Using provided export, you can simple trigger alert from server side. This is very much recommended method to do alerts, we've only included client side alerts, so we could provide you compatibility from other dispatches.
---**`server`**
---@param payload ServerAlertPayload
---@return boolean | nil, string | nil
function exports.fd_dispatch:addAlert(payload) end
---@class BlipPayload
---@field title? string
---@field time? number
---@field coords vector3
---@field sprite? number
---@field radius? number
---@field color number
---@field scale number
---@field flashes? boolean
---@field category? number
---@class ServerAlertPayload
---@field source? number
---@field title string
---@field description? string
---@field groups string[]
---@field location? { coords: vector3, street: string }
---@field priority? number
---@field code? string
---@field radioChannel? number
---@field metadata AlertMetadataType[]
---@field isArchived? boolean
---@field isEmergency? boolean
---@field isAnonymous? boolean
---@field isShooting? boolean
---@field blip string | BlipPayload
Providing source to the payload, script will automatically call source via callback and get location information. Coordinates and street information.
local succ, err = exports.fd_dispatch:addAlert({
source = source,
title = 'Important alert',
description = 'Very important alert. Go now!',
groups = { 'police' },
blip = 'shooting'
})
if not succ then
print('Failed adding alert', err)
end
To alert, you can provide as much information as you want. Everything will displayed in it.
local succ, err = exports.fd_dispatch:addAlert({
title = 'Important alert',
description = 'Very important alert. Go now!',
groups = { 'police' },
location = {
coords = vector3(0, 0, 0),
street = 'Random Street'
},
priority = 2,
code = '10-32',
blip = 'shooting',
metadata = {
{
type = 'general',
content = 'Important information 1'
},
{
type = 'general',
content = 'Important information 2'
}
}
})
if not succ then
print('Failed adding alert', err)
end
If you add isAnonymous
to the payload, location will be stripped automatically from payload and alert will become anonymous.
local succ, err = exports.fd_dispatch:addAlert({
title = 'Important alert',
description = 'Very important alert. Go now!',
groups = { 'police' },
location = {
coords = vector3(0, 0, 0),
street = 'Random Street'
},
priority = 2,
code = '10-32',
blip = 'shooting',
isAnonymous = true,
metadata = {
{
type = 'general',
content = 'Important information 1'
},
{
type = 'general',
content = 'Important information 2'
}
}
})
if not succ then
print('Failed adding alert', err)
end
If you add isAnonymous
to the payload, location will be stripped automatically from payload and alert will become anonymous.
local succ, err = exports.fd_dispatch:addAlert({
title = 'Important alert',
description = 'Very important alert. Go now!',
groups = { 'police' },
location = {
coords = vector3(0, 0, 0),
street = 'Random Street'
},
priority = 2,
code = '10-32',
blip = 'shooting',
metadata = {
{
type = 'general',
content = 'Important information 1'
},
{
type = 'vehicle',
model = 'Paragon 3',
plate = 'XXX1234',
color = '#123123'
}
}
})
if not succ then
print('Failed adding alert', err)
end
If provided, location will fetched from the provided source. Groups, which will see the alert and be informed about it. location{ coords: vector3, street: string }
Data about alert location. Dedicated alert radio channel, to which units will be able to join metadataAlertMetadataType[]
Alert metadata, this is used to put various information into the alert. Defines if alert is archived or not. Defines if alert is emergency or not. If it is, it will apply additional styles to it. Defines if alert is anonymous or not. Defines if alert is for shooting or not. Mostly used to suppress shots spam if it's enabled in config, and count shots fired in the area. If you provide a string, it will try to check for predefined blips in config/alerts.lua
-> predefinedBlips
config. Otherwise, provide blip data.