zephyr_dispatchExportsServer

Server Exports

zephyr_dispatch exposes six server-side exports for use by other resources.


CreateCall

Creates a dispatch call from a server-side script. This is the recommended approach when creating calls from non-client contexts (e.g. a robbery script’s server-side trigger). Returns the full call object.

local call = exports.zephyr_dispatch:CreateCall(data)

Parameters

All fields are optional, but title, message, and coords should always be provided.

FieldTypeDescription
titlestringCall title shown in the dispatch list.
messagestringDescription of the situation.
coordsvector3/tableWorld coordinates. Use { x, y, z } or a vector3.
locationstringHuman-readable location label.
codestringCall code (e.g. '10-90', '10-80'). Auto-inferred if omitted.
codeNamestringBlip icon key (e.g. 'bankrobbery', 'pursuitstarted').
prioritystring'P1' (high), 'P2' (medium), 'P3' (low). Defaults to 'P3'.
jobtable/stringJob(s) to receive the call. Defaults to all dispatch jobs.
sourcenumberServer ID of the player who triggered the event (0 for non-player).
callerSourcenumberServer ID of the caller (used to show caller identity).
showCallerIdentitybooleanAttach officer name/callsign to the call record.
callerNamestringOverride caller name. Used when source is 0 or not a player.
callerCallsignstringOverride caller callsign.
callerJobstringOverride caller job label.
followPrimarybooleanCall blip tracks the primary unit (auto-set for 10-80 code).
autoAttachSourcebooleanAttach the source player to the call automatically.
suppressNotifybooleanCreate the call silently — no alert toasts or NUI notifications.
extraInfotableAdditional info items: { { info = "string" }, ... }.
patientSourcenumberFor EMS calls: server ID of the downed patient.
patientNamestringPatient display name for EMS calls.
patientStatusstringPatient status text (e.g. 'Critical').

Returns: table — The created call object.

Examples

Basic robbery call from a server script:

local coords = vector3(150.26, -1040.45, 29.37)
local call = exports.zephyr_dispatch:CreateCall({
    title    = '10-90 - Fleeca Bank Robbery',
    message  = 'Silent alarm triggered — 2-3 armed suspects inside',
    coords   = coords,
    location = 'Alta Street / Fleeca Bank',
    code     = '10-90',
    codeName = 'bankrobbery',
    priority = 'P1',
    job      = { 'police', 'sheriff', 'bcso', 'sasp', 'lspd', 'sahp' },
})
print('Created call #' .. call.id)

Officer distress (10-99) showing caller identity:

exports.zephyr_dispatch:CreateCall({
    title              = '10-99 - Officer in Distress',
    message            = 'Officer requesting immediate assistance',
    coords             = GetEntityCoords(GetPlayerPed(officerSrc)),
    location           = 'Pillbox Hill',
    code               = '10-99',
    codeName           = 'officerdown',
    priority           = 'P1',
    job                = { 'police', 'sheriff', 'bcso', 'ambulance' },
    source             = officerSrc,
    showCallerIdentity = true,
    autoAttachSource   = true,
})

Silent background call (no toast notification):

exports.zephyr_dispatch:CreateCall({
    title          = '10-34 - Suspicious Activity',
    message        = 'ANPR flagged stolen vehicle in area',
    coords         = suspectCoords,
    location       = 'Davis Avenue',
    code           = '10-34',
    priority       = 'P3',
    job            = { 'police' },
    suppressNotify = true,
})

GetCalls

Returns all currently active dispatch calls. Optionally filter by a specific job name.

local calls = exports.zephyr_dispatch:GetCalls()
-- or filter by job:
local policeCalls = exports.zephyr_dispatch:GetCalls('police')

Parameters

ParameterTypeDescription
jobFilterstringOptional. Return only calls that target this specific job name.

Returns: table — Array of active call objects. See callUpdated event for field list.

Example

local calls = exports.zephyr_dispatch:GetCalls('police')
for _, call in ipairs(calls) do
    if call.status == 'active' then
        print(('#%d %s — %s'):format(call.id, call.code, call.location))
    end
end

RegisterUnit

Registers a player as an on-duty unit in the dispatch system. This is called automatically on duty-toggle events but can be called manually if you use a custom duty system.

exports.zephyr_dispatch:RegisterUnit(src, data)
ParameterTypeDescription
srcnumberServer ID of the player to register.
datatableOptional unit data (see table below).
data FieldTypeDescription
callsignstringInitial callsign.
statusstringInitial availability status.
unitTypestringUnit type for the map icon ('car', 'foot').

Example

-- Register an officer when a custom duty system turns them on
AddEventHandler('myCustomDuty:onDuty', function(src)
    exports.zephyr_dispatch:RegisterUnit(src, { status = 'Available' })
end)

UnregisterUnit

Removes a player from the active unit list. Call this when a player goes off duty.

exports.zephyr_dispatch:UnregisterUnit(src)
ParameterTypeDescription
srcnumberServer ID of the player to unregister.

GetActiveUnits

Returns the full table of all currently registered on-duty units, keyed by server ID.

local units = exports.zephyr_dispatch:GetActiveUnits()

Returns: table — Map of [source] = unit objects.

Unit object fields

FieldTypeDescription
sourcenumberServer ID.
namestringFull name.
callsignstringOfficer callsign.
jobstringJob name (normalized, lowercase).
jobLabelstringJob display label.
gradenumberGrade level.
gradeNamestringGrade name.
statusstringAvailability status ('Available', 'Busy', etc.).
unitTypestringUnit type string.
identifierstringPlayer citizenid.
coordstableLast known { x, y, z } or nil.
locationstringLast known location label.
locationUpdatedAtnumberUnix timestamp of last location update.

Example

local units = exports.zephyr_dispatch:GetActiveUnits()
local count = 0
for _, unit in pairs(units) do
    if unit.job == 'police' then
        count = count + 1
    end
end
print('Online police units: ' .. count)

IsUnitOnDuty

Returns whether a player is currently registered as an on-duty unit in dispatch.

local onDuty = exports.zephyr_dispatch:IsUnitOnDuty(src)
ParameterTypeDescription
srcnumberServer ID to check.

Returns: boolean

Example

RegisterNetEvent('myResource:doSomething', function()
    local src = source
    if not exports.zephyr_dispatch:IsUnitOnDuty(src) then
        TriggerClientEvent('ox_lib:notify', src, { description = 'You must be on duty.', type = 'error' })
        return
    end
    -- ... continue
end)