> ## Documentation Index
> Fetch the complete documentation index at: https://docs.redutzu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Dispatch

> Send dispatch calls from your scripts, run the MDT with a third-party dispatch, or connect a dispatch script that isn't supported yet.

Every alert in the MDT is a **dispatch call**: it shows up as a toast, in the call list, on the map, and as a blip in game. Calls come from three places:- The MDT itself: automatic alerts (shooting, speeding, deaths...), the panic and backup buttons, radar plate hits and CCTV cameras.
- Your own scripts, through the [`CreateDispatchCall`](#send-a-call-from-your-script) export.
- A third-party dispatch script, whose calls are synced into the MDT.## Pick your dispatch`Config.Dispatch.Script` in `config/config.lua` decides who handles alerts.| Value | What happens |
| - | - |
| `'auto'` | Uses the first supported dispatch script that is started, otherwise the built-in one. The default. |
| `'default'` | The MDT's built-in dispatch. |
| `'cd_dispatch'`, ... | A supported third-party dispatch, see the table below. |
| `'custom'` | Your own integration in `server/custom/dispatch/custom.lua`. See [Connect another dispatch](#connect-another-dispatch). |> [!TIP]
>
> Use one dispatch only. Picking a third-party one turns the built-in dispatch off, so officers never get the same alert twice.### Built-in dispatchThe MDT raises every alert itself: automatic detection, panic and backup, radar hits, cameras and the calls your scripts send. The included robbery add-ons (qb-robberies, rainmad, wasabi, 0r-heistpack in `server/custom/dispatch/default/`) also turn their alerts into calls.### Third-party dispatchThe third-party dispatch raises **every** alert, the MDT's own ones too:- Panic, backup, radar plate hits, camera alerts and calls from the `CreateDispatchCall` export are sent to that dispatch, so its popup shows them.
- Every call that dispatch handles is synced into the MDT: the call list, the map and blips. Officers can respond to it in the MDT like any other call.
- The MDT's automatic detection and the robbery add-ons are off, that dispatch has its own.`Config.Dispatch.ExternalNotifications` only decides whether the MDT **also** shows its own toast for those calls:```lua theme={null}
Config.Dispatch = {
    Script = 'cd_dispatch',

    -- true  = the MDT toast and the dispatch's popup
    -- false = only the dispatch's popup, the call still appears in the MDT
    ExternalNotifications = false,
}
```| Dispatch | Its calls in the MDT | Panic | Backup | Radar and camera alerts |
| - | - | - | - | - |
| `cd_dispatch` (Classic, 3D) | Yes, with responders | Its own panic button | Custom alert | Custom alert |
| `ps-dispatch` | Yes | `OfficerInDistress` | `OfficerBackup` | `CustomAlert` |
| `rcore_dispatch` | Yes | Custom alert | Custom alert | Custom alert |
| `linden_outlawalert` | Yes | Custom alert | Custom alert | Custom alert |
| `core_dispatch` | Yes | No | No | No |When a dispatch can't raise panic and backup, the MDT hides those buttons and their keybinds, so an officer never presses a panic button that nobody sees. Alerts that can't be sent, such as a camera destroyed by an NPC with cd\_dispatch, still appear in the MDT.> [!NOTE]
>
> The blip of each alert sent to cd\_dispatch, ps-dispatch and rcore\_dispatch is set in the `BLIPS` table of its file in `client/custom/dispatch/` or `server/custom/dispatch/`.> [!NOTE]
>
> When a call from your dispatch can't be added to the MDT, the server console warns `[dispatch] call from ... not added to the MDT` with the reason. Calls for jobs left out of `Config.Dispatch.Alerts` are skipped without a warning.## Mini dispatch panelThe mini dispatch panel (`F6` by default) works with every dispatch. If your server doesn't use it, remove it:```lua theme={null}
Config.Dispatch = {
    Panel = false, -- the respond, panic and backup keybinds keep working
}
```You can also turn it off in **Admin > Interface > In-game menus**. It closes right away for everyone, and turning it back on brings its key back on each player's next join.## Send a call from your script`CreateDispatchCall` is a **server** export. It works with every dispatch: with the built-in one it creates the call, with a third-party one it sends the alert to that dispatch and syncs it into the MDT. You never have to change your script when you switch dispatch.```lua theme={null}
exports['redutzu-mdt']:CreateDispatchCall({
    type     = 'store_robbery',
    code     = '10-31',
    priority = 'high',
    title    = 'Store Robbery',
}, source)
```Passing the robber's `source` is all it takes: the call is placed where they stand, and the street is filled in for you.### From a client scriptMost robbery scripts call the police from the client. Exports are per side, so send a server event from your client script and create the call there:```lua client.lua theme={null}
TriggerServerEvent('my_robbery:server:alertPolice', storeName)
``````lua server.lua theme={null}
RegisterNetEvent('my_robbery:server:alertPolice', function(storeName)
    local src = source

    exports['redutzu-mdt']:CreateDispatchCall({
        type        = 'store_robbery',
        code        = '10-31',
        priority    = 'high',
        title       = 'Store Robbery',
        description = ('Silent alarm triggered at %s'):format(storeName),
    }, src)
end)
```> [!WARNING]
>
> Players can trigger any server event themselves. Check on the server that the player really is robbing that store before you create the call, for example with your robbery's own state.### A call with no playerPass `coords` and leave out `source`, for alarms, NPC reports or timed events:```lua theme={null}
exports['redutzu-mdt']:CreateDispatchCall({
    type     = 'bank_robbery',
    code     = '10-90',
    priority = 'high',
    title    = 'Pacific Standard alarm',
    coords   = vector3(255.0, 225.0, 101.0),
    jobs     = { 'police', 'sheriff' },
})
```### Payload

\<table><thead><tr><th>payload</th>
            \<th>Type</th>
            \<th>Description</th></tr></thead>
        \<tbody /></table>

`details` takes any of these fields:```lua theme={null}
details = {
    call_content = 'Caller reports two armed men',     -- quote of the 911 call
    caller  = { name = 'John Doe', phone_number = '555-0101' },
    vehicle = { model = 'Sultan', plate = 'ABC123', color = 'Red', class = 'Sports', doors = '4', heading = 'North' },
    suspect = { gender = 'male', skinTone = 'dark', masked = true }, -- gender and masked required
    weapon  = 'Pistol',                                 -- label, or a weapon hash
    info    = {                                         -- up to 8 rows
        { label = 'Crew size', value = '4' },
        { label = 'Vault', value = 'Open' },
    },
}
```### Return

\<table><thead><tr><th>Return</th>
            \<th>Type</th>
            \<th>Description</th></tr></thead>
        \<tbody /></table>

```lua theme={null}
local call, errKey = exports['redutzu-mdt']:CreateDispatchCall(payload, src)
if not call then
    print(('Dispatch call rejected: %s'):format(errKey))
end
```> [!NOTE]
>
> The same player can create one call every 1.5 seconds. Cooldowns per alert type are up to your script.### Style a new alert typeGive your type an entry in `Config.Dispatch.Alerts` to set its blip and behavior:```lua theme={null}
Config.Dispatch.Alerts = {
    -- ...
    ['store_robbery'] = {
        MergeRadius = 40,             -- a new alert this close refreshes the open call
        Lifetime = 15 * 60 * 1000,    -- ms open with no unit attached
        SceneInfo = true,             -- adds nearby people, nearest unit and plate rows
        Jobs = { 'police' },          -- who receives it
        Blip = { Sprite = 52, Colour = 2, Pulse = true },
    },
}
```### React to callsTo follow calls in another script, such as a tablet or an EMS resource, listen to the [dispatch events](https://docs.redutzu.com/redutzu-mdt/api-reference/events.md#dispatch), such as `redutzu-mdt:dispatch-call:created`. To manage calls, use the other [dispatch exports](https://docs.redutzu.com/redutzu-mdt/api-reference/exports/server.md#dispatch): `AttachUnitToDispatchCall`, `ResolveDispatchCall`, `AddDispatchCallNote`...## Connect another dispatchFor a dispatch script that isn't in the table above, set `Script = 'custom'` and fill in `server/custom/dispatch/custom.lua`. An integration does two things:1) **Sync its calls into the MDT**: listen to the event it fires for every new call.
2) **Send the MDT's own alerts to it**: panic, backup, radar hits and cameras. Without this, panic and backup are hidden.The supported integrations in `server/custom/dispatch/` are complete working examples: `rcore_dispatch.lua` for a dispatch with a server API, `ps-dispatch.lua` with `client/custom/dispatch/ps-dispatch.lua` for one with a client API.**1. Select it**In `config/config.lua`:```lua theme={null}
Config.Dispatch.Script = 'custom'
```**2. Sync its calls into the MDT**Find the event your dispatch fires for every new alert, usually the one other scripts trigger to send an alert, and pass each call to `DispatchCalls.mirror`:```lua server/custom/dispatch/custom.lua theme={null}
RegisterServerEvent('your_dispatch:server:sendAlert', function(data)
    if type(data) ~= 'table' or not data.coords then return end

    DispatchCalls.mirror({
        type        = 'your_dispatch_call',
        code        = data.code or '10-00',
        priority    = data.urgent and 'high' or 'medium',
        title       = data.title,
        description = data.message,
        coords      = { x = data.coords.x, y = data.coords.y },
        jobs        = data.jobs,
    }, { from = source })
end)
```The payload is the same as [`CreateDispatchCall`](#payload). Always pass `{ from = source }`: when the MDT sends one of its own alerts to your dispatch (next step), that's how the copy coming back is matched to the existing call instead of being added twice.`RegisterServerEvent` adds a handler next to your dispatch's own, it doesn't replace it.**3. Send the MDT's alerts to it**Register a sender. It receives every alert the MDT raises and calls your dispatch's API. Return `false` when it couldn't send it.> [tab] Server API
>
> For a dispatch with a server export or event:
>
> ```lua server/custom/dispatch/custom.lua theme={null}
> Bridge.Dispatch.RegisterSender('custom', function(alert, source)
>     TriggerEvent('your_dispatch:server:sendAlert', {
>         code    = alert.code,
>         title   = alert.title,
>         message = alert.description,
>         coords  = alert.coords,
>         jobs    = alert.jobs,
>         urgent  = alert.priority == 'high',
>     })
>     return true
> end)
> ```> [tab] Client API
>
> For a dispatch whose alerts are sent from the player's client, like cd\_dispatch and ps-dispatch. The server sends the alert to the client of the player who raised it:
>
> ```lua server/custom/dispatch/custom.lua theme={null}
> Bridge.Dispatch.RegisterSender('custom', function(alert, source)
>     return DispatchCalls.sendFromClient(alert, source)
> end)
> ```
>
> Then create `client/custom/dispatch/custom.lua` and send it there:
>
> ```lua client/custom/dispatch/custom.lua theme={null}
> if Bridge.Dispatch.Provider ~= 'custom' then
>     return
> end
>
> Bridge.Dispatch.RegisterSender('custom', function(alert)
>     if alert.type == 'officer_panic' then
>         exports['your_dispatch']:Panic()
>         return true
>     end
>
>     exports['your_dispatch']:SendAlert({
>         code    = alert.code,
>         title   = alert.title,
>         message = alert.description,
>         coords  = alert.coords,
>         jobs    = alert.jobs,
>     })
>     return true
> end)
> ```
>
> Alerts with no player behind them can't go through a client API, they only appear in the MDT.If your dispatch has its own panic or backup feature, use it for `officer_panic` and `request_backup` like above, its popup and sound fit it best.**4. Sync responders (optional)**If your dispatch fires an event when an officer responds, attach their unit to the MDT call. Keep the id `DispatchCalls.mirror` returned:```lua theme={null}
local mdtCalls = {} -- your dispatch's call id -> MDT call id

-- in step 2:
local call = DispatchCalls.mirror({ ... }, { from = source })
if call then mdtCalls[data.id] = call.id end

AddEventHandler('your_dispatch:server:responding', function(callId, playerId)
    local mdtId = mdtCalls[callId]
    if not mdtId then return end

    for _, callsign in ipairs(Units.responderCallsigns(playerId)) do
        exports['redutzu-mdt']:AttachUnitToDispatchCall(mdtId, callsign)
    end
end)
```**5. Test it**Restart the server and check, on duty:- An alert from your dispatch shows up once in the MDT call list and on the map.
- The MDT's panic and backup buttons show your dispatch's popup, and the call appears once in the MDT.
- With `ExternalNotifications = false`, no MDT toast shows up.The server console warns `Bridge.Dispatch (custom): not implemented` until you remove that line at the bottom of `custom.lua`.### The alert your sender receives

\<table><thead><tr><th>alert</th>
            \<th>Type</th>
            \<th>Description</th></tr></thead>
        \<tbody /></table>



\<table><thead><tr><th>Sender arguments</th>
            \<th>Type</th>
            \<th>Description</th></tr></thead>
        \<tbody /></table>



This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.