Create Dispatch Call
The qs-dispatch:server:CreateDispatchCall event allows server-side creation of dispatch calls for specific jobs with detailed customization. Define parameters like job roles, location, call codes, messages, and blip details to create fully interactive dispatch alerts. Use this to dynamically manage and relay emergency information to the appropriate players.
Dispatch Call in Client
The event qs-dispatch:server:CreateDispatchCall allows you to create dispatch calls in the system, targeting specific jobs and providing detailed call information. Below is a guide to using this event effectively.
Basic 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:
TriggerServerEvent('qs-dispatch:server:CreateDispatchCall', {
job = { 'police', 'sheriff', 'traffic', 'patrol' },
callLocation = vector3(0, 0, 0),
callCode = { code = '10-10', snippet = 'Vehicle Pursuit' },
message = "A vehicle speeding at 120 km/h with license plate ABC123 was spotted.",
flashes = true,
image = "https://cdn.example.com/image.png", -- Use getSSURL if needed
blip = {
sprite = 488,
scale = 1.5,
colour = 1,
flashes = true,
text = 'High-Speed Pursuit',
time = 60000, -- 1 minute
},
otherData = {
{
text = 'Suspect Wearing Red',
icon = 'fas fa-user-secret'
}
}
})Dispatch Call With Player Data
The combination of CreateDispatchCall and GetPlayerInfo allows you to dynamically generate dispatch calls based on real-time player information. This is useful for creating personalized and precise alerts for jobs like police or emergency services.
To create a dispatch call using real-time player data, use the following code:
local playerData = exports['qs-dispatch']:GetPlayerInfo()
TriggerServerEvent('qs-dispatch:server:CreateDispatchCall', {
job = { 'police', 'sheriff', 'traffic', 'patrol' }, -- Targeted jobs
callLocation = playerData.coords, -- Player's current location
callCode = { code = 'High Speed', snippet = 'Vehicle' }, -- Dispatch code
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, -- Detailed call message
flashes = false, -- No flashing icon
image = image or nil, -- Optional image URL for dispatch
blip = {
sprite = 488, -- Blip icon
scale = 1.5, -- Blip size
colour = 1, -- Blip color
flashes = true, -- Blip flashes
text = 'High Speed', -- Blip label
time = (20 * 1000), -- Blip duration in milliseconds
}
})Dispatch Call With Player Data and Image
This example demonstrates how to create a dispatch call that includes real-time player data and a screenshot URL. This is useful for creating detailed and visual alerts for dispatch jobs like police or emergency services.
To dynamically generate a dispatch call with player data and a screenshot, use the following code:
local playerData = exports['qs-dispatch']:GetPlayerInfo()
-- Check if player data is successfully retrieved
if (not playerData) then
ErrorPrint("Error getting player data")
return
end
-- Get the screenshot URL and create a dispatch call
exports['qs-dispatch']:getSSURL(function(image)
TriggerServerEvent('qs-dispatch:server:CreateDispatchCall', {
job = { 'police', 'sheriff', 'traffic', 'patrol' }, -- Targeted jobs
callLocation = playerData.coords, -- Player's current location
callCode = { code = 'High Speed', snippet = 'Vehicle' }, -- Dispatch code
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, -- Detailed call message
flashes = false, -- No flashing icon
image = image or nil, -- Screenshot URL for dispatch
blip = {
sprite = 488, -- Blip icon
scale = 1.5, -- Blip size
colour = 1, -- Blip color
flashes = true, -- Blip flashes
text = 'High Speed', -- Blip label
time = (20 * 1000), -- Blip duration in milliseconds
}
})
end)Client Command for Dispatch
Add the following code to your client.lua file. Running the /testclient command in-game will send a dispatch alert to the configured jobs (police, sheriff, traffic, patrol) with the player's details who executed 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 = 'High Speed', snippet = 'Vehicle' },
message = "Street 1: ".. playerData.street_1 ..", Street 2: ".. playerData.street_2 ..
", Gender: ".. playerData.sex ..", Vehicle: ".. playerData.vehicle_label ..
", Color: ".. playerData.vehicle_colour ..", Plate: ".. playerData.vehicle_plate ..
", Speed: ".. playerData.speed,
flashes = false,
image = image or nil,
blip = {
sprite = 488,
scale = 1.5,
colour = 1,
flashes = true,
text = 'High Speed',
time = (20 * 1000), -- 20 seconds
}
})
end)
end, false)Command Execution
Use /testclient in the game chat.
Player Data Fetching
The script gathers player details like location, vehicle, and speed.
Dispatch Alert Creation
Sends the gathered information to the configured jobs as a dispatch call.
This example demonstrates how to integrate qs-dispatch to trigger dispatch events dynamically based on player data.
Dispatch Call in Server
The event qs-dispatch:server:CreateDispatchCall is used to generate dispatch calls for specific jobs in the dispatch management system. This event should be triggered server-side, passing an object with the required parameters.
Basic 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:
TriggerEvent('qs-dispatch:server:CreateDispatchCall', {
job = { 'police', 'sheriff', 'traffic', 'patrol' }, -- List of jobs to receive the dispatch
callLocation = vector3(0, 0, 0), -- Coordinates of the call
callCode = { code = '10-10', snippet = 'Vehicle Pursuit' }, -- Call code and description
message = "A high-speed vehicle was spotted traveling at 120 km/h.", -- Dispatch call message
flashes = true, -- Should the blip on the map flash?
image = "URL", -- Optional: URL for an image attachment (use `getSSURL` if needed)
blip = { -- Blip details for the map
sprite = 488, -- Blip icon type
scale = 1.5, -- Blip size
colour = 1, -- Blip color
flashes = true, -- Blip flashes
text = 'High-Speed Pursuit', -- Blip label
time = (60 * 1000), -- Duration of the blip (milliseconds)
},
otherData = { -- Additional optional information
{
text = 'Suspect wearing red', -- Additional detail
icon = 'fas fa-user-secret' -- Font Awesome icon
}
}
})Dispatch Call With Player Data
This example demonstrates how to use the GetPlayerInfo export and CreateDispatchCall to generate a dispatch call using player information.
The GetPlayerInfo export retrieves detailed player data, which can then be used in the CreateDispatchCall event to send a dispatch alert to specified jobs.
exports['qs-dispatch']:GetPlayerInfo(PlayerID, function(playerData)
if (not playerData) then
ErrorPrint("Error getting player data")
return
end
TriggerEvent('qs-dispatch:server:CreateDispatchCall', {
job = { 'police', 'sheriff', 'traffic', 'patrol' },
callLocation = playerData.coords,
callCode = { code = 'High Speed', snippet = 'Vehicle' },
message = "Street 1: ".. playerData.street_1 ..", Street 2: ".. playerData.street_2 ..
", Gender: ".. playerData.sex ..", Vehicle: ".. playerData.vehicle_label ..
", Color: ".. playerData.vehicle_colour ..", Plate: ".. playerData.vehicle_plate ..
", Speed: ".. playerData.speed,
flashes = false,
image = nil,
blip = {
sprite = 488,
scale = 1.5,
colour = 1,
flashes = true,
text = 'High Speed',
time = (20 * 1000), -- 20 seconds
}
})
end)For static data, you can create a dispatch call without player-specific information using the following:
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, -- Enable flashing lights if needed
image = "URL", -- Attach an image URL (optional)
blip = {
sprite = 488, -- Blip icon
scale = 1.5, -- Blip size
colour = 1, -- Blip color
flashes = true, -- Blip flashes
text = 'High Speed', -- Blip label
time = (20 * 1000), -- Duration in milliseconds
}
})Dispatch Call With Player Data and Image
This example demonstrates how to use the CreateDispatchCall, GetPlayerInfo, and GetSSURL exports to create a dispatch call enriched with player data and a screenshot.
This implementation fetches player-specific details (e.g., location, vehicle information) and optionally attaches a screenshot for enhanced dispatch call details.
exports['qs-dispatch']:GetPlayerInfo(PlayerID, function(playerData)
if (not playerData) then
ErrorPrint("Error getting player data")
return
end
exports['qs-dispatch']:GetSSURL(PlayerID, function(screenshot)
TriggerEvent('qs-dispatch:server:CreateDispatchCall', {
job = { 'police', 'sheriff', 'traffic', 'patrol' },
callLocation = playerData.coords,
callCode = { code = 'High Speed', snippet = 'Vehicle' },
message = "Street 1: ".. playerData.street_1 ..
", Street 2: ".. playerData.street_2 ..
", Gender: ".. playerData.sex ..
", Vehicle: ".. playerData.vehicle_label ..
", Color: ".. playerData.vehicle_colour ..
", Plate: ".. playerData.vehicle_plate ..
", Speed: ".. playerData.speed,
flashes = false,
image = screenshot or nil, -- Attach screenshot if available
blip = {
sprite = 488,
scale = 1.5,
colour = 1,
flashes = true,
text = 'High Speed',
time = (20 * 1000), -- 20 seconds
}
})
end)
end)Server Command for Dispatch
This example demonstrates how to create a server command that triggers a dispatch alert with player-specific data. By using this command, you can send a dispatch notification to configured jobs like police, sheriff, traffic, and patrol.
Add the following code to your server.lua file. When you run the test command in the TxAdmin console or game chat (with a valid player ID), it will fetch player data and send a dispatch alert.
RegisterCommand('test', function(source, args, rawCommand)
-- Ensure the player ID is provided
local PlayerID = tonumber(args[1])
if not PlayerID then
ErrorPrint("No player ID provided")
return
end
-- Fetch player data
exports['qs-dispatch']:GetPlayerInfo(PlayerID, function(playerData)
if not playerData then
ErrorPrint("Error getting player data")
return
end
-- Fetch screenshot
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 ..
", Gender: " .. playerData.sex ..
", Vehicle: " .. playerData.vehicle_label ..
", Color: " .. playerData.vehicle_colour ..
", Plate: " .. playerData.vehicle_plate ..
", Speed: " .. playerData.speed,
flashes = false,
image = screenshot or nil, -- Attach screenshot if available
blip = {
sprite = 488,
scale = 1.5,
colour = 1,
flashes = true,
text = 'Test Command',
time = (20 * 1000), -- 20 seconds
}
})
end)
end)
end, false)Command Execution
Use /test [PlayerID] in the TxAdmin console or game chat to trigger the dispatch.
Dynamic Data Retrieval
The command fetches real-time player data, including location, vehicle details, and speed.
Screenshot Attachment
Automatically captures and attaches a player screenshot (if available) to the dispatch alert.
Dispatch Customization
Configure jobs, messages, blips, and other details within the CreateDispatchCall event.
This setup ensures a dynamic and interactive way to create dispatch alerts for specific players.