HEX
HexscriptsPhone AppsDispatch App

Configurations

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

Config Files

Config = {}

Config.Debug = false -- Set to true to enable debug messages in the console
Config.Locale = 'automatic' -- automatic, en, de, es, fr, it, nl, pl, pt, tr, ar
Config.Framework = 'automatic' -- automatic, esx, qbcore, standalone

Config.Distance = {
    enabled = true, -- if enabled it will check if a dispatch is in range of the player already, if not it will not send the dispatch.
    maxDistance = 30.0, -- max distance
}

Config.Cooldown = {
    enabled = true, -- if enabled it will add a cooldown to the dispatch, so you cant spam it.
    time = 60, -- time in seconds
}

Config.Dispatches = {
    {
        name = 'ambulance', -- job name
        label = 'LSMD',
        description = 'Los Santos Medic Department'
    },

    {
        name = 'police', -- job name
        label = 'LSPD',
        description = 'Los Santos Police Department'
    },
    
    {
        name = 'sheriff', -- job name
        label = 'Sheriff',
        description = 'Los Santos Sheriff Department'
    },

    {
        name = 'fib', -- job name
        label = 'FIB',
        description = 'Los Santos Federal Investigation Bureau'
    },

    {
        name = 'doj', -- job name
        label = 'DOJ',
        description = 'Department of Justice'
    },

    {
        name = 'lsc', -- job name
        label = 'LSC',
        description = 'Los Santos Customs'
    },
}

Config.Zones = {
    enabled = true, -- if its enabled it will have
    positions = {
        {
            name = 'cayo',
            coords = {
                vector3(3630.1479, -4390.3218, 18.8659),
                vector3(4284.2832, -6172.2490, 13.8584),
                vector3(5962.7002, -6181.4614, 13.0729),
                vector3(5713.8022, -5174.3853, 10.7038),
                vector3(5118.9023, -4089.6326, 18.9263),
                vector3(4203.9561, -4062.7036, 12.5283)
            }
        },
    
        {
            name = 'south',
            coords = {
                vector3(6345.8896, 403.3148, 105.0050),
                vector3(-5941.3228, 422.4166, 105.0050),
                vector3(-5888.7900, -5142.2900, 105.0050),
                vector3(3498.5122, -5116.8369, 105.0050),
                vector3(3419.5996, -4190.2944, 105.0050),
                vector3(5036.2896, -3807.5754, 105.0050)
            }
        },
    
        {
            name = 'center',
            coords = {
                vector3(6345.8896, 403.3148, 105.0050),
                vector3(-5941.3228, 422.4166, 105.0050),
                vector3(-6123.0864, 1897.4667, 105.0050),
                vector3(6902.9165, 2127.8560, 105.0050),
            }
        },
    
        {
            name = 'north',
            coords = {
                vector3(6902.9165, 2127.8560, 105.0050),
                vector3(8888.6445, 8138.8096, 105.0050),
                vector3(-4703.3755, 8305.1152, 119.4313),
                vector3(-6123.0864, 1897.4667, 105.0050),
            }
        },
    }
}

if GetResourceState('amb-roxwood-map') == 'started' then
    Config.Zones.positions[#Config.Zones.positions + 1] = {
        name = 'roxwood',
        coords = {
            vector3(1147.9154, 6889.2192, 30.7576),
            vector3(733.5878, 6730.5601, 24.0171),
            vector3(519.5971, 7013.1304, 17.2006),
            vector3(501.3024, 6998.3784, 17.2006),
            vector3(241.5320, 7317.1870, 8.0950),
            vector3(167.3187, 7405.8472, 6.0035),
            vector3(-85.1174, 7279.0869, 6.0664),
            vector3(-99.5077, 6952.2534, 8.1137),
            vector3(-135.9979, 6819.8345, 6.2295),
            vector3(-159.0460, 6802.4785, 5.8159),
            vector3(-360.8724, 6725.2124, 5.2657),
            vector3(-404.0640, 6560.6392, 6.3983),
            vector3(-1498.1025, 6354.0083, 14.8239),
            vector3(-2208.0005, 6141.9214, 12.5018),
            vector3(-2656.9595, 5974.9512, 10.0280),
            vector3(-3103.3782, 5813.4985, 7.8364),
            vector3(-3631.2864, 5626.2158, 12.4191),
            vector3(-3784.2209, 5568.4976, 12.4191),
            vector3(-3880.4011, 5995.0479, 11.2047),
            vector3(-3911.9373, 6378.9209, 20.5655),
            vector3(-3916.8689, 6741.2266, 25.8212),
            vector3(-3921.7864, 7098.7744, 29.9227),
            vector3(-3922.9834, 7830.7314, 27.4870),
            vector3(-3892.4338, 8932.3672, 21.2903),
            vector3(-2573.7473, 9162.6240, 24.9461),
            vector3(-2373.0293, 9088.6533, 21.7858),
            vector3(-1335.8824, 8607.3926, 31.8326),
            vector3(35.4730, 7949.0200, 20.1846),
            vector3(63.7677, 8009.8677, 20.1846),
            vector3(222.7233, 7932.2051, 17.1739),
            vector3(817.2397, 7256.2354, 16.2436),
            vector3(1064.5510, 6796.9863, 15.1496),
        }
    }
end

Opensource Files

if Config.Framework ~= 'esx' then return end

local ESX = nil

function loadFramework()
    local status, ESXLOAD = pcall(function()
        return exports['es_extended']:getSharedObject()
    end)

    ESX = ESXLOAD

    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(50)
    end

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

    ESX.PlayerData = ESX.GetPlayerData()
end

function TriggerServerCallback(name, cb, ...)
    ESX.TriggerServerCallback(name, function(result)
        cb(result)
    end, ...)
end

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

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