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.
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 variableend)
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.
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.
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:
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.
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 thenprint("BOLO SUCCESS")elseprint("BOLO ERROR")endend, { 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:
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.
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 thenprint("BOLO SUCCESS")elseprint("BOLO ERROR")endend, { 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/falseexports['qs-dispatch']:ToggleDuty(Boolean)
-- Return true if is on duty or false if is off dutyexports['qs-dispatch']:GetIsOnDuty()