> For the complete documentation index, see [llms.txt](https://tk-scripts.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tk-scripts.gitbook.io/docs/tk_dispatch/exports/client.md). Agents can also search and read this documentation through its [MCP server](https://tk-scripts.gitbook.io/docs/~gitbook/mcp).

# Client

Client-side Dispatch exports that other FiveM resources call to send calls, read the player's details and open the dispatch.

## addCall

Sends a call from the player's client, adding the player's details that the `show` fields ask for.

```lua
exports.tk_dispatch:addCall(data)
```

* `data`: `table`

| Field              | Type                                       | Meaning                                                                                                                                                                                                 |
| ------------------ | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `title`            | `string`                                   |                                                                                                                                                                                                         |
| `jobs`             | `string` or `string[]`                     | Job names from [`Config.Dispatch`](https://tk-scripts.gitbook.io/docs/tk_dispatch/config.md#dispatch-groups), or group keys (`'police'` and `'ems'` in the download); each matching group gets the call |
| `coords?`          | `vector3`                                  | Default: the player's position                                                                                                                                                                          |
| `coordsOffset?`    | `number`                                   | Metres the call position is moved at random                                                                                                                                                             |
| `code?`            | `string`                                   | A code shown with the call, for example `'10-58'`                                                                                                                                                       |
| `priority?`        | `string`                                   | For example `'Priority 2'`                                                                                                                                                                              |
| `message?`         | `string`                                   |                                                                                                                                                                                                         |
| `image?`           | `string`                                   | An image URL                                                                                                                                                                                            |
| `takePhoto?`       | `boolean`                                  | True to upload a photo of the player's screen; needs a [Fivemanage token](https://tk-scripts.gitbook.io/docs/tk_dispatch/setup.md#set-up-player-photos)                                                 |
| `showLocation?`    | `boolean`                                  | True to add the street name                                                                                                                                                                             |
| `showDirection?`   | `boolean`                                  | True to add the direction the player faces                                                                                                                                                              |
| `showGender?`      | `boolean`                                  | True to add the character's gender                                                                                                                                                                      |
| `showVehicle?`     | `boolean`                                  | True to add the model, colour and plate of the vehicle the player is in or entering                                                                                                                     |
| `platePercentage?` | `number` or `{min = number, max = number}` | Percent of the plate shown; hidden characters show as `?`; default the whole plate                                                                                                                      |
| `showWeapon?`      | `boolean`                                  | True to add the weapon in the player's hand, if it is in `Config.Weapons`                                                                                                                               |
| `showPerson?`      | `boolean`                                  | True to add the character's name                                                                                                                                                                        |
| `showNumber?`      | `boolean`                                  | True to add the phone number from `Config.Phone`                                                                                                                                                        |
| `removeTime?`      | `number`                                   | Milliseconds until the call leaves the map; default `300000`                                                                                                                                            |
| `showTime?`        | `number`                                   | Milliseconds the notification stays; default `7500`                                                                                                                                                     |
| `color?`           | `string`                                   | Colour of the notification's edge, an [open-color](https://yeun.github.io/open-color/) name; default `'blue'`                                                                                           |
| `flash?`           | `boolean`                                  | True to make the code and priority badges blink                                                                                                                                                         |
| `playSound?`       | `boolean`                                  | True to play the call sound for receiving units                                                                                                                                                         |
| `playSoundAll?`    | `boolean`                                  | True to play the call sound from the unit's character                                                                                                                                                   |
| `soundId?`         | any                                        | Passed to `PlayCallSound` in `client/main_editable.lua`, where you pick the sound                                                                                                                       |
| `blip?`            | `table`                                    | A map blip that fades out over `removeTime`; fields below                                                                                                                                               |

`blip` fields:

| Field         | Type      | Meaning                                                    |
| ------------- | --------- | ---------------------------------------------------------- |
| `sprite`      | `number`  | The blip sprite ID                                         |
| `scale`       | `number`  |                                                            |
| `color`       | `number`  | The blip colour ID                                         |
| `flash?`      | `boolean` | True to make the blip flash                                |
| `display?`    | `number`  | The blip display ID; default `4`                           |
| `shortRange?` | `boolean` | True to show the blip only near the player; default `true` |
| `radius?`     | `number`  | Adds a radius circle in the blip colour                    |

```lua
exports.tk_dispatch:addCall({
    title = 'House robbery',
    code = '10-90',
    jobs = {'police'},
    showLocation = true,
    showGender = true,
    playSound = true,
    blip = {sprite = 357, scale = 1.0, color = 3},
})
```

The photo upload, the phone number and on ESX the weapon label wait for the server, so call it from a thread or an event handler.

## getPlayerData

Gets the player's details for writing your own call message.

```lua
local data = exports.tk_dispatch:getPlayerData()
```

Returns `table`:

| Field       | Type     | Meaning                                                                                          |
| ----------- | -------- | ------------------------------------------------------------------------------------------------ |
| `gender`    | `string` | The locale's male or female text                                                                 |
| `location`  | `string` | The street name                                                                                  |
| `direction` | `string` | The direction the player faces, one of eight compass points in the locale, for example `'North'` |
| `vehicle?`  | `table`  | `model`, `color` and `plate` strings, only while the player is in a vehicle                      |
| `weapon?`   | `string` | The label of the weapon in hand, only if it is in `Config.Weapons`                               |

```lua
local data = exports.tk_dispatch:getPlayerData()
exports.tk_dispatch:addCall({
    title = 'Shooting',
    message = ('A %s is shooting at %s'):format(data.gender, data.location),
    jobs = {'police'},
})
```

## toggleUI

Opens or closes one part of the dispatch.

```lua
exports.tk_dispatch:toggleUI(page, state)
```

* `page`: `'callManager'`, `'sidebar'` or `'map'`
* `state?`: `boolean`
  * True to open, false to close; default opens a closed page and closes an open one

A page opens only for a player whose `Config.Dispatch` group has it in `pages` and who carries the group's `neededItem`.
