Client Exports

Here you will find all the useful exports for this asset, please read each step and example carefully to better understand how it works, we do not recommend using these if you are not an experienced developer.


GetPlayerInfo

To obtain the player's information you must use the following export.

exports['qs-dispatch']:GetPlayerInfo()

Export exports['qs-dispatch']:GetPlayerInfo() returns an object with the following player information.

ped

Player character identifier (game ped id)

coords

Player's coordinates on the map.

street_1

Name of the street near the player (first street)

street_2

Name of the street near the player (second street)

sex

Gender of the player's character.

vehicle

Identifier of the vehicle the player is in (if in one)

vehicle_label

Vehicle label/description.

vehicle_colour

Color of the vehicle.

vehicle_plate

Vehicle registration number.

speed

Vehicle speed in kilometers per hour (if in one)

The return object has a format similar to:

{
    ped = <pedId>,
    coords = vector3,
    street_1 = "String",
    street_2 = "String",
    sex = "String",
    vehicle = "Vehicle",
    vehicle_label = vehicle_label or 'VehLabel Unknown',
    vehicle_colour = vehicle_colour or 'VehColor Unknown',
    vehicle_plate = vehicle_plate or 'VehPlate Unknown',
    speed = speed or 0
}

getSSURL

To get the screanshot of the local player (client) you must use the following export.

This export returns a text string in case of getting the image as for example cdn.discordapp.net/image.png. This can also return nil in case you have not been able to take the screenshot.

exports['qs-dispatch']:getSSURL(function(image)
    -- Other code using image variable
end)

Creating Dispatch Call

The event qs-dispatch:server:CreateDispatchCall is used to create a dispatch call in a dispatch management system. You must pass an object as an argument to the event with the following data.

  • job (array): A list of jobs related to the dispatch call. You can include values such as 'police', 'sheriff', 'traffic', 'patrol' and any others you wish to receive the dispatch call.

  • callLocation (vector3): The coordinates of the location of the dispatch call. You must provide the coordinates in the form of a vector3 object.

  • callCode (table): An object containing a call code and an associated code fragment. For example, you can have a call code 'Hight Speed' with a code fragment 'Vehicle'.

  • message (string): A message describing the dispatch call. It may include relevant information such as vehicle model, license plate, color and speed.

  • flashes (boolean): A Boolean value indicating whether the dispatch call icon should flash.

  • image (string o nil): An image attached to the dispatch call. This can be an image URL or nil if there is no image attached.

  • blip (table): An object describing the blip associated with the dispatch call. It may contain properties such as the blip's sprite, scale, color, whether it blinks, the associated text, and the blip's duration time in milliseconds.

Be sure to provide the proper data in the correct format when calling this event to create a dispatch call correctly.

TriggerServerEvent('qs-dispatch:server:CreateDispatchCall', {
    job = { 'police', 'sheriff', 'traffic', 'patrol' },
    callLocation = vector3(0,0,0),
    callCode = { code = '<CALL CODE>', snippet = '<CALL SNIPPED EX: 10-10>' },
    message = "Call Message",
    flashes = false, -- you can set to true if you need call flashing sirens...
    image = "URL", -- Url for image to attach to the call 
    --you can use the getSSURL export to get this url
    blip = {
        sprite = 488, --blip sprite
        scale = 1.5, -- blip scale
        colour = 1, -- blio colour
        flashes = true, -- blip flashes
        text = 'Hight Speed', -- blip text
        time = (20 * 1000), --blip fadeout time (1 * 60000) = 1 minute
    },
    otherData = {
-- optional if you dont need this you can remove it and remember remove the `,` after blip end and this block
       {
           text = 'Red Obscure', -- text of the other data item (can add more than one)
           icon = 'fas fa-user-secret', -- icon font awesome https://fontawesome.com/icons/
       }
     }
})

Creating Dispatch Call With Player Data

In this example we will use the above example CreateDispatchCall and GetPlayerInfo.

local playerData = exports['qs-dispatch']:GetPlayerInfo()

TriggerServerEvent('qs-dispatch:server:CreateDispatchCall', {
    job = { 'police', 'sheriff', 'traffic', 'patrol' },
    callLocation = playerData.coords,
    callCode = { code = 'Hight Speed', snippet = 'Vehicle' },
    message = " street_1: ".. playerData.street_1.. " street_2: ".. playerData.street_2.. " sex: ".. playerData.sex.. " vehicle_label: ".. playerData.vehicle_label.. " vehicle_colour: ".. playerData.vehicle_colour.. " vehicle_plate: ".. playerData.vehicle_plate.. " speed: ".. playerData.speed.. "",
    flashes = false,
    image = image or nil,
    blip = {
        sprite = 488,
        scale = 1.5,
        colour = 1,
        flashes = true,
        text = 'Hight Speed',
        time = (20 * 1000),     --20 secs
    }
})

Creating Dispatch Call With Player Data and Image

In this example we will use the above example CreateDispatchCall , GetPlayerInfo and getSSURL.

local playerData = exports['qs-dispatch']:GetPlayerInfo()

if (not playerData) then
    ErrorPrint("Error getting player data")
    return
end

exports['qs-dispatch']:getSSURL(function(image)
    TriggerServerEvent('qs-dispatch:server:CreateDispatchCall', {
        job = { 'police', 'sheriff', 'traffic', 'patrol' },
        callLocation = playerData.coords,
        callCode = { code = 'Hight Speed', snippet = 'Vehicle' },
        message = " street_1: ".. playerData.street_1.. " street_2: ".. playerData.street_2.. " sex: ".. playerData.sex.. " vehicle_label: ".. playerData.vehicle_label.. " vehicle_colour: ".. playerData.vehicle_colour.. " vehicle_plate: ".. playerData.vehicle_plate.. " speed: ".. playerData.speed.. "",
        flashes = false,
        image = image or nil,
        blip = {
            sprite = 488,
            scale = 1.5,
            colour = 1,
            flashes = true,
            text = 'Hight Speed',
            time = (20 * 1000),     --20 secs
        }
    })
end)

Example of the use of a command on the Client

If you paste this into a client.lua file and run the test command in your game chat it will send a dispatch alert to all the jobs configured in that call 'police', 'sheriff', 'traffic' and 'patrol' which will be sent with the information of whoever runs the command.

RegisterCommand('testclient', function(source, args, rawCommand)
    local playerData = exports['qs-dispatch']:GetPlayerInfo()

if (not playerData) then
    ErrorPrint("Error getting player data")
    return
end

exports['qs-dispatch']:getSSURL(function(image)
        TriggerServerEvent('qs-dispatch:server:CreateDispatchCall', {
            job = { 'police', 'sheriff', 'traffic', 'patrol' },
            callLocation = playerData.coords,
            callCode = { code = 'Hight Speed', snippet = 'Vehicle' },
            message = " street_1: ".. playerData.street_1.. " street_2: ".. playerData.street_2.. " sex: ".. playerData.sex.. " vehicle_label: ".. playerData.vehicle_label.. " vehicle_colour: ".. playerData.vehicle_colour.. " vehicle_plate: ".. playerData.vehicle_plate.. " speed: ".. playerData.speed.. "",
            flashes = false,
            image = image or nil,
            blip = {
                sprite = 488,
                scale = 1.5,
                colour = 1,
                flashes = true,
                text = 'Hight Speed',
                time = (20 * 1000),     --20 secs
            }
        })
    end)
end, false)

Creating a History Entrie for vehicle

This feature will only work if you use Config.MDT.newMdt = false

In this section you will learn how to create a vehicle report from your customer code. Taking into account what you have learned in the previous parts such as GetPlayerInfo and getSSURL, you can use this events.

Parameters

The server callback takes three parameters:

  1. Callback Function: A function that is executed when a response is received from the server. The resp argument indicates whether the operation was successful or not.

  2. Data Object: An object containing the vehicle data to be stored in the registry. You must provide the following data:

    • type (string): Type of violation or event. Do not modify the value.

    • plate (string): Vehicle license plate.

    • zone (string): Text of the area or name of the official related to the event.

    • data (table): A list of vehicle data to be stored in the registry. Each item in the list is an object with the following properties:

      • key (string): Title or label of the data.

      • value (string): Data content or value.

An example of server callback usage is shown below:

TriggerServerCallback("qs-dispatch:server:setVehicleDataRecord", function(resp)
    if resp then
        print("BOLO SUCCESS")
    else
        print("BOLO ERROR")
    end
end, {
    type = "infraction",
    plate = "ABC123",
    zone = "Centro de la ciudad",
    data = {
        { key = "Modelo", value = "Sedan" },
        { key = "Placa", value = "ABC123" },
        { key = "Color", value = "Rojo" },
        { key = "Velocidad", value = "60 km/h" },
        { key = "Zona",  value = "Centro de la ciudad" },
        { key = "Límite", value = "50 km/h" },
        { key = "Multa",  value = "100$" },
        { key = "Imagen", value = "https://example.com/image.jpg" }
    }
})

Creating History Entrie for Player

This feature will only work if you use Config.MDT.newMdt = false

This History will be automatically added to the player's job database, for example if Callabck is run on a player who is a police officer, only the police officers will be able to see this.

Parameters

The server callback takes three parameters:

  1. Callback Function: A function that is executed when a response is received from the server. The resp argument indicates whether the operation was successful or not.

  2. Data Object: An object containing the history data to be inserted. You must provide the following data:

    • identifier (string): Data Player identifier.

    • datatype (string): Type of violation or event. Do not modify the value.

    • dataobj (table): An object containing detailed information about the history data. You must provide the following properties:

      • message (string): Message associated with the history data.

      • by (string): Who entered the history data.

      • title (string): Title of the history data.

      • data (table): A list of data to be stored in the registry. Each item in the list is an object with the following properties:

        • key (string): Title or label of the data.

        • value (string): Data content or value.

An example of server callback usage is shown below:

TriggerServerCallback("qs-dispatch:server:insertHistoryData", function(resp)
    if resp then
        print("BOLO SUCCESS")
    else
        print("BOLO ERROR")
    end
end, {
    identifier = "12345",
    datatype = "infraction",
    dataobj = {
        message = "Historial de incidente",
        by = "John#1234",
        title = "Incidente de tráfico",
        data = {
            { key = "Descripción", value = "Accidente de tráfico en la intersección" },
            { key = "Fecha", value = "2023-07-13" },
            { key = "Hora", value = "15:30" },
            { key = "Lugar", value = "Calle principal" }
        }
    }
})

Remember to provide the correct data in the right format when using this server callback. Be sure to adapt it to your programming logic and data structure.


Job duty system

Dispatch asset brings an export to do a duryoff and dutyon, to give permissions for the use of dispatch and mdt. In case the duty is false then you will not have access to dispatch and mdt.

-- We control whether or not the worker can use dispatch and mdt with true/false
exports['qs-dispatch']:ToggleDuty(Boolean)
-- Return true if is on duty or false if is off duty
exports['qs-dispatch']:GetIsOnDuty()

Default Exports

    exports['qs-dispatch']:VehicleShooting()
    exports['qs-dispatch']:Shooting()
    exports['qs-dispatch']:OfficerDown()
    exports['qs-dispatch']:SpeedingVehicle()
    exports['qs-dispatch']:Fight()
    exports['qs-dispatch']:InjuriedPerson()
    exports['qs-dispatch']:DeceasedPerson()
    exports['qs-dispatch']:StoreRobbery()
    exports['qs-dispatch']:FleecaBankRobbery()
    exports['qs-dispatch']:PaletoBankRobbery()
    exports['qs-dispatch']:PacificBankRobbery()
    exports['qs-dispatch']:PrisonBreak()
    exports['qs-dispatch']:VangelicoRobbery()
    exports['qs-dispatch']:HouseRobbery()
    exports['qs-dispatch']:DrugSale()
    exports['qs-dispatch']:ArtGalleryRobbery()
    exports['qs-dispatch']:HumaneRobery()
    exports['qs-dispatch']:TrainRobbery()
    exports['qs-dispatch']:VanRobbery()
    exports['qs-dispatch']:UndergroundRobbery()
    exports['qs-dispatch']:DrugBoatRobbery()
    exports['qs-dispatch']:UnionRobbery()
    exports['qs-dispatch']:YachtHeist()
    exports['qs-dispatch']:CarBoosting()
    exports['qs-dispatch']:CarJacking()
    exports['qs-dispatch']:VehicleTheft()
    exports['qs-dispatch']:SuspiciousActivity()
    exports['qs-dispatch']:SignRobbery()
    exports['qs-dispatch']:IllegalRacing()
    exports['qs-dispatch']:Kidnapping()
    exports['qs-dispatch']:CyberAttack()
    exports['qs-dispatch']:IllegalFishing()
    exports['qs-dispatch']:ArmsDeal()

Last updated

Was this helpful?