Add alerts
In this page you will learn how you can include new alerts, from simple command-based alerts like /911
to complex custom alerts with advanced functionalities.
Default Alert Commands
Go to configs/cl_config.lua
and include your new command inside this table.
-- Priority 'low', 'medium' or 'high'
-- Car robbery, shop robbery and bank robbery can be found inside client/api/alert_handlers.lua
CL_CONFIG.AlertCommands = {
{
command = '911',
job = { 'police' },
code = '10-13',
default_priority = 'medium',
enabled = true,
anonymous = false,
--timeout = 10, --Optional timeout you can set in seconds
},
{
command = 'anon911',
job = { 'police' },
code = '10-13',
default_priority = 'medium',
enabled = true,
anonymous = true,
},
{
command = 'sos',
code = 'P2',
job = { 'police', 'ambulance' },
prepared_args = 'A officer is in need of assistance, please come as fast as possible.',
default_priority = 'high',
enabled = true,
anonymous = true,
blip_time = 5,
-- job_restricted = 'police', or { 'police', 'ambulance' } (optional)
sos = true,
blip = { -- Optional parameter to override the default blip
sprite = 84,
colour = 3,
scale = 0.7,
flashes = true,
text = '10-13 - Officer in distress',
}
},
{
command = 'emergency',
code = 'P2',
job = { 'police', 'ambulance' },
default_priority = 'high',
enabled = true,
anonymous = false,
}
}
Alert Command Parameters
command: The command that will be used (e.g., '911', 'sos')
job: The job(s) that will receive the alert (string or table)
code: The alert code displayed in dispatch
default_priority: Alert priority ('low', 'medium', or 'high')
enabled: Whether the command is enabled
anonymous: If the character name should appear or not
timeout: Optional timeout in seconds before alert expires
prepared_args: Pre-filled message for the alert
job_restricted: Optional restriction on who can use the command
sos: Mark as an SOS alert for special handling
blip_time: Time in seconds until the blip fades
blip: Optional blip configuration override
Custom Alerts
For more advanced alerts that require player data, vehicle information, or custom logic, you can create custom alerts using the dispatch API.
Client-Side API
Getting Player Data
To create custom alerts with dynamic information, use the GetPlayerData
export to retrieve comprehensive player information:
local data = exports['rcore_dispatch']:GetPlayerData()
This export returns different data depending on whether the player is in a vehicle or not.
Player Data (On Foot)
local data = exports['rcore_dispatch']:GetPlayerData()
-- Returns:
data.street_1 -- "Marina Drive" (Raw street name)
data.zone -- "Sandy Shores" (Zone name)
data.street -- "Marina Drive, Sandy Shores" (Combined street and zone)
data.coords -- vector3(0,0,0) (Player coordinates)
data.sex -- "male" or "female" (Player ped gender)
data.ped -- 4354 (Ped ID)
Player Data (In Vehicle)
When the player is in a vehicle, additional vehicle data is included:
local data = exports['rcore_dispatch']:GetPlayerData()
-- All the above player data, plus:
-- Vehicle-specific data
data.vehicle_data.speed -- "54 km/h" (Speed with unit)
data.vehicle_data.dispatch_color -- "/#ff0000" (Color formatted for dispatch)
data.vehicle_data.color -- "#ff0000" (HEX color value)
data.vehicle_data.model_form -- "Zentorno" (Formatted vehicle name)
data.vehicle_data.vehicle_entity -- 4866 (Vehicle entity ID)
data.vehicle_data.model -- -1403128555 (Vehicle model hash)
data.vehicle_data.model_string -- "ZENTORNO" (Raw model string)
data.vehicle_data.heading -- "West" (Cardinal direction)
data.vehicle_data.plate -- "ABC123" (License plate)
-- Legacy compatibility fields
data.vehicle -- 4866 (Vehicle entity)
data.vehicle_label -- "Zentorno" (Formatted vehicle name)
data.vehicle_colour -- "/#ff0000" (Dispatch-formatted color)
data.speed -- "54.00 km/h" (Formatted speed)
data.heading -- "West" (Cardinal direction)
data.vehicle_plate -- "ABC123" (License plate)
Sending Custom Alerts (Client)
Use the rcore_dispatch:server:sendAlert
event to send custom alerts from the client:
local playerData = exports['rcore_dispatch']:GetPlayerData()
local alertData = {
code = '10-64', -- Alert code
default_priority = 'medium', -- 'low', 'medium', or 'high'
coords = playerData.coords, -- Alert location
job = 'police', -- Job(s) to receive alert (string or table)
text = 'Custom alert message', -- Alert description
type = 'alerts', -- Alert type for statistics
blip_time = 5, -- Optional: Blip fade time (seconds)
image = 'url_to_image.jpg', -- Optional: Image URL
custom_sound = 'url_to_sound.mp3', -- Optional: Custom sound URL
blip = { -- Optional: Custom blip settings
sprite = 54,
colour = 3,
scale = 0.7,
text = 'Custom Alert',
flashes = false,
radius = 0,
}
}
TriggerServerEvent('rcore_dispatch:server:sendAlert', alertData)
Server-Side API
Sending Alerts from Server
You can trigger alerts directly from server-side scripts using TriggerEvent
:
function sendCustomAlert(source)
local alertData = {
code = '10-64',
default_priority = 'high',
coords = vector3(0, 0, 0),
job = {'police', 'ambulance'},
text = 'Server-generated alert',
type = 'alerts',
blip_time = 10,
blip = {
sprite = 54,
colour = 1,
scale = 0.8,
text = 'Server Alert'
}
}
TriggerEvent('rcore_dispatch:server:sendAlert', alertData)
end
Getting Player Data from Server
For server-side scripts that need player data, you can use a callback system:
-- Usage example
exports['rcore_dispatch']:GetPlayerData(source, function(playerData)
local alertData = {
code = '10-64',
default_priority = 'medium',
coords = playerData.coords,
job = 'police',
text = string.format('Alert at %s involving %s', playerData.street, playerData.sex),
type = 'alerts'
}
TriggerEvent('rcore_dispatch:server:sendAlert', alertData)
end)
Alert Types for Statistics
The dispatch system tracks different alert types for statistics:
alerts
- General alertsbank_robbery
- Bank robbery incidentsshop_robbery
- Store robbery incidentscar_robbery
- Vehicle theft incidents
Complete Example: Car Theft Alert with Screenshot
Here's a comprehensive example that creates a car theft alert with a screenshot using the screenshot-basic resource. This example is configured to work with a Discord webhook for image hosting:
-- Client-side car theft alert with screenshot
function createCarTheftAlert()
-- Get player data
local playerData = exports['rcore_dispatch']:GetPlayerData()
-- Check if player is in a vehicle
if not playerData.vehicle_data then
return
end
-- Build dynamic alert message
local alertText = string.format(
'Vehicle theft in progress! Suspect is stealing a %s painted %s. ' ..
'Offender gender: %s, License plate: %s. Last seen at %s.',
playerData.vehicle_data.model_form,
playerData.vehicle_data.dispatch_color,
playerData.sex,
playerData.vehicle_data.plate,
playerData.street
)
-- Take screenshot and send alert (using Discord webhook)
exports['screenshot-basic']:requestScreenshotUpload(
CL_CONFIG.CarRobberyPictureWebhook, -- Discord webhook URL configured in your config
"files[]",
function(response)
local imageData = json.decode(response)
local alertData = {
code = '10-64 - Vehicle Theft',
default_priority = 'high',
coords = playerData.coords,
job = 'police',
text = alertText,
type = 'car_robbery',
blip_time = 8,
image = imageData.attachments[1].proxy_url, -- Discord CDN URL from webhook response
blip = {
sprite = 56, -- Car icon
colour = 1, -- Red
scale = 0.8,
text = 'Vehicle Theft',
flashes = true,
radius = 0
}
}
TriggerServerEvent('rcore_dispatch:server:sendAlert', alertData)
end
)
end
RegisterCommand('reportcartheft', function()
createCarTheftAlert()
end, false)
API Reference
Alert Data Structure
code
string
Yes
Alert code (e.g., "10-64", "10-13")
default_priority
string
Yes
Priority level: "low", "medium", "high"
coords
vector3
Yes
Alert coordinates
job
string/table
Yes
Job(s) to receive alert
text
string
Yes
Alert message text
type
string
Yes
Alert type for statistics
blip_time
number
No
Blip fade time in seconds
image
string
No
Image URL
custom_sound
string
No
Custom sound URL
blip
table
No
Custom blip configuration
Blip Configuration
scale
number
Blip size scale
text
string
Blip label text
flashes
boolean
Whether blip should flash
radius
number
Radius blip size (0 or nil = normal blip)
Examples of alert types and their implementations can be found in client/api/alert_handlers.lua
.
Last updated
Was this helpful?