> For the complete documentation index, see [llms.txt](https://devmosaic.gitbook.io/devmosaic/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devmosaic.gitbook.io/devmosaic/resources/devmosaic-dm-hud/exports-and-bridges.md).

# Exports And Bridges

Every export with a worked example, the compatibility bridge, and provider hooks.

Every export is on `dm-hud`. **Client exports act on the player running them. Server exports take that player's `source` as the first argument.**

```lua
exports['dm-hud']:setVisible(false)          -- client
exports['dm-hud']:toggleHud(source, false)   -- server
```

{% hint style="success" %}
**Jump to what you need**
{% endhint %}

| I want to                          | Go to                                           |
| ---------------------------------- | ----------------------------------------------- |
| Hide the HUD during a cutscene     | [HUD visibility](#hud-visibility)               |
| Read or set the seatbelt           | [Seatbelt](#seatbelt)                           |
| Read or set cruise control         | [Cruise control](#cruise-control)               |
| Add or drain stress                | [Stress](#stress-exports)                       |
| Open the settings or layout editor | [Opening panels](#opening-panels)               |
| Add my own bar or chip             | [Custom bars and chips](#custom-bars-and-chips) |
| Hide or lock something at runtime  | [Policy](#policy-exports)                       |
| Point the HUD at my own script     | [Providers](#providers)                         |

Every export below has a real example you can copy.

## HUD Visibility

**`setVisible(state)`** — client. Hides the whole HUD and brings it back.

```lua
exports['dm-hud']:setVisible(false)
Wait(10000)
exports['dm-hud']:setVisible(true)
```

**`isVisible()`** — client. Returns `true` or `false`.

```lua
if not exports['dm-hud']:isVisible() then
    exports['dm-hud']:setVisible(true)
end
```

**`toggleHud(source, state)`** — server. The same, for one player.

```lua
RegisterCommand('cutscene', function(source)
    exports['dm-hud']:toggleHud(source, false)
end, true)
```

## Seatbelt

**`isBuckled()`** — client. Returns `true` or `false`.

```lua
CreateThread(function()
    while true do
        Wait(2000)

        if cache.vehicle and not exports['dm-hud']:isBuckled() then
            lib.notify({ title = 'Buckle up', type = 'error' })
        end
    end
end)
```

**`setBuckled(state)`** — client. Buckles them for you, for a delivery job.

```lua
RegisterNetEvent('delivery:start', function()
    exports['dm-hud']:setBuckled(true)
end)
```

## Cruise Control

**`isCruising()`** — client. Returns `true` or `false`.

```lua
RegisterNetEvent('zones:enterSchool', function()
    if exports['dm-hud']:isCruising() then
        lib.notify({ title = 'Cruise control off — school zone' })
    end
end)
```

## Stress Exports

**`getStress()`** — client. Returns `0`–`100`.

```lua
if exports['dm-hud']:getStress() > 80 then
    lib.notify({ title = 'You need a break', type = 'error' })
end
```

**`relieveStress(amount)`** — client. A cigarette that calms you down.

```lua
RegisterNetEvent('items:useCigarette', function()
    exports['dm-hud']:relieveStress(25)
end)
```

**`gainStress(amount)`** — client. A tense moment that winds you up.

```lua
RegisterNetEvent('heist:alarmTripped', function()
    exports['dm-hud']:gainStress(20)
end)
```

**`setStressLevel(value)`** and **`resetStress()`** — client.

```lua
exports['dm-hud']:setStressLevel(50)
exports['dm-hud']:resetStress()
```

**`isPlayerJobWhitelisted()`** — client. `true` when the player's job is in `DashCfg.stress.whitelistedJobs` and never gains stress.

```lua
if not exports['dm-hud']:isPlayerJobWhitelisted() then
    exports['dm-hud']:gainStress(10)
end
```

The same four exist on the server with `source` first, for when the event happens server-side.

```lua
RegisterNetEvent('job:finishedShift', function()
    local src = source

    exports['dm-hud']:relieveStress(src, 30)
end)
```

```lua
exports['dm-hud']:getStress(source)
exports['dm-hud']:setStress(source, 40)
exports['dm-hud']:gainStress(source, 10)
exports['dm-hud']:relieveStress(source, 10)
```

## Opening Panels

**`openSettings()`** — client. Put the HUD settings behind your own menu.

```lua
RegisterCommand('myhud', function()
    exports['dm-hud']:openSettings()
end)
```

**`openLayoutTool()`** — client.

```lua
exports['dm-hud']:openLayoutTool()
```

**`toggleVehicleControls(state)`** — client. Opens the door and window panel.

```lua
RegisterCommand('doors', function()
    exports['dm-hud']:toggleVehicleControls(true)
end)
```

## Custom Bars And Chips

Full guide in [Extending The HUD](/devmosaic/resources/devmosaic-dm-hud/extending.md).

```lua
exports['dm-hud']:registerVital({
    id = 'radiation',
    label = 'Radiation',
    colour = '#7cff5a',
    icon = 'stress',
})

exports['dm-hud']:setVital('radiation', 42)
exports['dm-hud']:removeVital('radiation')
```

```lua
exports['dm-hud']:registerChip({ id = 'crew', label = 'Crew', icon = 'gang' })
exports['dm-hud']:setChip('crew', { text = 'Alpha' })
exports['dm-hud']:removeChip('crew')
```

## Policy Exports

The runtime version of `shared/policy.lua`. Full guide in [Policy And Locks](/devmosaic/resources/devmosaic-dm-hud/policy-and-locks.md).

**`setHidden(source, id, state)`** — server. A server-wide blackout event.

```lua
RegisterNetEvent('event:blackoutStart', function()
    for _, id in ipairs(GetPlayers()) do
        exports['dm-hud']:setHidden(tonumber(id), 'minimap', true)
    end
end)
```

**`setForced(source, path, value)`** — server. Put someone in a race.

```lua
exports['dm-hud']:setForced(source, 'vehicle.layout', 'racing')
```

**`setLocked(source, path, state)`** — server. Lock a setting where it stands.

```lua
exports['dm-hud']:setLocked(source, 'minimap.shape', true)
```

**`clearForced(source, path)`** and **`resetPolicy(source)`** — server. The second is the one you want when the event ends.

```lua
RegisterNetEvent('event:blackoutEnd', function()
    for _, id in ipairs(GetPlayers()) do
        exports['dm-hud']:resetPolicy(tonumber(id))
    end
end)
```

All of them exist on the client for the local player, without `source`:

```lua
exports['dm-hud']:setHidden('minimap', true)
exports['dm-hud']:isHidden('minimap')
exports['dm-hud']:setLocked('minimap.shape', true)
exports['dm-hud']:isLocked('minimap.shape')
exports['dm-hud']:setForced('vehicle.layout', 'racing')
exports['dm-hud']:clearForced('vehicle.layout')
exports['dm-hud']:resetPolicy()
```

## Stress Events

Already sending stress events for another HUD? These are listened for, so your existing code keeps working untouched.

```lua
TriggerServerEvent('hud:server:GainStress', 10)
```

* `hud:server:GainStress` — client to server
* `hud:server:RelieveStress` — client to server
* `updateStress` — server to client
* `dash:setStress` — server to client

***

## Compatibility Bridge

The bridge exists so you can drop the HUD onto an existing server without rewriting anything. It detects what you are running at start-up — there is nothing to configure.

#### Frameworks

* `qbx_core` — detected as `qbx`
* `qb-core` — detected as `qb`
* `es_extended` — detected as `esx`
* none of the above — `none`

With no framework the HUD still runs. Health, armour, oxygen, stamina, speed, fuel and everything vehicle-related come from the game itself. Only job, gang, cash, bank, hunger and thirst go quiet.

The console prints what it found:

```
[dm-hud] v1.0.0 ready — framework: qbx
```

#### Fuel

Checked in order, first one running wins.

* `ox_fuel` · `LegacyFuel` · `ps-fuel` · `cdn-fuel` · `Renewed-Fuel`
* `lj-fuel` · `lc_fuel` · `myFuel` · `x-fuel` · `BigDaddy-Fuel` · `okokGasStation`

Nothing running? The HUD falls back to the game's own fuel level, which works but ignores custom fuel logic.

#### Voice

* `pma-voice` — talking indicator, proximity range, radio channel
* `saltychat` — talking indicator, radio channel
* `tokovoip_script` — talking indicator
* `mumble-voip` — talking indicator

#### Hunger And Thirst

Read from your framework's player data. On ESX the HUD also listens to `esx_status`, supporting both of its APIs.

***

## Providers

Bridges cover scripts the HUD knows about. Providers cover the ones it does not. If you already run a seatbelt, stress or cruise control script you want to keep, hand that feature over — the HUD still draws the element, it just asks your script for the value.

All of it lives in `DashCfg.providers`. Leave a block commented out to keep the built-in behaviour.

#### Seatbelt

```lua
DashCfg.providers = {
    seatbelt = {
        get = function() return exports['my-seatbelt']:IsBuckled() end,
        toggle = function() exports['my-seatbelt']:Toggle() end,
    },
}
```

`get` returns `true` or `false`. `toggle` runs when the player presses the belt key or types `/dashbelt`.

Hand it over and the HUD stops running its own belt logic — no double buckling, no fighting over the through-the-windscreen crash. The lamp, the warning chime and the crash protection all follow your script. Set `DashCfg.keys.belt = false` too if your script binds its own key.

#### Stress

```lua
DashCfg.providers = {
    stress = {
        get = function() return exports['my-stress']:GetStress() end,
    },
}
```

`get` returns `0`–`100`. There is no `toggle` — stress is a value, not a switch. The HUD stops generating stress but keeps drawing the bar and applying the screen blur above `DashCfg.stress.blurAbove`.

#### Cruise Control

```lua
DashCfg.providers = {
    cruise = {
        get = function() return exports['my-cruise']:IsActive() end,
        toggle = function() exports['my-cruise']:Toggle() end,
    },
}
```

`get` takes whichever shape your script already returns:

* `true` — lamp on, showing your current speed
* `false` or `nil` — lamp off
* a number such as `70` — lamp on, showing `70`
* `0` — lamp off

A number is read as already being in the player's display units, so return mph or kmh to match `DashCfg.units.speed`, not metres per second. The HUD stops holding the throttle itself; your script does the driving, the HUD only reports.

#### Notes

* A provider that errors is treated as off rather than crashing, and will not spam your console.
* Providers are read every frame. Keep `get` cheap — read a cached value or a statebag, never a server round trip.
* Turning a module off in `DashCfg.modules` removes the element entirely. A provider is the opposite: keep the element, change where its value comes from.

***

## Every Export

| Export                           | Side   | Returns |
| -------------------------------- | ------ | ------- |
| `setVisible(state)`              | client | —       |
| `isVisible()`                    | client | boolean |
| `toggleHud(source, state)`       | server | —       |
| `isBuckled()`                    | client | boolean |
| `setBuckled(state)`              | client | —       |
| `isCruising()`                   | client | boolean |
| `getStress()`                    | client | 0–100   |
| `setStressLevel(value)`          | client | —       |
| `gainStress(amount)`             | client | —       |
| `relieveStress(amount)`          | client | —       |
| `resetStress()`                  | client | —       |
| `isPlayerJobWhitelisted()`       | client | boolean |
| `getStress(source)`              | server | 0–100   |
| `setStress(source, value)`       | server | —       |
| `gainStress(source, amount)`     | server | —       |
| `relieveStress(source, amount)`  | server | —       |
| `openSettings()`                 | client | —       |
| `openLayoutTool()`               | client | —       |
| `toggleVehicleControls(state)`   | client | —       |
| `registerVital(def)`             | client | boolean |
| `setVital(id, value)`            | client | boolean |
| `removeVital(id)`                | client | boolean |
| `registerChip(def)`              | client | boolean |
| `setChip(id, patch)`             | client | boolean |
| `removeChip(id)`                 | client | boolean |
| `setHidden(id, state)`           | client | —       |
| `isHidden(id)`                   | client | boolean |
| `setLocked(path, state)`         | client | —       |
| `isLocked(path)`                 | client | boolean |
| `setForced(path, value)`         | client | —       |
| `clearForced(path)`              | client | —       |
| `resetPolicy()`                  | client | —       |
| `setHidden(source, id, state)`   | server | —       |
| `setLocked(source, path, state)` | server | —       |
| `setForced(source, path, value)` | server | —       |
| `clearForced(source, path)`      | server | —       |
| `resetPolicy(source)`            | server | —       |
