⚙️Configuration

Here we'll see how to configure your own Codes.

Configuring the Dispatch

Setting up your framework & SQL

We must configure the resource with the framework and SQL script used for our server. So for that, let's make some changes.

List of supported frameworks

Framework NameFramework Input

ESX Old (1.1)

ESX

ESX Legacy

ESX-Legacy

QB-Core

QB-Core

List of supported SQL scripts

Script NameScript Input

MySQL Async

mysql-async

OxMySQL

oxmysql

Example

config.lua
Config.Settings = {
    Framework = 'ESX', -- The Framework Input
    FrameworkEvent = 'esx:getSharedObject', -- Only works if using ESX as a Framework.
    FrameworkName = 'es_extended', -- The name of the Framework resource.
    MySQL = 'mysql-async', -- The SQL script input
}

Setting up your notification system

We must configure the resource with the notification system used for our server. So for that, let's make some changes.

List of supported notification systems:

NameInput

ug-notify

ug-notify

OKOK Notify

okokNotify

ESX Notification

ESX

QB-Core Notification

QB-Core

Default Notification

default

Custom Notification System

custom

If using a custom notification system, please refer to this documentation to configure the notification system.

Example

config.lua
Config.Settings = {
    NotifySystem = 'ug-notify', -- Notification System input 
}

Setting up the jobs

We must configure the jobs that can use the dispatch system. So for that, you must add to the table your wanted jobs to work.

Example

config.lua
Config.Dispatch = {
    Jobs = {
        'police', -- The job 'police' will have access to the dispatch.
        'ambulance', -- The job 'ambulance' will have access to the dispatch.
        'yourjob' -- The job 'yourjob' will have access to the dispatch.
    }
}

Configuring the Codes

How are the codes working

Before we see on how to add more codes, let's get an overview about how are the codes made and what are the contents of the tables.

Overview of a Code:

Config.Codes = {
    {
        Name = 'Code 1',
        Description = 'Officer Location',
        Type = 'code',
        Code = 1,
        Color = '#000000',
        DefaultKey = 'NUMPAD1',
        Jobs = {
            'police'    
        },
        Sound = {
            Enable = true,
            Name = 'code.ogg',
            Volume = 0.05
        }
    }
}

List of the table contents for the Code:

Name of the contentType of the contentDescription of the content

Name

string

This is the name of the code that will show when triggered.

Description

string

This is the description of the code that will show when triggered.

Type

string (code/panicButton)

This is to tell if ug-dispatch must say if it's a code or a panic button. The values are code/panicButton

Code

number

This determines which number to use if you are using commands (example: /code 1)

Color

string

This is the color of the code. The background of the dispatch will change determining which code was triggered.

DefaultKey

string

This is to set a default key to trigger the code. The key can be changed by the player in FiveM settings.

Jobs

table

This is to set the jobs that will receive the code (the job must be set in the jobs list before. Refer to this documentation).

Sound

table

Must check this list to get more details.

For the code color, you can use this website to get a color (must be in HEX format).

List of the table content's sound for the Code:

Name of the contentType of the contentDescription of the content

Enable

boolean

This is to enable or disable the sound that will be triggered when the code is called.

Name

string

This is the name of the sound file that can be found in the folder web/build.

Volume

number

This is the volume of the sound.

To add custom sounds, please refer to this documentation.

Example of a new code (for EMS)

Config.Dispatch = {
    Jobs = {
        'ambulance' -- Must have the job here to grant access to the dispatch.
    }
}

Config.Codes = {
    {
        Name = 'Code Blue',
        Description = 'Critical status of a patient',
        Type = 'code',
        Code = 5,
        Color = '#3356FF',
        DefaultKey = 'K',
        Jobs = {
            'ambulance'    
        },
        Sound = {
            Enable = true,
            Name = 'codeblue.ogg',
            Volume = 0.05
        }
    }
}

Configuring a Custom Notification System

You can always use a custom notification system in our scripts. To do that, please refer to the code bellow:

Config.Notify = {
    ClientNotify = function (notifyData)
        --###########################################################################--
        -- Here you can set your own notification system in case you don't use those --
        -- that we support.                                                         --
        --                                                                           --
        -- [[ Parameters Content ]]                                                  --
        -- notifyData: table                                                         --
        --      notifyData.title: string                                             --
        --      notifyData.description: string                                       --
        --      notifyData.type: string                                              --
        --      notifyData.time: number                                              --
        --                                                                           --
        -- [[ Example ]]                                                             --
        -- local title = notifyData.title                                            --
        -- local description = notifyData.description                                -- 
        -- local type = notifyData.type                                              --
        -- local time = notifyData.time                                              --
        --                                                                           --
        -- exports['ug-notify']:CreateNotify(title, description, type, time)         --
        --###########################################################################--

        local title = notifyData.title -- This is the title of the notification.
        local description = notifyData.description -- This is the description of the notification.
        local type = notifyData.type -- This is the type of the notification.
        local time = notifyData.time -- This is the time of the notification.

        -- Put here the event/export that you use for your notification script.
        -- Example: exports['ug-notify']:CreateNotify(title, description, type, time)
    end,

    ServerNotify = function (source, notifyData)
        --##############################################################################################--
        -- Here you can set your own notification system in case you don't use those that we support.  --
        --                                                                                              --
        -- [[ Parameters Content ]]                                                                     --
        -- source: playerSrc                                                                            --
        -- notifyData: table                                                                            --
        --      notifyData.title: string                                                                --
        --      notifyData.description: string                                                          --
        --      notifyData.type: string                                                                 --
        --      notifyData.time: number                                                                 --
        --                                                                                              --
        -- [[ Example ]]                                                                                --
        -- local title = notifyData.title                                                               --
        -- local description = notifyData.description                                                   -- 
        -- local type = notifyData.type                                                                 --
        -- local time = notifyData.time                                                                 --
        --                                                                                              --
        -- TriggerClientEvent('ug-notify:CreateNotify', source, title, description, type, time)         --
        --##############################################################################################--
        
        local title = notifyData.title -- This is the title of the notification.
        local description = notifyData.description -- This is the description of the notification.
        local type = notifyData.type -- This is the type of the notification.
        local time = notifyData.time -- This is the time of the notification.

        -- Put here the event/export that you use for your notification script.
        -- TriggerClientEvent('ug-notify:CreateNotify', source, title, description, type, time)
    end
}

Adding a new custom sound for codes

To add a new sound for the codes, you must simply download the sound you like and the drag it to the folder web/build. There, you will find the code.ogg and code99.ogg sounds refering to the default sounds of the dispatch.

Last updated