> 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/custom-bridges.md). Agents can also search and read this documentation through its [MCP server](https://horizon-scripts.gitbook.io/horizon-scripts-docs/~gitbook/mcp).

# Custom bridges

HorizonMDT includes two editable adapter files: `bridge/client.lua` for client exports and `bridge/server.lua` for server exports. Both load before the main code and are included in the escrow edit list. The main configuration stays short: enter a resource folder name, then change the matching export call in its bridge file.

## HUD: one name and two calls

Set `Config.HudResource = 'my_hud'` in `shared/config.lua`. In `bridge/client.lua`, replace `HorizonHudAdapter.Hide` and `.Show` with the client exports your HUD actually provides. For example:

```lua
function HorizonHudAdapter.Hide(resource)
    return exports[resource]:ToggleHud(false)
end
function HorizonHudAdapter.Show(resource)
    return exports[resource]:ToggleHud(true)
end
```

If the HUD exposes a visibility query, adapt `HorizonHudAdapter.IsVisible` too. This lets HorizonMDT preserve a HUD that the player had already hidden. The default examples use `HideHudAndRadar`, `ShowHudAndRadar`, and `IsHudVisible`. Start the HUD before HorizonMDT.

## Notifications: one name and one call

Set `Config.NotifyResource = 'my_notify'`. In `Bridge.Client.Notify(payload)` in `bridge/client.lua`, replace the supplied `exports[notifyResource]:notify(payload)` with your notification script's client export. For a script that takes separate arguments:

```lua
exports[notifyResource]:Show(payload.message, payload.type, payload.duration)
return true
```

The payload can include `title`, `message` or `description`, `type`, `duration`, and `details`. Keep `return true` after a successful call. If the resource is missing or the call fails, HorizonMDT uses its configured notification fallback.

## Inventory: one name and one server call

Set `Config.InventoryResource = 'my_inventory'`. In `Bridge.Server.GetInventoryCount(source, itemName, player)` in `bridge/server.lua`, replace the sample `exports[resource]:GetItemCount(source, itemName)` with your inventory's **server** export. Return a number, boolean, or table with a numeric `count`, `amount`, or `quantity`. With a configured resource, a failed item check denies access rather than granting it.

```lua
return exports[resource]:GetItemCount(source, itemName)
```

Built-in inventory detection works with an empty resource name. The legacy explicit inventory providers remain in `shared/advanced.lua` for unusual setups.

## Other server adapters

| Feature                    | Select it                                                      | Edit in `bridge/server.lua`                               | Result                                                                                                |
| -------------------------- | -------------------------------------------------------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| Character identity overlay | `Config.Identity.Provider = 'custom'` in `shared/advanced.lua` | `Bridge.Server.GetIdentity(source, player)`               | Return optional identity fields; framework identifier, job, and grade remain authoritative.           |
| Fine invoice               | `Config.FineBilling.Provider = 'custom'`                       | `Bridge.Server.IssueFine(data)`                           | Return a positive invoice ID, nonempty reference, or accepted result only after creating the invoice. |
| EMS invoice                | `Config.MedicalBilling.Provider = 'custom'`                    | `Bridge.Server.IssueMedicalInvoice(data)`                 | Return the external invoice ID or reference. HorizonMDT keeps its own invoice ledger.                 |
| Dispatch                   | `Config.DispatchBridgeMode = 'mirror'` or `'replace'`          | `Bridge.Server.SendDispatchAlert(alert, originalPayload)` | Return `true` only after external dispatch accepts an alert.                                          |

The invoice payloads are validated by the HorizonMDT server. Confirm external payments through the trusted payment API described in [EMS patients and billing](https://horizon-scripts.gitbook.io/horizon-scripts-docs/horizonmdt/ems-patients-and-billing.md). `mirror` sends a second dispatch copy; `replace` falls back to internal dispatch if the external provider declines.

## Where to edit and how to test

1. Keep the exact third-party resource folder name in `shared/config.lua`.
2. Put the real client or server export call in the matching bridge file. The sample names are examples, not universal APIs.
3. Start the provider before HorizonMDT, restart HorizonMDT, and test the relevant feature in game.
4. Set `Config.Debug = true` temporarily if an adapter fails; restore it to `false` afterward.

Client exports cannot be called from the server bridge. Keep authorization and billing amounts on the server. A custom resource does not need a separate HorizonMDT resource or an extra `fxmanifest` export declaration just to consume another resource's export.

Prison custody remains inside HorizonMDT. Trusted resources that need to adjust a sentence use [Prison sentence exports](https://horizon-scripts.gitbook.io/horizon-scripts-docs/horizonmdt/prison-sentence-exports.md).
