# koja-dispatcher

koja-dispatcher is a 911 dispatcher job for FiveM. A player clocks in at a dispatch station, takes emergency calls, questions the callers and commands police, EMS and fire units on a live tactical map, the way you would in an RTS game. It is built on [koja-lib](https://github.com/Koja-Scripts/koja-lib), so it runs on ESX, QBCore and Qbox without changes.

Calls can come from generated AI callers with voiced conversations, from real players (`/911`, phones, other scripts) or both. Units can be an AI fleet that drives the road network, real on-duty players, or both. Everything is set up in game with `/dispatchadmin` and saved in the database, so most servers never need to touch the config file.

## Features

::::cards{cols="2"}
:::card{title="CAD and voiced calls" href="/new/dispatcher/features"}
A full CAD with 911 lines, incidents, units and radio traffic. More than 150 call scenarios with caller conversations, hidden needs, pre-arrival instructions, prank calls and 20 recorded caller voices.
:::
:::card{title="Live 2D and 3D map" href="/new/dispatcher/features"}
Satellite map of San Andreas with every unit, incident and call. A 3D tactical view with terrain, buildings and planned routes.
:::
:::card{title="RTS controls" href="/new/dispatcher/features"}
Box select, shift-click, right-click to send units or stage them, Ctrl+1-9 control groups, follow camera, WASD pan, Tab to cycle incidents.
:::
:::card{title="AI fleet with road routing" href="/new/dispatcher/features"}
Patrol, K9, SWAT, helicopter, ambulances, air ambulance, engines and ladders drive the real road network from their stations, work the scene, transport patients and return to base.
:::
:::card{title="Real players in the loop" href="/new/dispatcher/features"}
`/911` text calls with the caller's live position, field units with toasts, GPS, staging points, scenes, 10-codes, backup and panic.
:::
:::card{title="Stations and shift intro" href="/new/dispatcher/admin-menu"}
Dispatch stations with an in-world screen, placed in game with a 3D gizmo. A cinematic camera fly-in and boot screen when a shift starts.
:::
:::card{title="Admin menu and modes" href="/new/dispatcher/admin-menu"}
Modes, stations, jobs, limits, pay, features, integrations, modules, scenario editor and fleet editor. Saved in the database and applied live.
:::
:::card{title="Pursuits and patrol zones" href="/new/dispatcher/features"}
Live pursuits with a moving suspect, spike strips and roadblocks. Patrol zones that idle AI units patrol.
:::
:::card{title="Incidents that change" href="/new/dispatcher/features"}
Call escalation, multi-stage incidents, weather and time of day weighting, unit fatigue and damage, mass casualty triage and hospital bed capacity.
:::
:::card{title="Voice calls and phones" href="/new/dispatcher/integrations"}
Private pma-voice or mumble-voip call between the caller and the dispatcher. 911 from lb-phone, npwd and other phones.
:::
:::card{title="koja-mdt integration" href="/new/dispatcher/integrations"}
Two-way sync of calls, incidents, units and status, field 10-codes, BOLOs and an MDT workspace inside the CAD.
:::
:::card{title="Compatibility and logs" href="/new/dispatcher/integrations"}
Alerts from ps-dispatch, cd_dispatch, core_dispatch, rcore_dispatch, qs-dispatch and linden_outlawalert. Discord webhook logs.
:::
:::card{title="Ranks, stats and training" href="/new/dispatcher/features"}
Dispatcher ranks with XP and unlocks, statistics with a heatmap and leaderboard, a guided training mode with practice calls.
:::
:::card{title="Developer API" href="/new/dispatcher/api/overview"}
Server and client exports, before and after hooks and events for calls, incidents, units, modes and settings.
:::
::::

### Feature list

| Feature | What it does |
|---|---|
| CAD and calls | 911 lines, call console with questions, instructions, classification, priority and planned response. Calls are locked to the dispatcher who answers. |
| Voiced callers | 20 caller voices (10 female, 10 male), pre-rendered audio. Optional live AI callers with OpenAI and ElevenLabs. |
| Live 2D and 3D map | Satellite tiles, unit and incident markers, routes with ETA, civilian and NPC layers, 3D view with terrain and buildings. |
| RTS controls | Selection, orders, staging, control groups, follow camera, keyboard pan and zoom. |
| AI fleet | 19 units on 11 stations by default, A* routing on the game's road network, helicopters fly straight. |
| Real players | `/911` text calls, field units on the map, assignments with blip and GPS, `/code4`, `/unitstatus`. |
| Stations | In-world screen over the desk, sit or stand pose, blip, placed with a 3D gizmo from the admin menu. |
| Cinematic shift intro | Camera flies from the building to the monitor while the CAD boots. Skippable. |
| Admin menu and modes | Call source, unit source and what happens when nobody is on shift. Every setting saved and applied live. |
| Pursuits | Moving suspect vehicle, units in sight, spike strips, roadblocks, catch or lose. |
| Patrol zones | Draw polygon or circle zones on the map, idle AI units patrol inside. |
| Escalation and multi-stage incidents | Callers report new facts during the call, incidents continue with a new stage when one is done. |
| Weather and time | Generated calls depend on the in-game hour and weather. |
| Fatigue and damage | AI units tire out and can be damaged on violent calls, then rest or repair at their station. |
| MCI | Mass casualty incidents with red, yellow and green patients and a triage board. |
| Hospitals | Bed capacity per hospital, diversion, overflow waits. |
| Voice calls | Dispatcher and player caller on a private voice channel, mute, hold and transfer to a field unit. |
| Phones | 911 calls and texts from lb-phone and npwd, an adapter for qs-smartphone-pro, a generic event for other phones. |
| Dispatch script compatibility | Events and export shims of other dispatch scripts become calls or incidents. |
| Discord logs | Shifts, incidents, missed calls, admin changes, pursuits and MCI. Webhooks from server convars. |
| Ranks | Five ranks with XP, simultaneous lines, pay bonus and call type unlocks. |
| Stats and heatmap | Incident history, KPIs, charts, busiest streets, dispatcher leaderboard and a heatmap layer. |
| Training mode | Guided walkthrough of the CAD with practice calls only the trainee sees. |
| Scenario and fleet editors | Create and edit call scenarios and the AI fleet in game. |
| koja-mdt integration | Incidents and calls both ways, unit status and assignments, callsigns, 10-codes, BOLO, MDT workspace (key `B`). |
| Developer API | Exports, hooks and events. See the [API overview](/new/dispatcher/api/overview). |

## Requirements

| Requirement | Notes |
|---|---|
| FXServer with Lua 5.4 | The resource uses `lua54 'yes'`. |
| [koja-lib](https://github.com/Koja-Scripts/koja-lib) | Required. Framework bridge, notifications, target and version check. |
| oxmysql | Required. Tables are created on start. |
| ESX, QBCore or Qbox | One of them, through koja-lib. Creating a job from the admin menu works on ESX and QBCore. |
| A target resource | Optional. `ox_target`, `koja-interactions` or `qb-target`. Without one the station shows an `[E]` prompt. |
| koja-mdt | Optional. See [Integrations](/new/dispatcher/integrations). |
| pma-voice or mumble-voip | Optional. Needed for voice 911 calls; without it calls stay text. |
| A phone resource | Optional. lb-phone, npwd, qs-smartphone-pro, or any phone through the generic event. |
| OpenAI and ElevenLabs keys | Optional. Only for live AI callers. |

## Where to go next

- [Installation](/new/dispatcher/installation)
- [Configuration](/new/dispatcher/configuration)
- [Admin menu](/new/dispatcher/admin-menu)
- [Features](/new/dispatcher/features)
- [Commands and keybinds](/new/dispatcher/commands-and-keybinds)
- [Integrations](/new/dispatcher/integrations)
- [Database](/new/dispatcher/database)
- [Translations](/new/dispatcher/translations)
- [Troubleshooting](/new/dispatcher/troubleshooting)

Developer reference: [API overview](/new/dispatcher/api/overview), [Server exports](/new/dispatcher/api/server-exports), [Client exports](/new/dispatcher/api/client-exports), [Hooks](/new/dispatcher/api/hooks), [Events](/new/dispatcher/api/events), [Examples](/new/dispatcher/api/examples).
