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).
Emergency Dispatch (LoveRP Scripts)
Section titled “Emergency Dispatch (LoveRP Scripts)”The resource has a preconfigured integration for Emergency Dispatch by LoveRP Scripts.
How it works
Section titled “How it works”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.
Client vs. server mode
Section titled “Client vs. server mode”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.
Station alerting
Section titled “Station alerting”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', ...}Format of the emergency report
Section titled “Format of the emergency report”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: FahrzeugbrandOn-duty check
Section titled “On-duty check”Before sending, the adapter queries the staffing level from Emergency Dispatch:
exports['emergencydispatch']:mannedvehicles() -- crews in vehiclesexports['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_dutyin the server console you can check which job names Emergency Dispatch currently reports.
Phone integration (optional)
Section titled “Phone integration (optional)”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)TriggerEvent('qb-phone:client:CallContact', { number = data.number })exports['gksphone']:CallContact(data.number)exports['roadphone']:callNumber(data.number)Connecting your own dispatch adapters
Section titled “Connecting your own dispatch adapters”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.
Step-by-step guide
Section titled “Step-by-step guide”-
Create the adapter file:
Create a new Lua file in the folderserver/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 runningif GetResourceState(cfg.resource) ~= 'started' thenreturn false, ('Resource "%s" is not running'):format(cfg.resource)endlocal 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 trueend) -
Register it in fxmanifest.lua:
Add the file tofxmanifest.luaunderserver_scripts(afterserver/dispatch.luaand beforeserver/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',} -
Make it selectable in the tablet:
Add the adapter toconfig/config.luaunderConfig.Dispatch.adapters:Config.Dispatch.adapters = {{ value = 'emergencydispatch', label = 'Emergency Dispatch' },{ value = 'roadphone', label = 'Roadphone' },} -
Add your own config block:
Add the parameters your adapter needs toconfig/config.lua:Config.Dispatch.roadphone = {resource = 'roadphone',priority = 2,} -
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.
What the call object contains
Section titled “What the call object contains”Every adapter receives a comprehensive call table when triggered:
| Field | Type | Description |
|---|---|---|
call.source | number | Server ID of the caller (0 if triggered without a player). |
call.callerName | string | RP name of the player (or the placeholder for anonymous reports). |
call.anonymous | boolean | true if the report was marked as anonymous. |
call.pillar | table | Call box data (id, label, road, km, code, coords, etc.). |
call.service | table | Service data (id, label, number, jobs, dispatchCode, priority, etc.). |
call.coords | vector3 | Exact 3D coordinates of the call box. |
call.street / zone | string | Street and area name of the call box. |
call.message | string | Free text entered by the caller. |
call.time | number | Timestamp (os.time()). |
Adapter return values
Section titled “Adapter return values”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.
Listening to emergency calls via events
Section titled “Listening to emergency calls via events”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)Exports & command overview
Section titled “Exports & command overview”Exports
Section titled “Exports”-- server-side: open the tablet for a specific playerexports.hm_Notrufsaeulen:openTablet(source)
-- client-side: open the emergency call menu of a specific call boxexports.hm_Notrufsaeulen:openPillarMenu(pillarId)Complete command reference
Section titled “Complete command reference”| Command | Can be run by | Function |
|---|---|---|
/notruf_config | Editor, admin | Opens the config tablet in-game. |
notruf_grant <ID|identifier> [level] | Admin, server console | Grants admin or editor rights. |
notruf_revoke <ID|identifier> | Admin, server console | Revokes granted permissions. |
notruf_perms | Admin, server console | Lists all permission entries. |
/notruf_id | Every player | Shows your own identifiers for copying. |
notruf_map | Admin, server console | Prints the current map bounds for config.lua. |
notruf_duty | Admin, server console | Checks the staffing status in Emergency Dispatch and compares jobs. |
notruf_reload | Admin, server console | Rereads all JSON files in data/. |
notruf_seed | Admin, server console | Re-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. |