HEX
HexscriptsClassicPremium HUD

Configurations

Here you will get all configurations & open source files that are included within this script.

Config Files

Config = {
    Debug = false,

    Framework = 'ESX', -- ESX | QBCore | Standalone
    Locale = 'en',
    Voice = {
        System = 'saltychat', -- Saltychat | pma
        Ranges = { 1, 3.5, 8, 32 },
        RangeColor = {
            red = 237,
            green = 2,
            blue = 2
        } 
    },

    TxAnnounces = {
        restart = {
            enable = true, -- if true it will use txAdmin restarts, dont forget to hide it in the settings from txAdmin
            type = 'announcement', -- announcement | notify
            timeout = 8000 -- ms how long the restart announcement should be shown
        },
        announcement = {
            enable = true, -- if true it will use txAdmin announcements, dont forget to hide it in the settings from txAdmin
            type = 'announcement', -- announcement | notify
            timeout = 8000 -- ms how long the announcement should be shown
        },
        directMessage = {
            enable = true, -- if true it will use txAdmin Direct Messages, dont forget to hide it in the settings from txAdmin
            type = 'notify', -- announcement | notify
            timeout = 7000 -- ms how long the direct message should be shown
        },
    },

    TeamlerAd = {
        enable = true,
        defaultGroup = 'user',
        reSendData = 1000 * 15, -- 15 Seconds, you can refresh it too via the event TriggerEvent('hex_hud:reSendTeamlerData') server only
        airportDimension = 5,   
    },

    Server = {
        Name = 'HEX SCRIPTS',
        Bottom = 'ROLEPLAY',
        Currency = '$'
    },

    Speedo = {
        kmh = false, -- if false it will mp/h instead of km/h
        disableSpecificVehicles = {
            class = {
                [13] = true, -- cycles
            },
            models = {
                [joaat('bmx')] = true,
            }
        }
    },

    Chat = {
        enabled = true,
        text = 'Write a message here...',
        keymapping = {
            command = 'openChat',
            desc = 'Open the Chat',
            mapper = 'keyboard',
            key = 't'
        }
    },

    Waits = {
        Vehicle = 0,
        Refreshfood = 1000 * 60 * 10
    },

    Binders = { -- icons from here https://fontawesome.com/search
        {
            icon = 'fa-solid fa-phone',
            keybind = 'F1'
        }
    },

    Permissions = {
        teamchat = {
            'projektleitung',
            'superadmin',
            'admin'
        },

        announce = {
            'projektleitung',
            'superadmin',
            'admin'
        }
    },

    NotifySound = {
        ["notify"] = {
            mp3 = false,
            gta = {
                audioName = 'ATM_WINDOW',
                audioRef = 'HUD_FRONTEND_DEFAULT_SOUNDSET'
            },
            url = 'sounds/alarm.mp3'
        },

        ["announce"] = {
            mp3 = false,
            gta = {
                audioName = 'CHALLENGE_UNLOCKED',
                audioRef = 'HUD_AWARDS'
            },
            url = 'sounds/alarm.mp3'
        }
    },

    Commands = {
        ["settings"] = {
            command = 'settings',
            enabled = true,
        },

        ["id"] = {
            command = 'id',
            enabled = true
        },

        ["ids"] = {
            command = 'ids',
            enabled = true
        },

        ["ooc"] = {
            command = 'ooc',
            enabled = true
        },

        ["tc"] = {
            command = 'tc',
            enabled = true
        },

        ["announce"] = {
            command = 'announce',
            enabled = true
        }
    },
    
    DefaultSettings = {
        food = 5,
        helpNotify = 2,
        speedo = 1,
        notify = 0,
        announce = 0,
        server = 1,
        binder = true,
        weapon = true,
        job = true,
        street = true,
        enableBankOrBlack = true,
        switchBankBlack = true
    },

    DefaultPositions = {
        food = { x = 0, y = 0 },
        thirst = { x = 0, y = 0 },
        speedo = { x = 0, y = 0 },
        modern_radio = { x = 0, y = 0 },
        modern_mic = { x = 0, y = 0 },
        modern_eat = { x = 0, y = 0 },
        modern_thirst = { x = 0, y = 0},
        modern_street = { x = 0, y = 0 },
        modern_job = { x = 0, y = 0 },
        classic_street = { x = 0, y = 0 },
        classic_job = { x = 0, y = 0 }
    },

    Locales = {
        ['de'] = {
            ['info'] = 'Information!',
            ['your_id'] = 'Deine Id Lautet: %s',
            ['no_player'] = 'Kein Spieler in der Nähe!',
            ['near_player_id'] = 'Seine Id Lautet: %s',

            ['tx_admin_restart'] = 'Geplanter Neustart',
            ['tx_admin_announce'] = 'Serverankündigung von %s',
            ['tx_admin_dm'] = 'Direktnachricht von %s',

            -- ui
            ['save'] = 'Setzen',
            ['reset'] = 'Reset',
            ['select'] = 'Auswählen',

            ['binder'] = 'Keybinds',
            ['weapon'] = 'Waffenanzeige',
            ['job'] = 'Jobanzeige',
            ['street'] = 'Straßenanzeige',
            ['enableBank'] = 'Bank/Schwarzgeldanzeige',
            ['switchBankBlack'] = 'Grün oder Schwarzgeld',
            ['eat_hud'] = 'Nahrungsanzeige',
            ['speedo_hud'] = 'Geschwindigkeitsanzeige',
            ['help_notify'] = 'Help Benachrichtigung',
            ['notify'] = 'Benachrichtigung',
            ['announce'] = 'Ankündigung',
            ['server'] = 'HUD',

            ['server_1'] = 'Classic',
            ['server_2'] = 'Modern',

            ['eat_hud_1'] = 'Classic',
            ['eat_hud_2'] = 'Modern',
            ['eat_hud_3'] = 'Minimalistic',
            ['eat_hud_4'] = 'Kreis',
            ['eat_hud_5'] = 'Advanced',
            ['eat_hud_6'] = 'Hud Modern',

            ['help_notify_1'] = 'Modern',
            ['help_notify_2'] = 'Minimalistic',
            ['help_notify_3'] = 'Classic',

            ['speedo_hud_1'] = 'Classic',
            ['speedo_hud_2'] = 'Modern',
            ['speedo_hud_3'] = 'Minimalistic',
            ['speedo_hud_4'] = 'Advanced',

            ['notify_1'] = 'Classic',
            ['notify_2'] = 'Minimalistic',
            ['notify_3'] = 'Advanced',

            ['announce_1'] = 'Classic',
            ['announce_2'] = 'Minimalistic',
            ['announce_3'] = 'Advanced'
        },
    
        ['en'] = {
            ['info'] = 'Information!',
            ['your_id'] = 'Your Id Is: %s',
            ['no_player'] = 'No player nearby!',
            ['near_player_id'] = 'His Id Is: %s',

            ['tx_admin_restart'] = 'Scheduled Restart',
            ['tx_admin_announce'] = 'Server announcement by %s',
            ['tx_admin_dm'] = 'Direct Message from %s',

            -- ui
            ['save'] = 'Save',
            ['reset'] = 'Reset',
            ['select'] = 'Select',

            ['binder'] = 'Keybinds',
            ['weapon'] = 'Weapons display',
            ['job'] = 'Job display',
            ['street'] = 'Street display',
            ['enableBank'] = 'Bank/Black Money Display',
            ['switchBankBlack'] = 'Bank or Black Money',
            ['eat_hud'] = 'Food indicator',
            ['speedo_hud'] = 'Speedometer',
            ['help_notify'] = 'Help Notification',
            ['notify'] = 'Notification',
            ['announce'] = 'Announce',
            ['server'] = 'HUD',

            ['server_1'] = 'Classic',
            ['server_2'] = 'Modern',

            ['eat_hud_1'] = 'Classic',
            ['eat_hud_2'] = 'Modern',
            ['eat_hud_3'] = 'Minimalistic',
            ['eat_hud_4'] = 'Classic',
            ['eat_hud_5'] = 'Advanced',
            ['eat_hud_6'] = 'Hud Modern',

            ['help_notify_1'] = 'Modern',
            ['help_notify_2'] = 'Minimalistic',
            ['help_notify_3'] = 'Classic',

            ['speedo_hud_1'] = 'Classic',
            ['speedo_hud_2'] = 'Modern',
            ['speedo_hud_3'] = 'Minimalistic',
            ['speedo_hud_4'] = 'Advanced',

            ['notify_1'] = 'Classic',
            ['notify_2'] = 'Minimalistic',
            ['notify_3'] = 'Advanced',

            ['announce_1'] = 'Classic',
            ['announce_2'] = 'Minimalistic',
            ['announce_3'] = 'Advanced'
        }
    }
}

Config.Options = {
    {
        label = Config.Locales[Config.Locale]['server'],
        name = 'server',
        type = 'options',
        options = {
            Config.Locales[Config.Locale]['server_1'],
            Config.Locales[Config.Locale]['server_2']
        }
    },

    {
        label = Config.Locales[Config.Locale]['eat_hud'],
        name = 'food',
        type = 'options',
        options = {
            Config.Locales[Config.Locale]['eat_hud_1'],
            Config.Locales[Config.Locale]['eat_hud_2'],
            Config.Locales[Config.Locale]['eat_hud_3'],
            Config.Locales[Config.Locale]['eat_hud_4'],
            Config.Locales[Config.Locale]['eat_hud_5'],
            Config.Locales[Config.Locale]['eat_hud_6']
        }
    },

    {
        label = Config.Locales[Config.Locale]['speedo_hud'],
        name = 'speedo',
        type = 'options',
        options = {
            Config.Locales[Config.Locale]['speedo_hud_1'],
            Config.Locales[Config.Locale]['speedo_hud_2'],
            Config.Locales[Config.Locale]['speedo_hud_3'],
            Config.Locales[Config.Locale]['speedo_hud_4']
        }
    },

    {
        label = Config.Locales[Config.Locale]['help_notify'],
        name = 'helpNotify',
        type = 'options',
        options = {
            Config.Locales[Config.Locale]['help_notify_1'],
            Config.Locales[Config.Locale]['help_notify_2'],
            Config.Locales[Config.Locale]['help_notify_3'],
        }
    },

    {
        label = Config.Locales[Config.Locale]['notify'],
        name = 'notify',
        type = 'options',
        options = {
            Config.Locales[Config.Locale]['notify_1'],
            Config.Locales[Config.Locale]['notify_2'],
            Config.Locales[Config.Locale]['notify_3'],
        }
    },

    {
        label = Config.Locales[Config.Locale]['announce'],
        name = 'announce',
        type = 'options',
        options = {
            Config.Locales[Config.Locale]['announce_1'],
            Config.Locales[Config.Locale]['announce_2'],
            Config.Locales[Config.Locale]['announce_3'],
        }
    },

    {
        label = Config.Locales[Config.Locale]['binder'],
        name = 'binder',
        type = 'checkbox'
    },

    {
        label = Config.Locales[Config.Locale]['weapon'],
        name = 'weapon',
        type = 'checkbox'
    },

    {
        label = Config.Locales[Config.Locale]['job'],
        name = 'job',
        type = 'checkbox'
    },

    {
        label = Config.Locales[Config.Locale]['street'],
        name = 'street',
        type = 'checkbox'
    },

    {
        label = Config.Locales[Config.Locale]['enableBank'],
        name = 'enableBankOrBlack',
        type = 'checkbox'
    },

    {
        label = Config.Locales[Config.Locale]['switchBankBlack'],
        name = 'switchBankBlack',
        type = 'checkbox'
    },
}

Open Source Files

local playerLoaded = false

Citizen.CreateThread(function()
    if Config.Framework == 'ESX' then
        local status, ESX = pcall(function()
            return exports['es_extended']:getSharedObject()
        end)

        if not status then
            while not ESX do
                TriggerEvent("esx:getSharedObject", function(object) ESX = object end)
                Citizen.Wait(50)
            end
        end

        while ESX.GetPlayerData().job == nil do
            Citizen.Wait(100)
        end

        while not ESX.IsPlayerLoaded() do
            Citizen.Wait(50)
        end

        Citizen.Wait(500)

        ESX.PlayerData = ESX.GetPlayerData()

        playerLoaded = true

        RegisterNetEvent('esx:setJob', function(job)
            ESX.PlayerData.job = job
        end)

        RegisterNetEvent('esx:setAccountMoney', function(account)
            SendNUIMessage({
                action = 'setMoney',
                data = {
                    type = account.name,
                    money = account.money
                }
            })
        end)

        RegisterNetEvent('esx:setJob', function(job)
            ESX.PlayerData.job = job

            SendNUIMessage({
                action = 'setJob',
                data = {
                    label = ESX.PlayerData.job.label,
                    gLabel = ESX.PlayerData.job.grade_label
                }
            })
        end)

        function GetJob()
            return {
                label = ESX.PlayerData.job.label,
                gLabel = ESX.PlayerData.job.grade_label
            }
        end

        if GetResourceState('hex_food') == 'started' then
            RegisterNetEvent('hex_food:onTick', function(food, thirst)
                SendNUIMessage({
                    action = 'refreshFood',
                    data = {
                        food = food,
                        thirst = thirst
                    }
                })
            end)
        elseif GetResourceState('esx_status') == 'started' then
            RegisterNetEvent('esx_status:onTick', function(data)
                local hunger, thirst
                
                for i = 1, #data do
                    if data[i].name == "thirst" then
                        thirst = math.ceil(data[i].percent)
                    end
                    if data[i].name == "hunger" then
                        hunger = math.ceil(data[i].percent)
                    end
                end

                SendNUIMessage({
                    action = 'refreshFood',
                    data = {
                        food = hunger,
                        thirst = thirst
                    }
                })
            end)
        end

        function GetFood()
            if GetResourceState('hex_food') == 'started' then
                return exports['hex_food']:GetFood()
            elseif GetResourceState('esx_status') == 'started' then
                local status = nil
                local timesToTry = 0

                while status == nil and timesToTry < 10 do
                    Citizen.Wait(50)
                    timesToTry = timesToTry + 1

                    TriggerEvent('esx_status:getStatus', 'hunger', function(stats)
                        status = stats.val / 10000
                    end)
                end
                
                return status ~= nil and math.ceil(status) or 0
            else
                return math.random(1, 100)
            end
        end

        function GetThirst()
            if GetResourceState('hex_food') == 'started' then
                return exports['hex_food']:GetThirst()
            elseif GetResourceState('esx_status') == 'started' then
                local status = nil
                local timesToTry = 0

                while status == nil and timesToTry < 10 do
                    Citizen.Wait(50)
                    timesToTry = timesToTry + 1
                
                    TriggerEvent('esx_status:getStatus', 'thirst', function(stats)
                        status = stats.val / 10000
                    end)
                end

                return status ~= nil and math.ceil(status) or 0
            else
                return math.random(1, 100)
            end
        end

        function GetWeaponFromHash(weapon)
            return ESX.GetWeaponFromHash(weapon)
        end

        function GetWeaponLabel(weaponName)
            return ESX.GetWeaponLabel(weaponName)
        end

        function GetMoney(account)
            for k, v in pairs(ESX.GetPlayerData().accounts) do
                if v.name == account then
                    return v.money
                end
            end

            return 0
        end
    end
end)

function IsPlayerLoaded()
    return playerLoaded
end