> For the complete documentation index, see [llms.txt](https://mango-5m.gitbook.io/mango5m-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mango-5m.gitbook.io/mango5m-docs/resources/mango-mdt/reference/exports-and-events.md).

# Exports and Events

The public API — exports and events other resources can use to integrate with Mango MDT.

## Client exports

```lua
exports.mango_mdt:Open()
exports.mango_mdt:Close()
```

Open/close the tablet from your own resource (a job garage, an interaction menu, …). Both go through the same server-side authentication as `/mdt` — this can never bypass permission checks.

## Server exports

### Dispatch — CreateDispatchCall

Raise a dispatch call from any resource — a robbery script, an ANPR hit, an alarm — landing in the exact same pipeline as `/911`: the Active Calls board, the map, and whichever [alert provider](/mango5m-docs/resources/mango-mdt/configuration/dispatch-integration.md) is active. The export exists on **both sides**:

{% tabs %}
{% tab title="Server" %}

```lua
local ok, idOrReason = exports.mango_mdt:CreateDispatchCall({
    code        = '10-90',                 -- up to 10 chars; default 'ALERT'
    title       = 'Bank Alarm — Fleeca',   -- up to 150 chars
    description = 'Silent alarm triggered at the Legion Square Fleeca.',
    callerName  = 'Fleeca Security',       -- default 'Anonymous Caller'
    callerNumber= '311',                   -- optional
    sound       = 'fleeca-alarm.mp3',      -- optional, a file in web/sounds/
    x = 149.5, y = -1040.7, z = 29.4,      -- required
    street      = 'Legion Square',         -- optional
    suburb      = 'Downtown',              -- optional
    tags        = { 'alarm', 'bank' },     -- optional
})
```

Use this when your trigger runs server-side and you already know the coordinates (an alarm prop, a fixed location). Returns `ok` (boolean) and the call id, or `false, reason` (`'invalid_coords'`).
{% endtab %}

{% tab title="Client" %}

```lua
exports.mango_mdt:CreateDispatchCall({
    code        = '10-31',
    title       = 'Vehicle Theft in Progress',
    description = 'A bystander reports a driver being pulled from their car.',
    sound       = 'carjack-alert.mp3',     -- optional, a file in web/sounds/
    -- x/y/z optional — defaults to this player's CURRENT position
})
```

Use this when your trigger runs client-side and the relevant location is **wherever the player is right now** — a carjacking, a shots-fired detector, a store robbery. Coordinates default to the local player's position, and the **street and zone names are resolved automatically** (those natives only exist client-side), so the alert carries the real location with zero effort. Fire-and-forget: returns `true` once sent.

The payload is validated, clamped, and rate-limited server-side like every other call source — a tampered client can't flood alerts (per-player cooldown, `Config.Dispatch.clientCall.cooldownSeconds`, default 5 s).
{% endtab %}
{% endtabs %}

**Per-call sounds:** the optional `sound` field names a file in `mango_mdt/web/sounds/` played for *that* alert instead of the default `dispatch-alert.mp3` — so a Fleeca alarm can sound different from a carjacking. The master switch and volume stay `Config.Dispatch.alertSound`'s; a missing file is silent, never an error. `/911` always uses the default.

### Person Database

```lua
exports.mango_mdt:GetPersonProfile(identifier)  -- full profile table or nil
exports.mango_mdt:PersonExists(identifier)      -- boolean
exports.mango_mdt:GetPersonFlags(identifier)    -- { 'wanted', 'dangerous', ... }
```

### Jail

```lua
-- Is this identifier currently serving an MDT-recorded sentence?
exports.mango_mdt:IsImprisoned(identifier)      -- boolean

-- Jail a player THROUGH the MDT from your own resource, so the sentence is
-- recorded and the profile's IN PRISON tag tracks it. target = server id or
-- framework identifier. Routed to the configured prison (Config.Bridge.Jail).
local ok, recordIdOrReason = exports.mango_mdt:JailPlayer(target, minutes, reason)
```

See [Jail and Sentencing](/mango5m-docs/resources/mango-mdt/features/jail-and-sentencing.md) for the sentencing flow, supported prisons, and the escape BOLO.

### Inventory item hooks (ox\_inventory)

`mango_mdt.bodycam` and `mango_mdt.warrant` are the item-use exports ox\_inventory calls — they belong in the **item definitions**, not in your code. See [Inventory Items](/mango5m-docs/resources/mango-mdt/configuration/inventory-items.md).

## Server events

The persons plugin broadcasts audit events other resources can listen to:

```lua
AddEventHandler('mango:persons:profileViewed', function(...) end)
AddEventHandler('mango:persons:noteAdded',     function(...) end)
AddEventHandler('mango:persons:noteDeleted',   function(...) end)
AddEventHandler('mango:persons:flagAdded',     function(...) end)
AddEventHandler('mango:persons:flagRemoved',   function(...) end)
```

{% hint style="info" %}
All MDT-internal events are prefixed `mango:` / `mango_mdt:`. Everything not documented on this page is internal and may change between versions — build against the exports above.
{% endhint %}
