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(playerID, function(playerData)-- Other codes 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.
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)
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.
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.
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, -- blip 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 Creating Dispatch Call and GetPlayerInfo.
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 }})
Creating Dispatch Call With Player Data and Image
In this example we will use the above example Creating Dispatch Call and GetPlayerInfo and GetSSURL.
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 thenErrorPrint("No player ID provided")returnend exports['qs-dispatch']:GetPlayerInfo(PlayerID, function(playerData)if (not playerData) thenErrorPrint("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)