> For the complete documentation index, see [llms.txt](https://docs.gkshop.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gkshop.org/tablet/export-and-events/server-exports.md).

# Server exports

### Dispatch

Active dispatches appear in Police/EMS MDT and the dispatch side panel.

#### Dispatch Table Schema

Full schema used by `AddDispatch`:

| Field         | Type                  | Required | Description                                         |
| ------------- | --------------------- | -------- | --------------------------------------------------- |
| `title`       | string                | Yes      | Dispatch title                                      |
| `description` | string                | Yes      | Description / message body                          |
| `code`        | string                | No       | Radio code (e.g. `10-90`)                           |
| `priority`    | string                | No       | `'high'`, `'medium'`, or `'low'` (default: `'low'`) |
| `location`    | string or table       | No       | Street label, or `{ label, coords }`                |
| `coords`      | vector2/vector3/table | Yes\*    | `{ x, y, z }` — required for map blip               |
| `job`         | string                | No       | `'police'` or `'ambulance'` (default: `'police'`)   |
| `time`        | number                | No       | Unix timestamp (default: `os.time()`)               |
| `image`       | string                | No       | Optional image URL                                  |
| `sound`       | string \| false       | No       | Sound name or `false` to disable                    |
| `fields`      | table\[]              | No       | Extra rows: `{ icon, label, value? }`               |
| `blip`        | table                 | No       | `{ sprite?, color?, size?, shortRange?, label? }`   |
| `isRadius`    | boolean               | No       | Show radius circle on map                           |
| `radius`      | number                | No       | Radius in meters when `isRadius` is true            |

***

#### AddDispatch

Create a dispatch using the full schema.

```lua
exports['gks-tablet']:AddDispatch(dispatch)
```

**Parameters**

| Parameter  | Type  | Required | Description                            |
| ---------- | ----- | -------- | -------------------------------------- |
| `dispatch` | table | Yes      | Full dispatch table (see schema above) |

**Returns**

| Type   | Description                        |
| ------ | ---------------------------------- |
| number | Dispatch ID (`0` on invalid input) |

**Example**

```lua
local id = exports['gks-tablet']:AddDispatch({
    title = "Shots Fired",
    description = "Multiple reports near Legion Square",
    code = "10-71",
    priority = "high",
    location = { label = "Legion Square", coords = vector3(195.0, -933.0, 30.0) },
    job = "police",
    blip = { sprite = 161, color = 1 },
})
```

#### UpdateDispatch

Update an active dispatch (partial updates supported).

```lua
exports['gks-tablet']:UpdateDispatch(id, dispatch)
```

**Parameters**

| Parameter  | Type   | Required | Description                                                               |
| ---------- | ------ | -------- | ------------------------------------------------------------------------- |
| `id`       | number | Yes      | Dispatch ID                                                               |
| `dispatch` | table  | Yes      | Fields to update (title, description, priority, coords, responders, etc.) |

**Returns**

| Type    | Description                 |
| ------- | --------------------------- |
| boolean | `true` if found and updated |

***

#### RemoveDispatch

Remove a dispatch by ID and notify MDT clients.

```lua
exports['gks-tablet']:RemoveDispatch(dispatchId)
```

**Returns**

| Type    | Description       |
| ------- | ----------------- |
| boolean | `true` if removed |

***

#### GetDispatch

Get a single active dispatch.

```lua
exports['gks-tablet']:GetDispatch(dispatchId)
```

**Returns**

| Type         | Description             |
| ------------ | ----------------------- |
| table \| nil | Dispatch table or `nil` |

***

#### GetDispatches

List all active dispatches, optionally filtered by job.

```lua
exports['gks-tablet']:GetDispatches(job)
```

**Parameters**

| Parameter | Type   | Required | Description                                |
| --------- | ------ | -------- | ------------------------------------------ |
| `job`     | string | No       | `'police'` or `'ambulance'` — omit for all |

**Returns**

| Type     | Description              |
| -------- | ------------------------ |
| table\[] | Array of dispatch tables |

***

#### UpdateResponderCallsign

Rename a responder callsign across all active dispatches (used when officers rename units or personal callsigns).

```lua
exports['gks-tablet']:UpdateResponderCallsign(oldCallsign, newCallsign)
```

**Returns**

Nothing.

### MDT Records

Create and manage Police MDT records from external resources. All write operations log to the MDT audit trail when `source` is a valid player.

#### RegisterWeapon

Register a weapon in the MDT weapons database.

```lua
exports['gks-tablet']:RegisterWeapon(serialNumber, data)
```

**Parameters**

| Parameter      | Type   | Required | Description                                              |
| -------------- | ------ | -------- | -------------------------------------------------------- |
| `serialNumber` | string | Yes      | Weapon serial number                                     |
| `data`         | table  | No       | `{ weaponName/model, owner, owner_id/ownerId, stolen? }` |

**Returns**

| Type            | Description                 |
| --------------- | --------------------------- |
| number \| false | Weapon record ID or `false` |

#### GetPoliceCallsign

Get an officer's personal callsign from MDT personnel records.

```lua
exports['gks-tablet']:GetPoliceCallsign(identifier)
```

**Returns**

| Type          | Description |
| ------------- | ----------- |
| string \| nil | Callsign    |

***

#### SetPoliceCallsign

Set or update an officer's callsign. Refreshes live map tracking and roster.

```lua
exports['gks-tablet']:SetPoliceCallsign(identifier, callsign, ignoreCallsignCheck)
```

**Parameters**

| Parameter             | Type    | Required | Description                      |
| --------------------- | ------- | -------- | -------------------------------- |
| `identifier`          | string  | Yes      | Framework identifier / citizenid |
| `callsign`            | string  | Yes      | New callsign                     |
| `ignoreCallsignCheck` | boolean | No       | Skip validation (optional)       |

**Returns**

| Type    | Description       |
| ------- | ----------------- |
| boolean | `true` on success |

### Units and Callsigns

In-memory unit management for Police and EMS MDT. Units affect dispatch responder names on the live map.

#### GetPlayerUnit

Get the unit name assigned to an online officer.

```lua
exports['gks-tablet']:GetPlayerUnit(source)
```

**Returns**

| Type          | Description |
| ------------- | ----------- |
| string \| nil | Unit name   |

***

#### GetUnits

List all units for a job.

```lua
exports['gks-tablet']:GetUnits(job)
```

**Parameters**

| Parameter | Type   | Default    | Description                 |
| --------- | ------ | ---------- | --------------------------- |
| `job`     | string | `'police'` | `'police'` or `'ambulance'` |

**Returns**

| Type     | Description        |
| -------- | ------------------ |
| table\[] | `{ name, status }` |

***

#### SetPlayerUnit

Assign an officer to a unit.

```lua
exports['gks-tablet']:SetPlayerUnit(source, job, unitName)
```

**Returns**

| Type    | Description       |
| ------- | ----------------- |
| boolean | `true` on success |

***

#### ResetPlayerUnit

Remove an officer from their current unit.

```lua
exports['gks-tablet']:ResetPlayerUnit(source)
```

***

#### CreateUnit / RemoveUnit / SetUnitStatus / RenameUnit

```lua
exports['gks-tablet']:CreateUnit(job, name, status)
exports['gks-tablet']:RemoveUnit(job, name)
exports['gks-tablet']:SetUnitStatus(job, name, status)
exports['gks-tablet']:RenameUnit(job, oldName, newName)
```

`CreateUnit` default status is `'station'`. `RenameUnit` updates dispatch responders for all officers in the unit.

***

#### GetPlayerUnitStatus

Get unit status by identifier (works offline).

```lua
exports['gks-tablet']:GetPlayerUnitStatus(identifier)
```

**Returns**

| Type   | Description             |
| ------ | ----------------------- |
| string | Status or `'available'` |

***

#### GetOfficerCallsign

Get personal callsign for an **online** player from MDT personnel DB.

```lua
exports['gks-tablet']:GetOfficerCallsign(source)
```

**Returns**

| Type          | Description |
| ------------- | ----------- |
| string \| nil | Callsign    |

***

### Notifications

Send notifications to the tablet **lockscreen** (not Dynamic Island — that is GKSPHONE).

#### Notification Data Schema

| Field     | Type   | Default          | Description                   |
| --------- | ------ | ---------------- | ----------------------------- |
| `title`   | string | `"Notification"` | Title (required with message) |
| `message` | string | `""`             | Body text                     |
| `app`     | string | `"System"`       | Source app name               |

***

#### SendNotification

Send to one player.

```lua
exports['gks-tablet']:SendNotification(targetSource, data)
```

**Returns**

| Type    | Description         |
| ------- | ------------------- |
| boolean | `true` if delivered |

***

#### BroadcastNotification

Send to all online players.

```lua
exports['gks-tablet']:BroadcastNotification(data)
```

**Returns**

| Type   | Description               |
| ------ | ------------------------- |
| number | Count of players notified |

***

#### SendJobNotification

Send to all players with a specific job name.

```lua
exports['gks-tablet']:SendJobNotification(jobName, data)
```

**Example**

```lua
exports['gks-tablet']:SendJobNotification("police", {
    title = "MDT",
    message = "New priority dispatch available.",
})
```

***

#### SendNotificationToPlayers

Send to a list of server IDs.

```lua
exports['gks-tablet']:SendNotificationToPlayers({ 1, 2, 3 }, data)
```

***

### Tablet Management

Database operations for tablet records (`gks_tablet` table).

#### GetTabletByUniqID

```lua
exports['gks-tablet']:GetTabletByUniqID(uniqId)
```

Returns full tablet row with parsed `settings` JSON, or `nil`.

***

#### GetTabletByPlayerIdentifier

```lua
exports['gks-tablet']:GetTabletByPlayerIdentifier(identifier)
```

Lookup by framework identifier (citizenid / license).

***
