Server Exports#
Server exports run only on the server. Use them to send an alert on behalf of a specific player, or to read the server's report list.
SendAlert is available in two ways — pick whichever fits your script:
- Export — direct call, works everywhere, but throws an error if
0r-dispatchhasn't started yet. - TriggerEvent — fire-and-forget, never throws, works no matter which resource starts first. If
0r-dispatchisn't running yet, the call is just silently dropped instead of crashing your script.
Both do the exact same thing under the hood.
Setup#
-- fxmanifest.lua
dependencies {
'0r-dispatch',
}
SendAlert (server)#
Sends the target player's own client through the same path as the client-side SendCustomAlert flow: that player's live position and exclusion-zone check are used, then it's synced to dispatch receivers.
exports['0r-dispatch']:SendAlert(src, 'Atm Robbery', '10-60', 'fa-dollar-sign',
{ 'police', 'bcso' }, 279)
-- same thing, as an event
TriggerEvent('0R:Dispatch:TriggerAlertForPlayer', src, 'Atm Robbery', '10-60', 'fa-dollar-sign',
{ 'police', 'bcso' }, 279)
Signature: (source, alertLabel, code, icon, jobs, blipId)
sourcemust be an online player's server id. The player's own client generates the alert, so they must be connected and not standing in a dispatch exclusion zone — otherwise nothing is sent.
Reports (export only)#
Returns the full table of dispatch reports held on the server. This is a getter, so it can only be used as an export — a TriggerEvent has no way to hand data back to the caller.
local reports = exports['0r-dispatch']:Reports()
for id, data in pairs(reports) do
print(id, data.type, data.title)
end
GetSelectedAlerts (export only)#
From the server's Reports list, returns the alerts whose dispatch rule lists job as a receiver. Also a getter — export only.
local policeAlerts = exports['0r-dispatch']:GetSelectedAlerts('police')
Only matches alerts created from a
data/settings.jsonrule (rule.type == alert.type). Custom alerts sent with an explicitjobstable (no matching rule) aren't included here.
Quick Reference#
| Function | Export | Event | Returns |
|---|---|---|---|
| SendAlert | ✅ | 0R:Dispatch:TriggerAlertForPlayer | — |
| Reports | ✅ | — (returns a value) | table |
| GetSelectedAlerts | ✅ | — (returns a value) | table |
For client exports, see client-exports.md. Rules and codes are read from data/settings.json and shared/config.lua.
Sending anonymous / system alerts (no player attached)#
If you don't have a specific online player to attribute the alert to (e.g. a scripted event with fixed coordinates), use the "custom" call shape instead — it writes straight to Reports without bouncing through any client:
exports['0r-dispatch']:SendAlert(
'Bank Heist', -- title
'10-99', -- code
'fa-bell', -- icon
{ 'police' }, -- jobs
161, -- blipId
coords, -- vector3
{ blipColor = 1, blipScale = 1.0 } -- extra (optional)
)
-- same thing, as an event
TriggerEvent('0R:Dispatch:TriggerCustomAlert', 'Bank Heist', '10-99', 'fa-bell',
{ 'police' }, 161, coords, { blipColor = 1, blipScale = 1.0 })