Remember that the system will work without using this type of exports, this guide is exclusively for people who want to create their own scripts using our dispatch alert system or simply to have information about the internal use of the resource.
In isolated cases you may need to use one of these events for your basic server resources, but usually it will all work automatically.
1. Getting Player Data
To obtain the player's information you must use the following export.
exports['qs-dispatch']:GetPlayerInfo(playerID, function(playerData)-- OTHER CODE USING THIS `playerData`end)
The function exports['qs-dispatch']:GetPlayerInfo() obligatorily it must be passed the id of the player to obtain the information and the function that will be executed after receiving the data, this export returns an object with the following information of the player:
The function exports['qs-dispatch']:GetSSURL() obligatorily you must pass the id of the player to obtain the information and the function that will be executed after receiving the data, this export returns a text string in case of obtaining the image as for example:cdn.discordapp.net/image.png This can also return nilin case you have not been able to take the screenshot
3. 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.
Example code:
TriggerEvent('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/ } }})
TriggerEvent('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 }})
If you paste this into a server.lua file and run the command test in your tx admin console or in your game chat (by entering a valid player id) it will send a dispatch alert to all the jobs configured in that call 'police', 'sheriff', 'traffic' and 'patrol'.
RegisterCommand('test', function(source,args,rawCommand)-- args[1] is the ID of the player/client you want to send the callback to to receive the datalocal PlayerID =tonumber(args[1])ifnot PlayerID then ErrorPrint("No player ID provided")returnend exports['qs-dispatch']:GetPlayerInfo(PlayerID, function(playerData)if (not playerData) then ErrorPrint("Error getting player data")returnend exports['qs-dispatch']:GetSSURL(PlayerID, function(screenshot) TriggerEvent('qs-dispatch:server:CreateDispatchCall', { job = { 'police', 'sheriff', 'traffic', 'patrol' }, callLocation = playerData.coords, callCode = { code ='Test Command', snippet ='TEST' }, 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 = screenshot ornil, blip = { sprite =488, scale =1.5, colour =1, flashes =true, text ='Test Command', time = (20*1000), --20 secs } })end)end)end, false)