# Client

Client exports are intended for player-side integrations: item scripts, keybinds, or other client-only flows that need to interact with the local MDT.

They are **not** gated by the `exportAllowlist` (that setting only applies to server exports). Open requests are routed to the server internally, where `setupOfficer` enforces job, duty, and roster-status checks, so a client calling `openTerminal()` cannot bypass the same authorization the `/mdt` command runs.

For server-side exports see [Server](./server.mdx).

## Terminal [#terminal]

<div className="flex flex-col gap-2 p-3 rounded-xl border bg-fd-card text-fd-card-foreground not-prose">
    ### openTerminal() [#openterminal]
    <p className="text-fd-muted-foreground text-sm">Open the MDT for the local player. Fires a server event that runs the full authorization flow (same as <code>/mdt</code>). Useful for item scripts where the player uses an item to open their tablet.</p>
    ```lua
    exports.vx_mdt:openTerminal()
    ```
</div>
<br />
<div className="flex flex-col gap-2 p-3 rounded-xl border bg-fd-card text-fd-card-foreground not-prose">
    ### closeTerminal() [#closeterminal]
    <p className="text-fd-muted-foreground text-sm">Close the MDT for the local player. Pure client-side, no server round-trip. Safe to call when the MDT is already closed.</p>
    ```lua
    exports.vx_mdt:closeTerminal()
    ```
</div>
<br />
<div className="flex flex-col gap-2 p-3 rounded-xl border bg-fd-card text-fd-card-foreground not-prose">
    ### isTerminalOpen() [#isterminalopen]
    <p className="text-fd-muted-foreground text-sm">Check whether the local player has the MDT open. Reads the local <code>terminal_subscribed</code> state bag.</p>
    ```lua
    ---@return boolean
    local open = exports.vx_mdt:isTerminalOpen()
    ```
</div>

## Dispatch [#dispatch]

<div className="flex flex-col gap-2 p-3 rounded-xl border bg-fd-card text-fd-card-foreground not-prose">
    ### triggerPanic() [#triggerpanic]
    <p className="text-fd-muted-foreground text-sm">Send a panic signal as the local player. Mirrors the F9 keybind / dispatch overlay button: captures current coords and street name, then creates a priority-0 panic call broadcast to all departments.</p>
    <p className="text-fd-muted-foreground text-sm">Useful for custom keybind scripts, smartwatch items, or down-detection scripts that need to trigger panic without going through the MDT UI.</p>
    <p className="text-fd-muted-foreground text-sm">All existing guards still apply: the player must be on duty (have <code>mdt_dep_id</code> set), the server enforces <code>jobCheck</code>, source-based rate limiting, and per-identifier cooldown (<code>dispatch.panicCooldown</code>, default 30s).</p>
    ```lua
    ---@return { id?: number, error?: string }
    local result = exports.vx_mdt:triggerPanic()
    if result and result.id then
        print("Panic call created with ID:", result.id)
    end
    ```
    <p className="text-fd-muted-foreground text-sm">Returns <code>{'{ id }'}</code> on success, <code>{'{ error }'}</code> on rejection (off duty, server cooldown, or job check failed). If the local cooldown is active, a toast is shown to the player and no server request is sent.</p>
</div>
<br />
<div className="flex flex-col gap-2 p-3 rounded-xl border bg-fd-card text-fd-card-foreground not-prose">
    ### registerAutoDetectSuppressor(eventKey, fn) [#registerautodetectsuppressoreventkey-fn]
    <p className="text-fd-muted-foreground text-sm">Register a callback that can drop a specific auto-detection event before it generates a dispatch call. Useful for paintball minigames, arena events, scripted cutscenes, or any context where the player's actions shouldn't page LEOs.</p>
    <p className="text-fd-muted-foreground text-sm"><code>eventKey</code> must be one of <code>gunshot</code>, <code>fight</code>, <code>carjacking</code>, <code>vehicleTheft</code>, <code>explosion</code>, <code>speeding</code>. <code>fn</code> receives an event-specific context table and should return <code>true</code> to suppress, <code>false</code>/<code>nil</code> to allow.</p>
    <p className="text-fd-muted-foreground text-sm">Suppressors stack: multiple resources can each register their own. If any returns <code>true</code>, the event is dropped. Calls run before the cooldown timer, so suppressed events don't burn the cooldown window. See <a href="/mdt/dispatch#suppression-hooks">Suppression Hooks</a> for the full <code>ctx</code> shape per event.</p>
    ```lua
    ---@param eventKey "gunshot"|"fight"|"carjacking"|"vehicleTheft"|"explosion"|"speeding"
    ---@param fn fun(ctx: table): boolean?
    ---@return boolean ok
    local ok = exports.vx_mdt:registerAutoDetectSuppressor("gunshot", function(ctx)
        return exports["pug-paintball"]:IsInPaintball()
    end)
    ```
    <p className="text-fd-muted-foreground text-sm">Returns <code>true</code> on success, <code>false</code> if the event key is unknown or arguments are invalid. Registrations are cleared on vx_mdt restart; re-register from your resource's start hook.</p>
</div>
