> 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/setup.md).

# Setup

Install Dispatch on an ESX, QBCore, Qbox or standalone FiveM server and update it without losing your config.

## Requirements

Required:

* ESX (`es_extended`), QBCore (`qb-core`) or Qbox. A standalone server needs `Badger_Discord_API` instead, which gives jobs from Discord roles.
* oxmysql or mysql-async. `tk_dispatch` creates no tables, so there is no SQL file to import.

Optional:

| Resource                                         | Needed for                           | Setting                                       |
| ------------------------------------------------ | ------------------------------------ | --------------------------------------------- |
| `ox_inventory`                                   | Items through ox\_inventory          | `Config.Inventory = 'ox'`                     |
| `screenshot-basic` and a Fivemanage token        | Player photos in alerts              | [Set up player photos](#set-up-player-photos) |
| lb-phone, qs-base, qs-smartphone-pro or gksphone | Caller phone numbers from that phone | `Config.Phone`                                |

## Install

1. Download `tk_dispatch` from the [Cfx.re Portal](https://portal.cfx.re/assets/granted-assets).
2. Put the `tk_dispatch` folder in your `resources` folder. Keep the name `tk_dispatch`; other scripts call `exports.tk_dispatch`.
3. Remove `ps-dispatch`, `qs-dispatch` and `cd_dispatch` from your server. `tk_dispatch` answers their exports and events itself.
4. In `server.cfg`, start `tk_dispatch` after its dependencies. Use `qb-core` or `qbx_core` in place of `es_extended`, or `Badger_Discord_API` on a standalone server, and leave out the optional resources you do not run:

   ```
   ensure oxmysql
   ensure es_extended
   ensure screenshot-basic
   ensure tk_dispatch
   ```
5. In `config.lua`, set `Config.Framework` to `'esx'`, `'qb'` (also for Qbox) or `'standalone'`.
6. Put your job names in `Config.Dispatch`: each group's `jobs` lists the jobs that see its calls and units. On a standalone server, use Discord role IDs as the keys, in `permissions` too:

   ```lua
   jobs = {
       ['820394321600708608'] = true,
   },
   ```

   Every option is on [Dispatch configuration](/docs/tk_dispatch/config.md).

## Set up player photos

Alerts that take a photo of the player's screen upload it to Fivemanage. Without a token, those alerts are not sent at all.

1. In [Fivemanage](https://docs.fivemanage.com/quickstart), create a team. On the team's **Tokens** page, create a token with the **Images** scope.
2. In `tk_dispatch/config_sv.lua`, paste the token between the quotes:

   ```lua
   ConfigSV.FivemanageToken = 'YOUR_TOKEN'
   ```
3. In `server.cfg`, start `screenshot-basic` before `tk_dispatch`.

## Update without losing your config

Your changes live in `config.lua`, `config_sv.lua`, `locales/*.lua`, `client/main_editable.lua`, `server/main_editable.lua`, `client/frameworks/*.lua` and `server/frameworks/*.lua`.

1. Copy the whole `tk_dispatch` folder somewhere outside `resources`.
2. Download the new version from the Cfx.re Portal and replace the `tk_dispatch` folder.
3. Copy your values from the backup into the new `config.lua` and `config_sv.lua` one option at a time.
4. Copy each function you changed in the editable and framework files into the same file of the new version.
