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

# Integrations and troubleshooting

HorizonMDT has built-in ESX Legacy, QB-Core, and Qbox adapters. Framework and inventory selection are independent. Optional providers are not required to start the core resource.

## Framework and inventory providers

Choose `Config.Framework` in `shared/config.lua`: `auto`, `esx`, `qbcore`, or `qbox`. Start the selected framework before HorizonMDT. `auto` checks Qbox, QB-Core, then ESX.

Built-in inventory detection works when `Config.InventoryResource = ''`. For another inventory, put its folder name in `Config.InventoryResource` and adapt the **server** item-count call in `bridge/server.lua`. The export must return a number, boolean, or table containing a count. `Config.TabletUse.Inventory.Type` and legacy custom export settings remain in `shared/advanced.lua` for explicit setups. An item definition and usable-item registration are separate from checking possession.

See [Custom bridges](https://horizon-scripts.gitbook.io/horizon-scripts-docs/horizonmdt/custom-bridges.md) for HUD, notification, inventory, identity, billing, and dispatch examples.

## Optional integrations

| Feature              | Setup                                                                                                                                          |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| HUD visibility       | `Config.HudResource` plus the HUD's client exports in `bridge/client.lua`.                                                                     |
| Notifications        | `Config.NotifyResource` plus one client export in `bridge/client.lua`; advanced provider fallback remains available.                           |
| EMS patient lookup   | `Config.MedicalIntegration` in `shared/advanced.lua`; default server export is `GetInjuredPlayersForMDT`.                                      |
| Radio                | `Config.Radio.VoiceResource` defaults to `pma-voice`. Channels and PTT details are in `shared/advanced.lua` and tablet Administration.         |
| Audio                | Native by default; advanced `Config.Audio` can select xSound or a custom provider.                                                             |
| CCTV                 | Built in; camera definitions are in `data/cctv_cameras.json`.                                                                                  |
| Mugshots             | `Config.Mugshot` chooses capture resources. Multiple photo points are configured in tablet Administration; persistent URLs require Fivemanage. |
| Bodycam uniform gate | `Config.Bodycam.WardrobeResource` names a client wardrobe resource whose `IsWearingDept(department)` export confirms the uniform.              |
| Fine invoices        | `Config.FineBilling.Provider` chooses the internal ledger or a server billing adapter.                                                         |
| Prison item removal  | `Config.Prison.Inventory` in `shared/advanced.lua`; only the configured `RemoveItems` list is removed.                                         |
| Vehicle CAD          | Optional module within HorizonMDT; enable `Config.DashInstall` in `shared/config.lua`.                                                         |

## Custom identity provider

Set `Config.Identity.Provider = 'custom'` in `shared/advanced.lua` and configure the resource plus export names, or adapt the server identity overlay in `bridge/server.lua`. The identity resource must expose server exports with these contracts:

* GetCharacterId(source) -> string | nil
* GetIdentity(characterId) -> { firstName, lastName, dateOfBirth, sex, phone } | nil
* SearchCharacters(query, limit) -> array
* GetFrameworkIdentifier(characterId) -> string | nil when offline job changes need the framework-native identifier.

The character key must remain stable across sessions. Do not change the identity provider for a populated database without mapping existing MDT character IDs first.

## Fine billing adapters

The included ESX Legacy billing adapter uses esx\_billing. For another billing resource, configure an export or server event, or bridge it through a server resource.

Export/event argument mappings can use data, citizenIdentifier, citizenId, citizenName, targetSource (online players only), amount, reason, notes, articles, officerJob, officerIdentifier, officerName, officerSource, and societyAccount. Literal values can be supplied with { value = '...' }.

For `Config.FineBilling.Provider = 'custom'`, implement `Bridge.Server.IssueFine(data)` in `bridge/server.lua`. The payload contains citizen and officer details, amount, reason, articles, and notes. Return a positive invoice ID, a non-empty string ID, or { success = true, id = ... }. A fire-and-forget server event cannot confirm that an invoice was persisted; use AssumeSuccess only when the configured event contract guarantees it.

## Fivemanage photo storage

Create a storage API key and add it to the server console configuration:

```cfg
set horizon_mdt_fivemanage_api_key "YOUR_API_KEY"
set horizon_mdt_fivemanage_endpoint "https://api.fivemanage.com/api/v3/file/base64"
```

The endpoint line is optional when using the default. Use set, not setr, so the key is not replicated to clients. Never put this secret in shared/config.lua or a distributed package.

Set `Config.Mugshot.Enabled` and photo mode in `shared/config.lua`. Capture resource names and camera calibration are in `shared/advanced.lua`. Start the capture resources before HorizonMDT. Without the provider/key, the tablet can still open but new photos cannot be stored as persistent URLs.

## Multiple mugshot photo points

In the tablet, open **Settings → Administration → Points → Photo points**. Add a faction/officer or citizen photo point for the current department and save its coordinates or place it in the world. Repeat for each station. Points are stored in `data/tablet_admin.json`; the resource must be able to write that file. The nearest point is selected for the relevant person. Police, Sheriff, and FIB can add both kinds; EMS currently permits officer photo points only.

`Config.Mugshot.MugshotSuspectPoint` and `OfficerPhotoPoint` in `shared/config.lua` are optional Lua fallback points. Officer photo points matter when `OfficerPhotoMode = 'fixed'`; `anywhere` captures at the officer's current location. With `SubjectOnly = true`, the citizen is framed at their point without the older staged walk sequence. See [Configuration](https://horizon-scripts.gitbook.io/horizon-scripts-docs/horizonmdt/configuration.md) for examples.

## Public API authorization

The API v1 server exports are deny-by-default. Add only trusted server resources to Config.Integrations.PublicApi.AllowedResources, grant the minimum capability needed, and restart HorizonMDT. Resource names must match exactly. Cooldowns are configured by capability. The exports page documents each capability and return value.

Legacy exports exist for compatibility; they do not all use the API v1 allowlist. Call them only from trusted server resources after validating the caller and action. Never forward privileged operations from an unvalidated client event.

## Troubleshooting

* **Tablet item says it is missing:** verify the item name in both the inventory and Config.TabletUse.ItemName; confirm the inventory resource is started, the selected provider is correct, and the item exists in that provider. For an open-access denial, temporarily set `Config.Diagnostics = true` in `shared/advanced.lua` to log the request origin, job, grade, and denial reason; turn it back off afterward.
* **Open command is denied:** check the player's job/grade in Config.TabletUse.AllowedJobs, the command under DepartmentCommands, AccessMode, the department duty policy, and whether RequireItem is enabled.
* **SQL schema does not initialize:** start oxmysql before HorizonMDT, check its connection and database user permissions, and import sql/police\_tablet.sql manually if startup DDL is blocked.
* **Photo is not saved:** confirm capture resource names, photo points, and server convars. Keep the API key server-only.
* **Radio does not transmit:** confirm Config.Radio.Enabled, the configured voice resource name, allowed jobs/grades, and channel access.
* **Extra diagnostic output:** Config.Debug, Config.Diagnostics, Config.TabletDiagnostics, and Config.PerformanceDiagnostics can produce diagnostic output; disable them after troubleshooting.
