Skip to content
This page was translated from German using AI. If anything is unclear, the German version applies.

Dispatch & interfaces

The system forwards emergency calls via modular dispatch adapters. Every service created in hm_Notrufsaeulen can use its own dispatch adapter (e.g. police via Emergency Dispatch, roadside assistance via Roadphone).


The resource has a preconfigured integration for Emergency Dispatch by LoveRP Scripts.

The Emergency Dispatch API expects individual parameters instead of a payload table:

TriggerEvent('emergencydispatch:emergencycall:new', jobName, message, coords, true)

Since the event only accepts one target job at a time, the adapter triggers the event once per job stored for the emergency service. If a service has e.g. the jobs police and sheriff, both factions receive the incident.

In config/config.lua under Config.Dispatch.emergencydispatch.mode:

  • mode = 'client' (default): Triggers the event on the caller’s client. Emergency Dispatch decides on its own between a phone call (if the dispatch centre is staffed) and a text emergency call (if not), and determines the player position automatically:
    TriggerEvent('emergencydispatch:emergencycall:new', jobName, message, false)
  • mode = 'server': Uses server-side triggering with the exact call box coordinate – always creates a pure text incident report without a phone call.

Optionally, an alarm for a fire or ambulance station can also be triggered (emergencydispatch:alarmierung:wache). The dispatch code stored for the service acts as the alarmcode:

Config.Dispatch.emergencydispatch = {
alertStation = false, -- set to true
station = 'Wache 1', -- name of the station
stationEvent = 'emergencydispatch:alarmierung:wache',
...
}

Since the Emergency Dispatch API has no separate field for the caller’s name, the script automatically puts the player name at the beginning of the incident report:

Melder: Frank Wolf | Notrufsäule: A9 Süd km 42 | Ort: Elgin Ave | gewählt: 112 | Meldung: Fahrzeugbrand

Before sending, the adapter queries the staffing level from Emergency Dispatch:

exports['emergencydispatch']:mannedvehicles() -- crews in vehicles
exports['emergencydispatch']:mannedcontrol() -- dispatchers in the control room
  • If nobody is on duty in the respective job, the emergency call is passed to the dispatch system anyway (so the incident is not lost).
  • At the same time the redundancy (Config.Dispatch.fallback) kicks in, and the caller gets the message at the call box: “Report forwarded (on-call service takes over)”.
  • With notruf_duty in the server console you can check which job names Emergency Dispatch currently reports.

Emergency Dispatch has no telephony of its own – for real voice connections, a phone script can be connected via the client hook Config.Phone.start(data):

Config.Phone = {
enabled = true,
resource = 'lb-phone',
start = function(data)
exports['lb-phone']:StartCall(data.number, data.anonymous)
end,
}

The data object passed in contains:

  • data.number: phone number of the selected service.
  • data.service: complete service object.
  • data.serviceId: ID of the service.
  • data.anonymous: boolean, whether the call was made anonymously.
  • data.pillar: call box object with location data.
exports['lb-phone']:StartCall(data.number, data.anonymous)

If you want to connect a different emergency or dispatch system (e.g. Roadphone, Quasar Dispatch, Codesign, etc.), this can be done modularly in a few steps.

  1. Create the adapter file:
    Create a new Lua file in the folder server/adapters/ (e.g. server/adapters/roadphone.lua):

    --[[ Adapter: Roadphone ]]
    NRS.Dispatch.Register('roadphone', function(call)
    local cfg = Config.Dispatch.roadphone
    -- check whether the target resource is running
    if GetResourceState(cfg.resource) ~= 'started' then
    return false, ('Resource "%s" is not running'):format(cfg.resource)
    end
    local message = ('%s an %s: %s'):format(
    call.service.label, call.street or call.pillar.label, call.message)
    exports[cfg.resource]:CreateCall({
    job = call.service.jobs[1],
    code = call.service.dispatchCode,
    text = message,
    coords = call.coords,
    caller = call.callerName,
    })
    return true
    end)
  2. Register it in fxmanifest.lua:
    Add the file to fxmanifest.lua under server_scripts (after server/dispatch.lua and before server/main.lua):

    server_scripts {
    'server/bridge.lua',
    'server/storage.lua',
    'server/permissions.lua',
    'server/dispatch.lua',
    'server/adapters/emergencydispatch.lua',
    'server/adapters/roadphone.lua', -- newly added
    'server/main.lua',
    }
  3. Make it selectable in the tablet:
    Add the adapter to config/config.lua under Config.Dispatch.adapters:

    Config.Dispatch.adapters = {
    { value = 'emergencydispatch', label = 'Emergency Dispatch' },
    { value = 'roadphone', label = 'Roadphone' },
    }
  4. Add your own config block:
    Add the parameters your adapter needs to config/config.lua:

    Config.Dispatch.roadphone = {
    resource = 'roadphone',
    priority = 2,
    }
  5. Assign the service:
    In the tablet, open the Emergency services tab, select the service and switch the Dispatch adapter drop-down to your new entry. The change is active immediately.

Every adapter receives a comprehensive call table when triggered:

FieldTypeDescription
call.sourcenumberServer ID of the caller (0 if triggered without a player).
call.callerNamestringRP name of the player (or the placeholder for anonymous reports).
call.anonymousbooleantrue if the report was marked as anonymous.
call.pillartableCall box data (id, label, road, km, code, coords, etc.).
call.servicetableService data (id, label, number, jobs, dispatchCode, priority, etc.).
call.coordsvector3Exact 3D coordinates of the call box.
call.street / zonestringStreet and area name of the call box.
call.messagestringFree text entered by the caller.
call.timenumberTimestamp (os.time()).

Your adapter must tell the system the result of forwarding:

  • return true: emergency call sent successfully.
  • return false, 'error message': an error occurred – the reason is logged in the server log and the system falls back to the redundancy.
  • return true, nil, { unstaffed = true }: incident created successfully in the system, but nobody is currently on duty. The call box control panel tells the caller that the report has been forwarded and the on-call service is taking over; at the same time the redundancy is executed.

If you want to inform external scripts about incoming emergency calls without writing an adapter, you can listen to these events:

-- triggered after every emergency call that was sent:
AddEventHandler('hm_Notrufsaeulen:callDispatched', function(call, adapterName, success)
print(('Emergency call to %s via adapter %s (success: %s)'):format(call.service.label, adapterName, tostring(success)))
end)
-- called by the 'custom' adapter:
AddEventHandler('hm_Notrufsaeulen:onDispatch', function(call)
-- contains all data: call.coords, call.message, call.service, etc.
end)

-- server-side: open the tablet for a specific player
exports.hm_Notrufsaeulen:openTablet(source)
-- client-side: open the emergency call menu of a specific call box
exports.hm_Notrufsaeulen:openPillarMenu(pillarId)
CommandCan be run byFunction
/notruf_configEditor, adminOpens the config tablet in-game.
notruf_grant <ID|identifier> [level]Admin, server consoleGrants admin or editor rights.
notruf_revoke <ID|identifier>Admin, server consoleRevokes granted permissions.
notruf_permsAdmin, server consoleLists all permission entries.
/notruf_idEvery playerShows your own identifiers for copying.
notruf_mapAdmin, server consolePrints the current map bounds for config.lua.
notruf_dutyAdmin, server consoleChecks the staffing status in Emergency Dispatch and compares jobs.
notruf_reloadAdmin, server consoleRereads all JSON files in data/.
notruf_seedAdmin, server consoleRe-creates the default services from config/services.lua.
/notruf_model [name]Everyone (client)Checks whether the given model is valid and loaded in the client.