# ACE Permissions (/docs/faq-ace-permissions)
FiveM's ACE system is how scripts decide who can run which commands. TIMMYG Studios scripts use it for admin-only features — for example, opening the tELS editor requires the `tlib.admin` permission.
Permission checks happen **server-side**, so changes require either an `ensure` of the resource or a server restart to take effect.
---
## Principals
A _principal_ is an identifier that holds permissions (which FiveM calls **ACEs**). Principals are either:
- **Player identifiers** — a specific player's Discord ID, Steam ID, License, etc.
- **Groups** — made-up identifiers prefixed with `group.` (e.g., `group.admin`, `group.moderator`). Groups don't need to be declared — they exist the moment you reference one.
Groups are the recommended approach since they let you assign the same permissions to many players at once.
### Adding a player to a group
```ini
title="server.cfg" add_principal identifier.discord:394446211341615104 group.admin
```
This adds the player with Discord ID `394446211341615104` to `group.admin`. Any ACEs granted to `group.admin` now apply to that player.
### Nesting groups
```ini
title="server.cfg" add_principal group.admin group.moderator
```
`group.admin` now inherits every permission that `group.moderator` has.
Lines starting with `#` in `server.cfg` are comments and are ignored by the parser.
---
## Granting permissions
Use `add_ace` to grant a permission node, `remove_ace` to revoke it. Permissions can be attached to a group or directly to a player identifier.
```ini
title="server.cfg" # Grant the tlib.admin permission to the admin group add_ace group.admin "tlib.admin" allow # Add the player to the group — they inherit all of its permissions add_principal identifier.discord:394446211341615104 group.admin
```
Any player added to `group.admin` now has `tlib.admin`. Add or remove players from the group without touching the ACE itself.
```ini
title="server.cfg" # Grant the permission directly to one player add_ace identifier.discord:394446211341615104 "tlib.admin" allow
```
Faster for a single player, but doesn't scale. Prefer groups if more than one person will ever need the permission.
### Removing permissions
```ini
title="server.cfg" # Revoke from the group remove_ace group.admin "tlib.admin" allow # Revoke from a specific player remove_ace identifier.discord:394446211341615104 "tlib.admin" allow
```
The `allow` at the end must match the original grant.
---
## Example: giving someone tELS editor access
The tELS editor is gated behind `tlib.admin`. To grant a player access:
### Open server.cfg
Locate `server.cfg` in your server's root directory.
### Grant the ACE to a group
```ini
title="server.cfg" add_ace group.admin "tlib.admin" allow
```
### Add the player to the group
```ini
title="server.cfg" add_principal identifier.discord:394446211341615104 group.admin
```
Replace the Discord ID with your admin's identifier. You can also use `identifier.steam:...`, `identifier.license:...`, or `identifier.fivem:...`.
### Restart the server
ACE changes are loaded at startup. Restart the server or run `refresh` + `restart` on the resources that check the permission.
### Verify
The admin runs `/telsedit` in-game. If the permission is correct, the editor opens. If it still says permission denied, check the identifier matches exactly — Discord IDs must be numeric with no prefix beyond `identifier.discord:`.
---
## Related
Where `tlib.admin` is used — gates the editor and server-wide defaults.
Provides the admin ACE and permission helpers used across TIMMYG Studios scripts.
If commands fail for reasons other than permissions, start here.
# You Lack the Required Entitlement (/docs/faq-entitlement-error)
## Error Message
```
You lack the required entitlement to use script_name
```
## Why This Happens
All FiveM escrow-protected scripts are linked to your FiveM account (the account you used on Tebex). The script requires a server key generated by the **same FiveM account** that purchased the script.
## What is a Server Key?
- A server key is generated at the [CFX Portal](https://portal.cfx.re/)
- It is **not** a script key
- A FiveM server can only use **one** server key
- It's set in your `server.cfg`:
```ini
sv_licenseKey "YOUR_SERVER_KEY_HERE"
```
---
## How to Fix
### Restart your server
Sometimes a simple restart resolves the issue. Fully restart — don't just `ensure` the resource.
### Verify your server key
Run this in your FiveM server console:
```
sv_licenseKey
```
This shows which server key your server is currently using. Note it down for the next step.
### Verify key ownership
1. Go to the [CFX Portal](https://portal.cfx.re/)
2. Check the **Granted Assets** tab — verify the script appears under this account
3. Check the **Server Keys** section — verify the key from the previous step was generated by this same account
If the script isn't listed under your granted assets, you used a different FiveM account on Tebex, or the script was transferred to another account.
### Check system time
Your server's operating system clock must be accurate. If it's more than one minute off:
1. Check at [time.is](https://time.is/)
2. Select your server's location
3. If the time is off, sync it — [watch this guide](https://www.youtube.com/watch?v=cLJGy4-sMZg)
### Transfer the script (if keys and purchase don't match)
If your server key belongs to a different account than the one that purchased the script, either:
- **Generate a new server key** from the account that owns the script, or
- **Transfer the script** to the account that owns the server key (see below)
---
## How to Transfer a Script
Scripts can only be transferred **once**, within 28 days of buying them. A transfer can't be undone.
### Find the server owner
You need the FiveM username of the account you're transferring to:
1. Go to the [FiveM Server List](https://servers.fivem.net/servers)
2. Find your server and check the **Owner** field
3. Alternatively, check the server console for the nucleus auth ID, then visit `https://servers.fivem.net/servers/detail/YOUR_ID`
### Transfer steps
### Log in to the CFX Portal
Open the [CFX Portal](https://portal.cfx.re/) and sign in with the account that currently owns the script.
### Open Granted Assets
Go to **Granted Assets** and select the script.
### Click Transfer
Click **Transfer**.
### Enter the target username
Type the username of the destination FiveM account, then confirm from the email Cfx sends you. The transfer is final.
---
## ZAP-Hosting Users
If you're using ZAP-Hosting, you do **not** enter your server key in `server.cfg`. Instead, set it directly in the ZAP-Hosting web panel.
See the [official ZAP-Hosting guide](https://zap-hosting.com/guides/docs/en/fivem_licensekey/) for instructions.
---
## Related
Overview of all escrow errors and how to identify which one you're seeing.
The other common escrow symptom — usually a bad upload.
If you're seeing this error alongside entitlement issues, start here.
# Failed to Verify Protected Resource (/docs/faq-failed-to-verify)
## Error Message
```
[svadhesive] Failed to verify protected resource your_resource
```
## Possible Causes
The `.fxap` file is required for escrow-protected resources. It's a hidden file and some FTP
programs skip it.
FileZilla damages escrow-protected files during transfer. Some hosting providers use FileZilla
internally as well.
Dragging the folder through Remote Desktop or an FTP client file-by-file corrupts the escrow
files. Always upload the `.zip` and extract on the server.
The download from the CFX Portal was incomplete or corrupted. Re-download and compare file sizes.
Some FTP programs skip hidden files like `.fxap` by default. In WinSCP, enable **Show hidden
files** (Options → Preferences → Panels).
---
## Solutions
### Fresh download and upload
1. Download the script again from the [CFX Portal](https://portal.cfx.re/)
2. Upload using [WinSCP](https://winscp.net/eng/download.php) — **not** FileZilla
3. Make sure hidden files (including `.fxap`) are transferred
4. Restart the server
Upload the `.zip` file to your server and extract it there. Do **not** drag-and-drop the folder
file-by-file, especially over Remote Desktop — this damages escrow files.
### Verify the .fxap file exists
In WinSCP, enable **Show hidden files** (Options → Preferences → Panels → Show hidden files), then navigate to the resource folder and confirm `.fxap` is present.
### Disable anticheat
Some anticheat systems dump or modify Lua files, which breaks escrow protection. Temporarily disable your anticheat to test. If that fixes it, configure your anticheat to exclude the resource folder.
### Update server artifacts
Make sure your server is on artifacts version **4752** or higher. Run `version` in the server console to check.
See [Syntax Error / Error Parsing → Update server artifacts](/docs/syntax-error#solutions) for update instructions.
---
## Related
Overview of all escrow errors and how to identify which one you're seeing.
Same underlying cause (bad upload) — different symptom in the console.
If you've confirmed the files are intact, check whether your key matches the purchasing account.
# General Issues (/docs/faq-general-issues)
If your scripts work initially but stop working after restarting the server a few times, you
likely have a virus on your server. We cannot help in that case — see [What to Do If Nothing Fixes
the Errors](#if-nothing-fixes-the-errors).
## How to Identify FiveM Escrow Errors
To determine if a script issue is caused by the FiveM asset escrow system:
1. Restart the script causing issues using `ensure your_script_name` in the txAdmin console
2. Check **both** the txAdmin console (server console) **and** the F8 in-game console for errors
3. If the error matches one of the types below, it's caused by the FiveM escrow system
---
## Common Escrow Errors
`syntax error near '<\1>'` or `Error parsing script` — usually a bad upload.
`Failed to verify protected resource` — missing `.fxap` or corrupted transfer.
`You lack the required entitlement` — server key doesn't match the purchasing account.
---
## General Solutions
If you can't start or use a script, try these in order:
- Update to **minimum** server artifacts version **4752** or higher
- **Don't** use FileZilla — use [WinSCP](https://winscp.net/eng/download.php) instead
- Use the correct license key generated by the same account where you downloaded the script
- Upload the `.zip` file to your server and extract it there — do **not** transfer files individually
---
## If Nothing Fixes the Errors
If none of the solutions on these pages resolve your issue:
1. Verify you've tried **every** solution listed on the relevant error page
2. Try a completely fresh install of the script
3. Check if your server has been compromised — scripts that break after a few restarts often indicate a virus modifying files
4. Contact support on [Discord](https://timmygstudios.com/discord) with details about what you've tried
---
## Related
How to grant players and groups access to script commands via FiveM's permission system.
# Syntax Error / Error Parsing (/docs/faq-syntax-error)
## Error Messages
You may see one of these in your server console:
```
syntax error near '<\1>'
```
```
Error parsing script @your_resource/server/file.lua in resource your_resource:
@your_resource/server/file.lua:1: syntax error near '<\1>'
```
```
Failed to load script @your_resource/server/file.lua
```
## Possible Causes
FileZilla damages escrow-protected files during transfer in its default mode. Use
[WinSCP](https://winscp.net/eng/download.php) instead, or switch FileZilla to binary transfer
mode.
Transferring files one-by-one through RDP also damages them. Upload the `.zip` to the server and
extract it there.
Your server must be at least artifacts version **4752**. Older builds can't load modern escrow
resources.
The download itself may have been truncated or corrupted. Re-download from the CFX Portal.
A virus on your server may be modifying script files. This usually manifests as scripts working
initially and breaking after a few restarts.
---
## Solutions
### Re-upload with WinSCP
Download the script again from the [CFX Portal](https://portal.cfx.re/) and upload using [WinSCP](https://winscp.net/eng/download.php) instead of FileZilla.
Always upload the `.zip` file to your server first, then extract it there. Never transfer the
folder file-by-file.
### Or: switch FileZilla to Binary mode
If you must use FileZilla:
1. Open FileZilla
2. Go to **Transfer** → **Transfer Type** → **Binary**
3. Re-upload the entire resource
### Update server artifacts
Run `version` in the server console. If it's below **4752**, update.
1. Download the latest recommended artifacts from the [Windows artifacts page](https://runtime.fivem.net/artifacts/fivem/build_server_windows/master/)
2. Stop your server
3. Remove the old server folder and replace it with the new one
4. Start the server and run `version` to confirm
1. Download the latest recommended artifact from the [Linux artifacts page](https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/)
2. Stop your server
3. Delete the `cache` and `alpine` folders
4. Extract with `tar -xf fx.tar.xz`
5. Start the server and run `version` to confirm
### Clear the server cache
Delete the `cache` folder in your server directory and restart.
### Fresh install
If nothing else works:
1. Delete the resource folder entirely
2. Download a fresh copy from the [CFX Portal](https://portal.cfx.re/)
3. Upload via [WinSCP](https://winscp.net/eng/download.php)
4. Disable any anticheat that dumps or modifies Lua files
5. Restart the server
---
## Related
Overview of all escrow errors and how to identify which one you're seeing.
Different error, same root cause as the corrupted-upload fix above.
If restarts stop loading the script entirely, you may be hitting this instead.
# tAFK (/docs/tAFK)

Store Page
Support
tAFK replaces the AFK kick with a camera. When a player stops touching their controls in a vehicle, the screen fades and an orbiting shot of their car takes over, cutting on the beat of whatever is playing. Any input drops them back in. Shots are authored **in the game**, and vehicle packs can ship their own.
## What it is not
- **Not an AFK kick.** It never removes, moves or reports anyone. To kick idle players, read [`Player(src).state.afk`](/docs/tAFK/api-reference#localplayerstateafk) yourself.
- **Not a photo mode.** No player free-cam, no capture, no upload.
- **Not a music player.** During the cinematic only, from `audio/` or a live stream an admin enables.
## Requirements
| Requirement | Detail |
| --- | --- |
| FiveM | **OneSync** enabled (Infinity or Legacy) |
| tLib | **v1.0 or newer**, free — [download](https://github.com/tommy141x/tLib/releases) |
| Framework, database | Neither. Identical on ESX, QBCore, Qbox and vanilla |
`Player(playerServerId).state.afk` is the whole integration — see
[Usage → Telling other scripts a player is AFK](/docs/tAFK/usage#telling-other-scripts-a-player-is-afk).
# tAFK API reference (/docs/tAFK/api-reference)
## Client exports
All on `exports['tAFK']`, acting on the local player.
| Export | Returns | Does |
| --- | --- | --- |
| `IsAFK()` | bool | `true` from entry commit, before the fade |
| `StartAFK()` | bool | Triggers AFK. **Blocks ~1s** for the fade |
| `StopAFK()` | — | Exits, or aborts an entry fade |
| `ToggleAFK()` | bool | Acceptance, **not** direction |
| `IsAFKEnabled()` | bool | Whether it *can* trigger this session |
| `SetAFKEnabled(bool)` | bool | Session-only, never persisted |
`StartAFK` returns the outcome, not an acknowledgement. `false` for:
| Refusal | Toast |
| --- | --- |
| Session switch off | yes |
| The sequence editor is open | yes |
| Ragdolling, in a cutscene, or mid player-switch | yes |
| Not in a vehicle | yes |
| No sequence applies to the vehicle | yes |
| Input cancelled the fade | no |
A manual start arms a **3-second input grace window** — input cannot cancel the fade inside it. `StopAFK` is not a no-op when the player is not AFK: it aborts an entry fade, so calling it just after `StartAFK` cancels that start.
`true` does **not** mean "now AFK" — exiting returns `true` too, so read `IsAFK()` afterwards.
`false` means the session switch is off or the player is not in a vehicle; both raise a toast.
The editor, ragdoll and no-sequence refusals apply later, on the start path.
## Client events
### `tafk:stateChanged`
```lua
AddEventHandler('tafk:stateChanged', function(isAfk) end)
```
Local to one client, and fired before the state bag is written.
To react to another player's AFK status, read `Player(src).state.afk` or subscribe to the
state-bag change handler.
## State bags
### `LocalPlayer.state.afk`
Replicated, set on AFK enter, exit and resource start. tAFK writes it; other scripts read it.
```lua
local ok = Player(playerServerId).state.afk -- client, about anyone
local ok = Player(source).state.afk -- server
AddStateBagChangeHandler('afk', nil, function(bagName, key, value)
local playerId = GetPlayerFromStateBagName(bagName) -- server id
end)
```
`nil` means they have not loaded tAFK. Treat it as "not AFK".
## Server-side admin events
All gated on `tlib.admin`. A non-admin can fire them and nothing happens.
### `tafk:admin:updateSetting`
```lua
TriggerServerEvent('tafk:admin:updateSetting', key, value)
```
An unknown key or a value outside its clamp is logged to the server console and nothing is written.
### Sequence events
| Global event | Per-vehicle event | Token |
| --- | --- | --- |
| `tafk:admin:upsertSequence` | `…:upsertVehicleSequence` | yes |
| `tafk:admin:deleteSequence` | `…:deleteVehicleSequence` | yes |
| `tafk:admin:toggleSequence` | `…:toggleVehicleSequence` | no |
The global three write `data.json.sequences`, the per-vehicle three `vehicleConfigs[].sequences`.
```lua
TriggerServerEvent('tafk:admin:upsertSequence', seqObject, token)
TriggerServerEvent('tafk:admin:upsertVehicleSequence', 'bati801', seqObject, token)
TriggerServerEvent('tafk:admin:toggleVehicleSequence', 'bati801', 'bati_low_pass', false)
```
`seqObject` is shaped like [`sequences[]`](/docs/tAFK/configuration); a matching `id` is replaced, otherwise appended, and anything invalid is rejected with the text on [`tafk:admin:saveResult`](#tafkadminsaveresult). **A script firing only the global pair silently misses every per-vehicle sequence.**
### The `token` argument
Any value you choose, echoed back verbatim. Use a fresh one per write and ignore replies that do not match. Pass `nil` and the write still happens, but **no reply is sent**.
### `tafk:admin:saveResult`
Server → client. The only channel carrying a write's outcome.
```lua
RegisterNetEvent('tafk:admin:saveResult', function(token, ok, message)
-- message: a full sentence, nil on success
end)
```
Show `message` verbatim; do not parse it.
Music is discovered from `audio/` at resource start (see
[Configuration](/docs/tAFK/configuration#music-tracks)) — there is nothing to register, toggle
or delete. Live radio is three `tafk:admin:updateSetting` keys.
## `audioDiscovery` (server export)
The state of [beat analysis](/docs/tAFK/configuration#beat-data) across every discovered track.
```lua
local state = exports['tAFK']:audioDiscovery()
```
| Field | Type | Meaning |
| --- | --- | --- |
| `tracks` | array | Every file found, each with a `state` |
| `analysed` | **number** | How many have a grid |
| `unanalysed` | array | Never analysed |
| `stale` | array | Analysed, but the sha256 changed |
| `pending` | array | Everything not `analysed` |
| `leased` | string \| `nil` | The file being analysed now |
`analysed` is a count while the three beside it are lists; `#state.analysed` is not what you want.
## Client config events
`tafk:request_config` asks for the current `data.json` and is answered by `tafk:config_receive`. It is **rate-limited to one call per second per player**, and a second is dropped silently — wait, do not retry.
# tAFK Configuration (/docs/tAFK/configuration)
Settings come from four places, each overriding the one before it: `shared/schema.lua` defaults, `data.json` at the resource root, a vehicle pack's `tafk.json`, then the player's own `tafk:*` settings. Sequences are a union of `data.json` and the packs.
Almost nothing here needs a text editor. The camera sequences are built in the
in-game editor (`/tafkedit`) and every server setting is tunable live from
`/tafk`; `data.json` is what those two write, and is documented below as
reference for reading it or shipping one with a vehicle.
## Admin settings via `/tafk`
Every `settings` field is tunable live with the `tlib.admin` ACE, and clamped server-side: `timeoutSeconds` 0–3600, durations 1000–45000, `beatAnchorMs` ±1000, `musicVolume` 0–1, `radioDelaySeconds` 5–60, `radioStreamUrl` https and ≤512 chars. A value outside its range is refused and logged, not written.
The duration sliders are in **seconds** — minimum 1–30, maximum 2–45 — and are stored in milliseconds.
## Player KVP overrides
| Key | Type | Default | Set by |
| --- | --- | --- | --- |
| `tafk:playerDisabled` | bool | unset → enabled | **AFK System** |
| `tafk:music` | bool | unset → inherit | **Play Music During AFK** |
| `tafk:volume` | float | unset → inherit | **Music Volume** |
| `tafk:hudHide` | bool | unset → inherit | **Hide HUD While AFK** |
| `tafk:stillCamera` | bool | unset → off | **Still Camera While AFK** |
| `tafk:seqDisabled` | string[] | `[]` | **Sequences** tab |
## Per-vehicle sequence packs
A vehicle resource can ship its own sequences. Declare them in its manifest and tAFK merges them in on start.
```lua title="fxmanifest.lua"
files { 'tafk.json' }
tafk_config 'tafk.json'
```
```json title="tafk.json"
{ "mycar": { "sequences": [ "… entries exactly as in data.json" ] } }
```
| Rule | Detail |
| --- | --- |
| Manifest | Needs **both** `tafk_config` and `tafk.json` in `files { }` |
| Shape | One file per resource, lowercase model keys, entries like `sequences[]` |
| Priority | Two resources, one model: **first scanned wins**. Admin edits outrank packs |
| Refresh | Server start, a pack's `onResourceStart`, every admin save |
## `data.json` shape
Read once at server start. After a direct edit run `restart tAFK`, which re-scans `audio/` too. Invalid sequences are dropped with a **server**-log warning.
It is not in the release zip, so your settings and sequences survive an upgrade. If it will not
parse, tAFK parks it as `data.json.corrupt.` and seeds defaults.
Four top-level keys: `version`, `settings`, `sequences`, and `vehicleConfigs`. **Do not edit `vehicleConfigs` by hand** — it is written for you by the editor and by vehicle packs.
### `settings`
| Key | Type | Default | Meaning |
| --- | --- | --- | --- |
| `timeoutSeconds` | int | `30` | Idle seconds before auto-AFK. `0` disables it |
| `useMusic` | bool | `true` | Start music on AFK enter |
| `musicVolume` | float 0–1 | `0.04` | Music volume |
| `hideHudInAFK` | bool | `true` | Hide HUD and minimap while AFK |
| `beatAnchorMs` | int | `-15` | Next-beat offset. Negative cuts early |
| `minDurationMs` | int | `5000` | Shortest shot |
| `maxDurationMs` | int | `10000` | Longest shot |
| `radioEnabled` | bool | `false` | Live stream instead of `audio/` |
| `radioStreamUrl` | string | OOC Radio | Icecast mount. `https`, must send CORS |
| `radioDelaySeconds` | int | `25` | Seconds behind live |
### Live radio
The stream replaces the `audio/` rotation. **Leave `radioDelaySeconds` alone** — beat-matching needs that lookahead.
Each AFK player opens their own connection, ~24 KB/s at 192 kbps. A dead mount, or one with no CORS header, falls back to `audio/`.
### `sequences[]`
| Field | Type | Notes |
| --- | --- | --- |
| `id` | string | Stable key for opt-outs and edits. Never change it |
| `name` | string | Display name in `/tafk` menus |
| `enabled` | bool | `false` is skipped by the director |
| `vehicles` | string[] | `["*"]` = all, else lowercase model names |
| `start` / `end` | object | See [Keyframe shape](#keyframe-shape) |
### Keyframe shape
```json
{ "offset": [-6.0, -7.0, 0.1], "rotation": [3.0, 0.0, 30.0], "fov": 55.0,
"dof": { "near": 2.0, "far": 20.0, "strength": 0.7 } }
```
| Field | Meaning |
| --- | --- |
| `offset` | Vehicle-local metres: right +x, forward +y, up +z |
| `rotation` | Degrees, a delta on the "point at vehicle" rotation |
| `fov` | Degrees. The editor clamps its wheel to 10–120 |
| `dof.near` / `.far` | Range in metres |
| `dof.strength` | 0 (no blur) to 1 (full) |
Offsets also accept `{ "x": …, "y": …, "z": … }`.
A hand-edited `fov` of 400 is accepted and renders. Stay inside the ranges.
### Music tracks
Drop `.ogg`, `.mp3` or `.wav` files into `tAFK/audio/` and restart. Any filename works, with nothing to register: the folder is the authority, re-scanned every boot, and tracks are **not** in `data.json`.
#### Beat data
Beat-matched cuts need a grid per track, in `audio/beatmap.json`.
You need run nothing: analysis starts 30 seconds after load and happens in the background, one track at a time. An un-analysed track still plays, at random shot lengths. The offline analyser in `tools/audio/beatmap.sh` produces a better grid, and is never overwritten by the automatic one.
Grids are keyed by sha256, so re-encoding at a different bitrate discards the old one — every
beat time in it is wrong.
The offline script defaults to tLoading's beatmap, so point `--out` at tAFK's:
```bash
./tools/audio/setup.sh # once
./tools/audio/beatmap.sh --out "data/resources/[tScripts]/tAFK/audio/beatmap.json" \
analyze "data/resources/[tScripts]/tAFK/audio/"*.ogg
```
## File layout
The paths you touch; the rest is internal.
| Path | Purpose |
| --- | --- |
| `data.json` | Settings, sequences, `vehicleConfigs` |
| `shared/schema.lua` | Defaults, the 11 seed sequences, validators |
| `audio/` + `beatmap.json` | Music tracks and their beat grids |
| `client/ui/` | The built NUI. Do not edit — it is generated, and a change here is lost on update. |
`shared/schema.lua` is unencrypted in your install, so every default on this page is readable there.
# tAFK Editor (/docs/tAFK/editor)
`/tafkedit`, or **Sequence Editor** in `/tafk`'s sidebar, authors, edits and deletes every sequence applying to the vehicle you are in. Requires `tlib.admin`. A sequence is two keyframes — a **start** and an **end** camera pose — plus a name, scope and DOF. What you frame is what players see.
## Layout
| Region | What is in it |
| --- | --- |
| **Header**, top left | Vehicle, FOV, `Start ✓` / `End ✓` chips, **UNSAVED** |
| **Sequence list**, left | Global `ALL` and per-model `VEH` rows, **New Sequence** |
| **Details**, right | Name, scope, DOF sliders, **Delete sequence** |
| **Bottom bar** | Set Start / Set End · Preview / Save · Exit |
Click a row to load it; its checkbox toggles the rotation without loading, and persists immediately. Scope is editable only on an unsaved draft. When Preview or Save is unavailable, the reason prints above the bar.
## Create a sequence
### Enter the editor
Be in a vehicle, not already AFK. The ped and vehicle freeze, the camera starts 7 m out.
### Use the blank draft you already have
Entering creates one, named *"Sequence 1"*. Overwrite the name inline; **New Sequence** starts a second.
### Position and capture
Orbit or fly, press **1** for the start, reposition, press **2** for the end. The chips go green and markers appear.
### Tune, preview, save
Set DOF and pick the scope, press **3** to play it, **4** to save. The button reads *Saving…* until the server answers, then **UNSAVED** clears; a failed write or missing ACE raises an error toast.
## Edit, delete, toggle
Loading a row fills the panel and drops markers at the saved positions; the **Start ✓** and **End ✓** chips teleport the camera to each pose. Re-capture with **1** / **2**, then save. **Delete sequence** confirms by name, then opens a fresh draft.
## Controls
| Input | Action |
| --- | --- |
| **MMB drag** | Orbit the pivot |
| **Shift + MMB** | Pan, camera and pivot together |
| **RMB drag** | Look around in place |
| **Wheel** | FOV zoom, 10°–120° |
| **W A S D** | Fly in view space |
| **Space / Ctrl** | Up / down, world Z |
| **Shift / Alt** *(hold)* | 3× / 0.3× speed |
| **1** / **2** | Capture Start / End |
| **3** | Preview, again to stop |
| **4** | Save Changes |
| **Esc** or **5** | Exit, twice if unsaved |
Action keys are ignored while a text field has focus, so `Escape plan` is a safe name.
Keyframes are stored relative to the vehicle, so a sequence replays correctly whatever direction the car is facing.
## Save scope
| Scope | Stored in | Best for |
| --- | --- | --- |
| **Global** (`["*"]`) | `data.json.sequences` | Shots that work on anything |
| **Per-vehicle** | `vehicleConfigs[]` | Shots using the model's geometry |
A sequence missing a keyframe is rejected with a toast.
Author under **This model only**, then copy the entries from `data.json.vehicleConfigs[]`
into your pack's `tafk.json`. See
[Configuration](/docs/tAFK/configuration#per-vehicle-sequence-packs).
## Leaving safely
**Exit** writes nothing for an unsaved draft; saved sequences stay on disk. With unsaved changes the first press arms it and the button becomes **Discard & Exit?** for four seconds. Losing the vehicle exits with an error toast.
Clicking another row — or **New Sequence** — replaces the draft. With unsaved changes the first
click only warns; click the same target again within four seconds to discard, or press **4**.
# tAFK Installation (/docs/tAFK/installation)
Drop the folder in, add two `ensure` lines, grant one ACE. tAFK writes its own `data.json` on first boot. It needs **OneSync** and [tLib v1.0 or newer](https://github.com/tommy141x/tLib/releases), and no framework or database.
The source archive has no built files, so every tAFK export resolves against nothing.
Do not edit `tlib_min_version '1.0'` out of `fxmanifest.lua` to run an older tLib. On tLib 0.6
the confirmation prompt is skipped, so **Reset My Settings** wipes five preferences on the first
click with no warning.
Remove `tommys-afk` first. The resource name, exports and state-changed event all differ.
## Install
### Extract the resource
Drop the `tAFK` folder into `resources/`, or a group like `[tScripts]`.
The folder name *is* the resource name, and names are case-sensitive. A space, or a `-main`
suffix from a downloaded archive, breaks every `exports['tAFK']` call and the editor's save path.
### Start tLib before tAFK
```ini title="server.cfg"
ensure tLib
ensure tAFK
```
### Grant admin access
```ini title="server.cfg"
add_ace group.admin tlib.admin allow
```
Unlocks `/tafkedit`, sequence management and **Server Defaults**. Non-admins see only the player half of `/tafk`.
### Start the server
tAFK ships a `data.json` with 11 sequences, rebuilt from `shared/schema.lua` if missing. `audio/` is re-scanned every boot.
## Verify it works
tAFK draws tLib's startup banner on the **server**:
```
Scenes: 11 sequence(s) configured
Tracks: 40 music track(s) discovered
Beats: 40 of 40 analysed
```
`Beats:` reads `… analysed, N queued` while tracks are still being analysed, and is absent with no audio files.
On the **client** a start is silent, bar one line for a player who switched the system off: `AFK disabled by player preference`. Judge the install from the server banner and the camera firing, not from F8.
## See it in the game
Get into any vehicle — cars, bikes, boats and aircraft all work — open `/tafk` and press **Enter AFK Mode**. Leaving the controls alone for 30 seconds does the same.
**It works if** the screen fades, the camera frames the vehicle, and your first input snaps you back. If not, see [Troubleshooting](/docs/tAFK/troubleshooting).
## Optional: help us fix tAFK
tAFK does not report its own faults to us. When it throws on your server the
error sits in your console, and unless someone opens a ticket we never learn it
happened — which means the bugs nobody reports are the ones that stay.
One line opts in, in `server.cfg` above `ensure tLib`:
```txt title="server.cfg"
set tlib_telemetry 1
```
That sends errors, warnings, renderer crashes and slow-operation outliers from
our own code. **No IP, no licence key, no server name, no player names or
identifiers**, and `_diag` output is never included. `tlib_telemetry_status`
in the console shows what is on and what decided it.
It is off unless you set it, nothing is gated behind it, and
[Diagnostics](/docs/tLib/telemetry) is the full account of what is and is not sent.
# tAFK Troubleshooting (/docs/tAFK/troubleshooting)
## Startup
| Symptom | Fix |
| --- | --- |
| `attempt to index a nil value (global 'tlib')` | tLib missing or late. Use its **release zip**, `ensure tLib` first, restart — `refresh` does not re-order |
| `No such export ScanResourceFiles` | tLib predates `assets`. Replace the folder wholesale |
| Every export returns nil | The folder is not named exactly `tAFK`. It is case-sensitive |
## The camera never fires
### Nothing happens after 30 seconds
| Check | Detail |
| --- | --- |
| In a vehicle? | Auto-AFK never fires on foot |
| Switched off? | `/tafk` → **AFK System**. The client logs it at start |
| An interface open? | NUI focus anywhere counts as input |
| Ragdolling? | Auto-AFK is suppressed |
| Timeout zero? | `timeoutSeconds` of `0` disables auto-trigger |
### **Enter AFK Mode** does nothing
It bypasses the timer, not the gates: in a vehicle, system enabled, editor closed, not ragdolling or mid-cutscene, one sequence applying. Each refusal names itself in a toast. No toast *and* no fade is none of these — report it.
### The camera enters, then instantly exits
Something counts as input during the fade: the camera threshold is `0.001°`, so the smallest drift cancels it. With the mouse still, suspect stick drift or a resource moving the camera.
## Sequences
| Symptom | Fix |
| --- | --- |
| Only a few sequences play | Unchecked in the editor, `vehicles` missing your model, or the player opted out. Shots whose camera would clip scenery are also skipped |
| One never plays for others | Scope: **This model only** plays on that model alone, and locks after the first save |
| A hand edit changed nothing | `data.json` is read once, at start. `restart tAFK` |
| A pack's sequences are missing | Manifest needs **both** `tafk_config` and `tafk.json` in `files { }`, keys lowercase; or another resource claimed the model |
A sequence failing validation is dropped with a **server**-console warning and never reaches
clients. Read the server log, not the client.
## Music and beat sync
### No music during the cinematic
| Check | Detail |
| --- | --- |
| Player setting | `/tafk` → **Play Music During AFK** |
| Server default | **Server Defaults** → `useMusic` |
| Volume | `0.04` is very quiet; a player can sit at 0 |
| Any files? | The banner's `Tracks:` row has the count |
| Radio failing? | It replaces the folder, then falls back |
### I added a track and it never plays
`audio/` is scanned at resource start only. `restart tAFK`; `Tracks:` goes up by one.
### Cuts do not land on the beat
No grid for that track yet, so shots take random lengths. Usually just wait — analysis runs in the background from 30 seconds after load. The banner reads `Beats: 39 of 40 analysed, 1 queued`; a changed track reads `changed since it was analysed`. For a better grid, run the offline analyser — [Beat data](/docs/tAFK/configuration#beat-data).
Grids are keyed by sha256, so re-encoding discards the old one — every beat time in it is wrong.
### `radio unavailable (...) — falling back to local tracks`
| Reason | What happened | What to do |
| --- | --- | --- |
| `element` | Mount would not load, or redirected to `http` | Open it in a browser; the setting must be the final `https` URL |
| `silent` | Audio played, analyser got zeroes: no CORS | `curl -I ` for `Access-Control-Allow-Origin`. Absent means no browser can beat-match it |
| `suspended` | The audio context refused to start | Usually transient; if it persists, use local tracks |
| `tap` | The browser audio tap could not start | Report it — this should not happen |
| `context` | No Web Audio at all | As above |
The fallback lasts the session. After fixing the URL or the station, `restart tAFK`.
**Fixed if** the console prints `radio: playing via worklet tap at 48000Hz, 25s behind live`.
### Radio plays but cuts are off the beat
Expect a few unsynced seconds around each track change. If it *never* syncs, raise `radioDelaySeconds` toward 25 — below 15 it cannot stay ahead.
## Editor and permissions
| Symptom | Fix |
| --- | --- |
| **Admin only.** toast | `add_ace group.admin tlib.admin allow`, and put your identifier in `group.admin`. Checked per command, so it applies on the next run |
| **"You must be in a vehicle."** | Get in one |
| **"Exit AFK mode first."** | Press a key to leave the cinematic, then re-run |
| Keys 1–4 do nothing | A text field has focus. Click the viewport first |
### I lost an unsaved sequence
A double-press discards it: **Exit** and a click on another row each warn once, then go through on a second press within four seconds. No recovery — press **4** first.
## Still stuck
Open a ticket in [Discord](https://discord.gg/rsxYTz6tnc) with the **server** console from resource start, the **client** F8 output including any red error, and your tLib and artifact versions.
# tAFK Usage (/docs/tAFK/usage)
| Command | Access | Effect |
| --- | --- | --- |
| `/tafk` | Anyone | The settings dialog |
| `/tafkedit` | `tlib.admin` | The [keyframe editor](/docs/tAFK/editor) |
`/tafkedit` has two preconditions beyond the ACE — **in a vehicle**, **not already AFK** — and toasts the one you tripped.
The single-press toggle is now the **Enter AFK Mode** button at the top of `/tafk`. Repoint any
keybind or help command — `/afk` no longer exists and reports nothing when run.
If your key bindings list two tAFK camera rows, ignore them: `+tafk_orbit` and `+tafk_look` no longer exist.
## How AFK triggers
| Trigger | Gated by | Notes |
| --- | --- | --- |
| **Auto**, after `timeoutSeconds` | In a vehicle, system enabled | Fades to black, then opens |
| **Manual**, **Enter AFK Mode** | In a vehicle, system enabled | Skips the timer, closes the dialog |
### What counts as input
- Position delta over `0.05` units, or heading over `0.5°`
- Camera rotation over `0.001°` — any mouse movement exits
- Any of 12 controls: next camera, the four move axes, WASD, sprint, jump, enter vehicle, attack, aim
- An open interface — NUI focus anywhere, the pause menu, a text box
Auto-AFK is also suppressed while ragdolling and while the editor is open; neither affects **Enter AFK Mode**.
An open interface counts as input, for any UI and with no configuration. A player who leaves one
open and walks away never goes AFK.
## Exit conditions
Any input above, leaving or losing the vehicle, or `IsCutsceneActive()` / `IsPlayerSwitchInProgress()` going true. A key pressed mid-fade aborts entry.
## The `/tafk` dialog
Every control applies live; there is no save button. **Stream URL** is sent once what you typed is a complete `https://` address.
### Settings tab
| Control | Effect |
| --- | --- |
| **Enter / Exit AFK Mode** | Toggles the cinematic, closes the dialog |
| **AFK System** | Persistent master switch; off silences the detector |
| **Play Music During AFK (Mine)** | Your override of the server default |
| **Music Volume (Mine)** | 0–100 % slider, stored as 0.0–1.0 |
| **Hide HUD While AFK (Mine)** | Hides HUD and minimap, restores on exit |
| **Still Camera While AFK** | Holds each shot on one frame; shots still change on the beat |
| **Reset My Settings** | Clears all five `tafk:` keys. Confirms first |
On foot, or with **AFK System** off, **Enter AFK Mode** explains why and leaves the dialog open.
### Sequences tab
One checkbox per sequence: ticked means it stays in your rotation.
It lists global sequences *and* every per-vehicle one, suffixed with its model
(`Hood pass · sultanrs`). Admin-disabled sequences are read-only.
### Admin tab
**Server Defaults** is grouped into **Detection** (idle timeout), **Camera Timing** (min/max duration, beat anchor), **Display** (hide-HUD) and **Audio** (music, volume, **Use Live Radio**, **Stream URL**, **Radio Delay**). Live radio is **off by default**.
Three settings exist in both stores — music, volume and hide-HUD. Your copy is suffixed `(Mine)` on the **Settings** tab, the server's `(Server Default)` on **Server Defaults**, and yours wins.
**Sequence Editor**, an entry in the sidebar, appears only for an admin in a vehicle; all sequence management happens inside the [editor](/docs/tAFK/editor). Leaving the editor puts you back on this dialog.
Drop `.ogg` / `.mp3` / `.wav` files into `tAFK/audio/` and restart — any filename, no
registration. See [Configuration](/docs/tAFK/configuration#music-tracks). **Use Live Radio**
replaces the folder with the local tracks as fallback; **Play Music During AFK** off silences
both.
## Telling other scripts a player is AFK
AFK state sits on a replicated player state bag:
```lua
local isAfk = Player(source).state.afk -- server
local isAfk = Player(targetServerId).state.afk -- client, about another player
```
`Player()` takes a **server** id on both sides. `nil` means they have not loaded tAFK; treat it as "not AFK".
Servers use it to mute AFK players on radio, mark scoreboards, filter dispatch panels and pause paycheque timers. There is also a local `tafk:stateChanged` event and six exports — see the [API reference](/docs/tAFK/api-reference).
# tChirp (/docs/tChirp)

An overview and a setup walkthrough are being recorded for tChirp. These pages are the
complete reference until they land.
When a siren is **park killed** — silenced because the car was put in park while still in pursuit mode — tChirp chirps that car at intervals until someone takes a front seat. It never turns a siren on or off; it watches whichever ELS you run.
Free, MIT, not escrowed. No encrypted file: the source is what you install.
## What it is not
- **Not an ELS.** No lighting, no siren control, no tones of its own.
- **Not a per-player sound.** Everyone near the car hears it.
- **Not a tone library.** Sounds are native GTA names, or a soundset you have.
- **One dependency.** [tLib](/docs/tLib) v1.2.0 or newer, which is free. Nothing else.
# tChirp API reference (/docs/tChirp/api-reference)
Two client exports, two client-side events, two commands. None of it is needed to use tChirp.
## Exports
Both client-side, and both `exports.tChirp`.
| Export | Parameters | Returns | What it does |
| --- | --- | --- | --- |
| `IsChirping` | `vehicle: number` | `boolean` | On the chirp list? Answers from the last list received, not the frame |
| `IsSirenActive` | `vehicle: number` | `boolean` | Siren on, per the owning provider. Respects `Config.sirenSystem` |
`IsSirenActive` reports the **siren**, not the lights and not park-kill state, so a park-killed car returns `false`.
LVC, LVC Fleet, ELS-FiveM and ALS only answer for the vehicle you are in, and asking about another car **suppresses your own park kill**. See [Asking about a vehicle you are not in](/docs/tChirp/configuration#asking-about-a-vehicle-you-are-not-in).
## Events
Local, raised with `TriggerEvent`. Both fire on **every** client, not only the one that parked the car.
| Event | Arguments | When |
| --- | --- | --- |
| `tchirp:armed` | `netId: number` | A vehicle is now on the chirp list |
| `tchirp:cleared` | `netId: number` | A vehicle has left it |
## Network events
Everything the server accepts is [validated against `config.lua`](/docs/tChirp/usage#what-the-server-refuses). Only `AddChirpVehicle` is gated by [`Config.access`](/docs/tChirp/configuration#access).
| Event | Direction | Arguments |
| --- | --- | --- |
| `tchirp:AddChirpVehicle` | client → server | `netId`, `soundCfg: { sound, ref }` |
| `tchirp:RemoveChirpVehicle` | client → server | `netId` |
| `tchirp:RequestChirpList` | client → server | none |
| `tchirp:SyncChirpList` | server → client | `list` keyed by `netId` |
### The `tChirp:` spellings are gone in 2.0.0
Lowercase `tchirp:` is the only form; the verbs are unchanged. Rename every `tChirp:` name in your code: a stale listener never runs, a stale trigger goes nowhere.
Triggering an event nobody registered does nothing, with no console warning. If an integration
stopped at 2.0.0, start here. If you subscribed to both spellings in 1.x, drop the `tChirp:` one.
## Commands
| Command | Who | What |
| --- | --- | --- |
| `/tchirp` | anyone, client-side | Status dialog, plus a Silence button. [Full row list](/docs/tChirp/usage#tchirp) |
| `tchirp_diag` | console, or `command.tchirp_diag` | Version, tLib version and floor, access, provider setting, which of tLS and JLS are running, a note on which of the two chirps when tLS runs alongside tChirp, timing, counts, fresh config check |
`tchirp_diag` is `restricted`: `add_ace group.admin command.tchirp_diag allow`. It reports the configuration **at startup**, not the live table.
# tChirp Configuration (/docs/tChirp/configuration)
Everything is in `config.lua`. Edit the file, restart the resource. tChirp runs with zero edits.
## Access
Who may park-kill a car onto the chirp list. **The default is `everyone`.**
| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `Config.access.mode` | string \| list | `"everyone"` | `everyone`, `ace`, `job`, `item`, `custom`, or a list of them |
| `Config.access.ace` | string | `"tchirp.use"` | For `mode = "ace"` |
| `Config.access.job` | table | `{ police = 0, sheriff = 0, statepolice = 0 }` | **name = minimum grade**; `0` accepts any |
| `Config.access.item` | string | `"police_radio"` | For `mode = "item"` |
| `Config.access.count` | number | `1` | How many of that item |
| `Config.access.custom` | function | `nil` | Takes a player id, returns `true` to allow |
A list passes if **either** entry does. Six frameworks and nine inventories resolve out of the box.
A civilian beside a chirping patrol car hears it, and silencing is accepted from anyone.
## Siren provider
tChirp asks one question: **was the siren on?** The default, `auto`, covers every case below, including two ELS resources on one server.
| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `Config.sirenSystem` | `auto` \| `tels` \| `lvc` \| `lvc_fleet` \| `els_fivem` \| `jls` \| `als` \| `native` | `"auto"` | Which system is asked whether the siren was on |
| `Config.sirenResources` | table | `{}` | Override, per provider, for a folder you renamed yourself |
| System | Read from | Name needed? | Notes |
| --- | --- | --- | --- |
| tLS | `exports[name]:IsSirenActive(vehicle)` | No | `tLS` and `tELS` are both recognised |
| JLS | `exports[name]:IsSirenActive(vehicle)` | No | `Burkhardt_Software_JLS` and `Jace3483_JLS` are both recognised |
| Luxart Vehicle Control | `lvc:UpdateThirdParty` event | No | On when the tone is above zero |
| LVC Fleet | the same event as LVC | No | |
| ELS-FiveM | `els:setSirenState_c` event | No | |
| Advanced Lighting System | the four `ALS:*SirenClient` events | No | **Either** siren counts as on |
| Plain GTA siren | `IsVehicleSirenAudioOn(vehicle)` | No | The fallback when nothing else claims the car |
tLS also has its own park chirp. A car tLS is already chirping is skipped by tChirp, so it chirps once — see [On a tLS car, tLS owns the chirp](/docs/tChirp/troubleshooting#on-a-tls-car-tls-owns-the-chirp).
Only tLS and JLS are asked by export, so they are the only two whose folder name matters — and tChirp knows the names both ship under, current and previous, and uses whichever is running. Fill in `Config.sirenResources` only if you renamed a folder yourself. A name there that is not a started resource is ignored rather than trusted, so an old config pinning a name that has since changed upstream still works.
`IsVehicleSirenOn` sounds like the right native and is not: it reports the siren **switch**, and in GTA that switch is the light bar. A unit parked at a scene with its lights on reads as siren-on, so every exit looked like a park kill. The fallback reads `IsVehicleSirenAudioOn` instead, which is false when the lights are up and the audio is silent. Changed in the current 2.0 build; if you pinned `Config.sirenSystem` to work around the old behaviour, unpin it.
### The cascade order
With `auto`, the first provider that recognises the vehicle answers:
```txt
tels → lvc / lvc_fleet → els_fivem → jls → als → native
```
`Config.sirenSystem = 'tels'` consults that provider only. A vehicle it does not recognise is treated as siren-off and never chirps. Pin only when you run exactly one ELS and would rather a wrong answer be loud.
### Your ELS kills the siren when you get out
Most do, LVC included, and it makes the park kill hard to see because the evidence deletes itself: LVC zeroes its tone the instant you start climbing out and tells tChirp so about a second before you are out of the seat.
tChirp does not believe a siren-off that arrives while you are getting out. That covers LVC, LVC Fleet, ELS-FiveM and ALS, and it means **you do not have to turn your ELS's own park kill off**. A siren you switch off yourself while sitting in the car is still a siren off, and that car will not chirp.
Pinning to `lvc` is not needed and costs you the fallback. `auto` reaches the LVC rung for any car LVC has reported a tone for, and the GTA fallback below it is silent on an LVC car anyway: LVC mutes GTA's own siren audio on the cars it controls, so the fallback cannot false-positive there. In the first 2.0 build, `lvc` could never chirp at all — if that is why you pinned it, unpin it.
### Asking about a vehicle you are not in
LVC, ALS and ELS-FiveM only answer for **the vehicle you are in**. Asking `IsSirenActive` about any other car both gets a useless answer and **suppresses your own park kill**, so do not poll nearby traffic.
### My ELS is not one of these
Nothing claims your vehicles, so every park falls through to the native check, which reads GTA's siren **audio**.
| Symptom | What happened |
| --- | --- |
| Nothing ever chirps | Your ELS plays its own siren sounds and mutes GTA's, so there is no audio for the fallback to find. This is the common case, and it is not fixable from config |
| Every park chirps, siren off | Your ELS leaves GTA's siren audio running after its own siren stops |
Pinning `Config.sirenSystem` to the closest match is the wrong first move: a provider that does not recognise your cars answers "siren off" for all of them, so pinning can turn a resource that chirps too often into one that never chirps. Report your ELS instead and it can be supported directly, as ALS is — what is needed from it is an export or an event that says whether the siren is sounding.
## Chirp timing
| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `Config.chirpMinIntervalMs` | number ≥ 1 | `4000` | Shortest gap between chirps, ms |
| `Config.chirpMaxIntervalMs` | number ≥ 1 | `6000` | Longest gap between chirps, ms |
| `Config.chirpMinDurationMs` | number ≥ 1 | `75` | Shortest chirp, ms |
| `Config.chirpMaxDurationMs` | number ≥ 1 | `125` | Longest chirp, ms |
| `Config.debug` | boolean | `false` | `DEBUG` log level on client and server |
Ranges are inclusive and drawn fresh per chirp. Min equal to max gives a fixed value; min above max is refused at startup; there is no upper bound. `Config.debug` prints a line per park kill, sync, chirp and refusal — leave it off on a live server.
## Vehicle assignments
| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `Config.chirpAssignments` | table | eight base-game police models | Spawn name → the sound that model chirps |
```lua
Config.chirpAssignments = {
['police'] = { sound = 'VEHICLES_HORNS_POLICE_WARNING', ref = 0 },
['police2'] = { sound = 'SIREN_PRIORITY', ref = 'DLC_WMSIRENS_SOUNDSET' },
}
```
`sound` goes to `PlaySoundFromEntity`; `ref` is a soundset name or `0` for these:
| `sound`, with `ref = 0` | What it is |
| --- | --- |
| `VEHICLES_HORNS_POLICE_WARNING` | Short attention chirp. The default |
| `VEHICLES_HORNS_SIREN_1` | Wail |
| `VEHICLES_HORNS_SIREN_2` | Yelp |
| `VEHICLES_HORNS_AMBULANCE_WARNING` | Powercall |
A malformed entry — no `sound`, or a bare number where the table belongs — is reported at startup **by model name**, not skipped.
A model with no entry never chirps. `{}` is a supported "nothing chirps" state, and deleting the key entirely is equivalent.
# tChirp Installation (/docs/tChirp/installation)
One dependency, no database, no NUI, no build step. Nothing is escrow-packed.
## Requirements
| Requirement | Detail |
| --- | --- |
| [tLib](/docs/tLib) | **v1.2.0 or newer**, free. tChirp refuses to start below it |
| A FiveM server | `lua54`, declared by tChirp itself |
| A siren system | tLS, JLS, LVC, LVC Fleet, ELS-FiveM or ALS — or none, and tChirp reads the plain GTA siren |
No siren system needs configuring: tChirp detects all six, and `Config.sirenResources` is only for a folder you renamed yourself — see [Siren provider](/docs/tChirp/configuration#siren-provider).
## Install
### Put the folder in place
Extract into `resources/`. The folder must be named exactly `tChirp`, no version suffix.
### Set the load order
```cfg
ensure tLib
ensure tChirp
```
Wrong order gives `No such export`.
### Check your vehicle list
Nothing chirps unless its model is in [`Config.chirpAssignments`](/docs/tChirp/configuration#vehicle-assignments), which ships with eight base-game police models and is also the on/off switch.
### Optionally, choose who may chirp
`Config.access` ships `mode = "everyone"`, so skipping this changes nothing. Hearing and silencing stay open to everyone whatever you set — see [Access](/docs/tChirp/configuration#access).
### Start it and read the console
```txt
Version: v2.0.0 — up to date
Models: 8 vehicle model(s) configured
Sirens: auto
```
Config problems print **above** the banner, naming the key, what was expected, what was found and the fix. An error stops tChirp starting, leaving no `Models` row.
## Confirm it works
1. Get into a configured vehicle as the driver.
2. Turn the siren on.
3. **Let the ELS park-kill it** — put the car in park and let the siren cut out on its own.
4. Get out and walk a few metres away.
The car chirps within 4–6 seconds and keeps chirping until somebody sits in a front seat.
If nothing happens, run [`/tchirp`](/docs/tChirp/usage#tchirp) in the car: whether the model is configured and which provider answers explains nearly every silent install. Then set `Config.debug` and read [Troubleshooting](/docs/tChirp/troubleshooting).
## Verifying a change without a server
`bun install && bun run test:lua` checks your `config.lua` against tChirp's own test suites.
## Optional: help us fix tChirp
tChirp does not report its own faults to us. When it throws, the error sits in
your console and we never learn it happened unless someone opens a ticket.
One line opts in, in `server.cfg` above `ensure tLib`:
```txt title="server.cfg"
set tlib_telemetry 1
```
That sends errors, warnings, renderer crashes and slow-operation outliers from
our own code. **No IP, no licence key, no server name, no player names or
identifiers**, and `_diag` output is never included. `tlib_telemetry_status`
in the console shows what is on and what decided it.
It is off unless you set it, nothing is gated behind it, and
[Diagnostics](/docs/tLib/telemetry) is the full account of what is and is not sent.
# tChirp Troubleshooting (/docs/tChirp/troubleshooting)
Set `Config.debug = true`, `restart tChirp`, and read which line is **missing**. `tchirp_diag` shows the configuration as read; `/tchirp` names the model and the answering provider.
## Nothing chirps at all
### Does it start?
No `Models` row in the banner means `config.lua` errored and the server half never started. The errors print above it.
### Is the model configured?
`Models` is the size of `Config.chirpAssignments`: `0` means nothing can chirp, `8` means the shipped models. Check your car's **spawn name** is one of them.
### Is the park kill detected?
```txt
[tChirp][DEBUG] park kill — vehicle 12345 (netId 67, sound VEHICLES_HORNS_POLICE_WARNING)
```
No line means the siren was never seen as on: your ELS is not one of the six and leaves no siren audio for the fallback to find ([My ELS is not one of these](/docs/tChirp/configuration#my-els-is-not-one-of-these)); or `Config.sirenSystem` is pinned to a provider that does not own this car; or you killed the siren by hand over 500 ms before getting out.
There was a third cause, fixed in the current 2.0 build: `Config.sirenSystem = 'lvc'` or `'lvc_fleet'` could **never** produce a park kill. LVC's own park kill zeroes its siren tone the instant you start getting out, about a second before you are clear of the seat, so tChirp always re-read the siren as off before it saw the seat empty. It no longer believes a siren-off that arrives while you are climbing out. No shorter poll interval would have helped — the zero always lands first.
### Did the server accept it?
```txt
[tChirp][WARN] player 3 asked for sound "VEHICLES_HORNS_SIREN_1" on netId 67, whose model is assigned "VEHICLES_HORNS_POLICE_WARNING" — refused
```
Client and server disagree about `config.lua`, almost always because only one was restarted — `restart tChirp` does both. Two sibling refusals name a model with no entry, or a sound in none.
### Did the list arrive?
`chirp list synced — 0 vehicle(s)` after a park kill means the add did not land. Look for the refusal above it.
### Are the front seats empty?
Nothing chirps while a front seat is occupied.
## Only some vehicles chirp
A model with no [entry](/docs/tChirp/configuration#vehicle-assignments) never chirps. Otherwise it is a malformed entry, reported at startup by model name — if you copied from the old GitBook page, check for `['police'] = 4`, a bare siren ID no released tChirp reads.
## Every park chirps, even with the siren off
**This was tChirp's own bug, and no config change worked around it.** A vehicle no provider claimed fell through to `IsVehicleSirenOn`, which reports the siren switch — and in GTA that switch is the light bar, so a unit parked at a scene with its lights on read as siren-on and every exit looked like a park kill. The current 2.0 build reads `IsVehicleSirenAudioOn` instead, so re-download it and unpin `Config.sirenSystem` if you pinned it to work around this.
Still happening on the current build means your ELS leaves GTA's own siren audio running after its own siren stops. See [My ELS is not one of these](/docs/tChirp/configuration#my-els-is-not-one-of-these).
## The chirp never stops
A **front** seat clears it; a rear seat does not. If it survives that, the vehicle is gone but its network ID is still listed, and those are swept every 5 seconds.
## Asking for help
Send these, as text rather than a screenshot:
1. **`tchirp_diag`** from the server console: the tChirp and tLib versions, who may chirp, the siren provider setting, which of tLS and JLS are running, the config check, and how many cars are chirping.
2. **The Providers row of `/tchirp`**, read while sitting in the car with its siren on. It is the one thing the server cannot see: whether LVC, ELS-FiveM or ALS ever reach tChirp.
3. **The car's spawn name**, and the line `Will chirp on park` from the same dialog.
4. Whether `Config.sirenSystem` is pinned, and whether the console shows a `park kill` line with `Config.debug = true`.
Take the current build first: it includes the fixes for LVC park kills never chirping and for every car with its lights on chirping on exit.
## On a tLS car, tLS owns the chirp
tLS has its own park chirp: the `park_chirp` rule in its trigger editor. When both are set up for a car, tLS is the one that chirps. Before each chirp tChirp asks tLS whether it is already chirping that car and, if it is, skips its own. Per vehicle:
- **A car with the `park_chirp` rule:** tLS chirps it. tChirp skips every chirp tLS is playing, so the car chirps once.
- **Everything else, including a tLS car with no rule:** tChirp, as before. It still reads tLS as its siren provider.
This needs a tLS that answers `GetLightState`. On an older tLS, or on the old tELS name, tChirp cannot ask and plays as it always did, so leave a car you give tLS's rule out of `Config.chirpAssignments` there. `tchirp_diag` prints a note whenever tLS is running next to tChirp, and the Providers row of `/tchirp` counts the chirps tChirp skipped.
## Errors and config messages
| Message | Cause and fix |
| --- | --- |
| `requires tLib v1.2.0 or newer` | Update tLib |
| `No such export`, or tChirp fails to start | tLib was not started first. `ensure tLib` above `ensure tChirp` |
| `attempt to index a function value` | Same cause, or a tLib too old to have the module tChirp asked for |
| `Config.sirenSystem must be one of ...` | A provider name that does not exist. See [Siren provider](/docs/tChirp/configuration#siren-provider) |
| `chirpMinIntervalMs (...) is greater than chirpMaxIntervalMs (...)` | An inverted range. Unchecked, the chirp thread dies silently |
| `... is not a setting this resource reads` | A warning, not an error. The key is ignored and the default applies |
# tChirp Usage (/docs/tChirp/usage)
No keybind, nothing to operate. `/tchirp` only answers questions.
## What counts as a park kill
All three must be true as a player leaves a vehicle:
1. They were in a **front seat** — driver or front passenger.
2. The vehicle's **siren was on** at the last check before they left.
3. The vehicle's **model is in `Config.chirpAssignments`**.
The siren is sampled every 500 ms, and the exit is judged against the **previous** sample.
A siren switched off by hand and then left within the same 500 ms window counts as a park kill, and nothing can tell the two apart afterwards. When testing, **let the ELS park-kill the siren**.
## The front-seat rule
A front seat — driver or passenger — both arms and clears a chirp, and nothing chirps while one is occupied. The chirp plays from the vehicle, so it fades as you walk away.
## `/tchirp`
Open to anyone, no ACE. Read-only — there is no `/tchirpedit`. Two sidebar entries: **Status**, below, and **Feedback**, which sends one message to TIMMYG Studios rather than to this server's staff.
| Row | Answers |
| --- | --- |
| Will chirp on park | Has this car an entry, and which sound. With none it prints the model hash |
| Siren right now | On or off, **and which provider answered** |
| Chirping now | How many vehicles are on the list server-wide, as last heard |
| Providers | tLS and JLS: whether their resource is running, and under which name. LVC, ELS-FiveM and ALS: how many times they have sent tChirp their state. **Never heard** after sitting in a car with its siren on means that system is not installed, or does not send the event tChirp listens for. **Skipped N chirps tLS was already playing** counts the chirps tChirp left to tLS |
| Silence … *N*m away | The one action. Only when something is chirping within 50 m |
| Provider · *N* models configured | The provider and timing from `config.lua` |
Every row above is on **Status**. The assignment key is the **spawn** name. On foot the first two rows become **Not in a vehicle**. **Silence** takes the nearest chirping car off the list, the same as someone getting in.
## What the server refuses
The server re-checks every park kill against its own `config.lua`:
| When the server can | It requires |
| --- | --- |
| see the vehicle and its model | **exactly** the tone that model is assigned. Another configured tone is refused, not corrected |
| see the vehicle, whose model has no assignment | nothing — refused outright |
| not see the vehicle at all | a tone this server has configured somewhere |
Both events are rate-limited at 12 per 10 seconds per player.
A removal is accepted from any player. The worst a forged one does is stop a chirp early.
## Cleanup
Entries whose vehicle no longer exists are swept every 5 seconds, after a 5-second grace period. Stopping the resource releases every sound.
# tDB (/docs/tDB)

tDB answers every oxmysql export, translates MySQL SQL to SQLite as it goes, and runs an
embedded [PocketBase](https://pocketbase.io/) underneath. No MySQL to install, no connection
string, no port to open, nothing to keep running alongside it.
```lua
-- Existing oxmysql code. Unchanged.
local row = exports.oxmysql:single_async('SELECT * FROM players WHERE citizenid = ?', { cid })
```
## What it is not
- **Not a MySQL server.** SQL is translated to SQLite, and a few constructs are refused —
see [MySQL compatibility](/docs/tDB/mysql-compatibility).
- **Not a drop-in for a database you already have data in.** tDB starts empty; moving an
existing MySQL database across is a migration, not a swap.
- **Not something to run next to oxmysql.** Remove oxmysql.
## Requirements
| Requirement | Detail |
| --- | --- |
| tLib | **v1.0 or later.** tDB declares `tlib_min_version '1.0'` and will not start without it |
| Platform | **Windows or Linux, x86-64.** The bundled PocketBase builds are `windows_amd64` and `linux_amd64`; there is no ARM build |
| FiveM artifact | New enough for Node 22, which the manifest declares as `node_version '22'` |
| Framework | None |
| OneSync | Not required |
## Credits and licence
tDB bundles [PocketBase](https://github.com/pocketbase/pocketbase) (MIT, Gani Georgiev) and
the Polyglot SQL transpiler `@polyglot-sql/sdk` (MIT, TobiLG) as WebAssembly. tDB itself is
MIT; see `LICENSE.md` in the repository.
# tDB API reference (/docs/tDB/api-reference)
Every name below is reachable as `exports.tDB:`, `exports.oxmysql:`,
`exports['mysql-async']:` and `exports.ghmattimysql:`.
Exports marked **async** return a promise: use the `_async` name, or `Citizen.Await`.
You only see FiveM's "no such export" if the calling resource is `ensure`d **above** tDB.
See [Readiness](#readiness).
## Readiness
| Export | Parameters | Returns | Async |
| --- | --- | --- | --- |
| `isReady` | none | boolean | no |
| `onReady` | `callback` | nil. Fires immediately if already ready, else queues | no |
| `isClientAuthenticated` | none | boolean, live rather than the boot result | no |
| `getUrl` | none | string base URL, or nil before ready | no |
| `awaitConnection` | none | true | yes |
A record or collection call made too early can still throw `PocketBase client not ready yet`.
Wrap the first one:
```lua
exports.tDB:onReady(function()
local players = exports.tDB:getFullList('players')
end)
```
## oxmysql exports
Each base name is registered three times: `name`, `name_async` and `nameSync`. **All three
behave identically.**
Accepted call shapes: `(sql)`, `(sql, params)`, `(sql, callback)`, `(sql, params, callback)`.
With a callback the export returns nothing and invokes it; without one it returns a promise.
| Export | Returns |
| --- | --- |
| `query` | array of rows |
| `execute` | array of rows. **Alias of `query`** |
| `fetch` | array of rows. **Alias of `query`** |
| `single` | first row, or nil |
| `scalar` | first column of the first row, or nil |
| `insert` | the new row's id |
| `update` | affected row count |
| `prepare` | one result per parameter set; a single set returns bare, and a callback unwraps a one-column row to the value |
| `rawExecute` | as `prepare`, without the unwrapping |
| `transaction` | true, or **false** if it rolled back. Never throws |
| `store` | the query string unchanged. Synchronous, and works before readiness |
### mysql-async aliases
| Alias | Behaves as | Returns |
| --- | --- | --- |
| `mysql_execute` | `update` | **affected row count** |
| `mysql_insert` | `insert` | insert id |
| `mysql_fetch_all` | `query` | rows |
| `mysql_fetch_scalar` | `scalar` | scalar |
| `mysql_transaction` | `transaction` | true/false |
| `mysql_store` | `store` | the query |
`exports.oxmysql:execute` returns rows, matching oxmysql. `mysql_execute` and
`MySQL.Sync.execute` return an affected row count, matching mysql-async. Check which name
your script calls before reading its result.
### Query cache
Off by default. When on, row queries are cached and any write through tDB clears the cache.
| Export | Parameters | Returns |
| --- | --- | --- |
| `enableCache` | `ttl = 60000`, `maxSize = 100` | true |
| `disableCache` | none | true, and clears |
| `invalidateCache` | `pattern?`: substring match on the key; omit to clear all | true |
| `setSlowQueryThreshold` | `ms`: 0 disables the warning; default 150 | true |
## `lib/MySQL.lua`
Add `server_script '@tDB/lib/MySQL.lua'` to your `fxmanifest.lua`. Every entry has an
`.await` form and a callable callback form, and waits for the database before dispatching,
so a script querying during its own startup gets rows.
| Entry | Returns |
| --- | --- |
| `MySQL.query` | rows |
| `MySQL.single` | row or nil |
| `MySQL.scalar` | value |
| `MySQL.insert` | insert id |
| `MySQL.update` | affected rows |
| `MySQL.execute` | **rows** (alias of query) |
| `MySQL.fetch` | rows |
| `MySQL.prepare` | per-set results |
| `MySQL.rawExecute` | raw result |
| `MySQL.transaction` | true/false |
```lua
local rows = MySQL.query.await('SELECT * FROM players')
local id = MySQL.insert.await('INSERT INTO logs (msg) VALUES (?)', { 'joined' })
MySQL.ready(function() print('database up') end)
```
Legacy namespaces: `MySQL.Sync.execute` (affected rows), `MySQL.Sync.insert`,
`MySQL.Sync.fetchAll`, `MySQL.Sync.fetchSingle`, `MySQL.Sync.fetchScalar`,
`MySQL.Sync.transaction`, `MySQL.Sync.prepare`, and the matching `MySQL.Async.*` callback
forms. Also `MySQL.ready`, `MySQL.isReady`, `MySQL.awaitConnection` and `MySQL.store`.
There is no `MySQL.Sync.rawExecute`; use `MySQL.rawExecute.await`. The library also
hardcodes the resource name `tDB`, so renaming the folder breaks it.
## Records
| Export | Parameters | Returns | Async |
| --- | --- | --- | --- |
| `create` | `collection`, `data`, `options?` | created record | yes |
| `update` | `collection`, `id`, `data`, `options?` | updated record | yes |
| `delete` | `collection`, `id?`, `options?` | true | yes |
| `getOne` | `collection`, `id`, `options?` | record. **Throws on 404** | yes |
| `getList` | `collection`, `page = 1`, `perPage = 30`, `options?` | `{ page, perPage, totalItems, totalPages, items }` | yes |
| `getFullList` | `collection`, `options?` | array of records | yes |
| `getFirstListItem` | `collection`, `filter`, `options?` | record. **Throws on 404** | yes |
| `findRecordsByIds` | `collection`, `ids` | array of records | yes |
| `countRecords` | `collection`, `filter?`, `params?` | number | yes |
| `filter` | `rawFilter`, `params?` | escaped filter string | no |
Pass SQL as the first argument to `update` or `delete` and the call goes down the oxmysql
path instead.
Build every filter with `filter()`, so values are bound rather than interpolated into the
string:
```lua
local f = exports.tDB:filter('score > {:min} && banned = {:banned}', { min = 100, banned = false })
local top = exports.tDB:getFullList('players', { filter = f })
local one = exports.tDB:getFirstListItem('players', f)
```
## Collections
| Export | Parameters | Returns | Async |
| --- | --- | --- | --- |
| `getCollections` | `options?` | array | yes |
| `getCollection` | `idOrName`, `options?` | collection | yes |
| `createCollection` | `data`, `options?` | collection | yes |
| `updateCollection` | `idOrName`, `data`, `options?` | collection | yes |
| `deleteCollection` | `idOrName`, `options?` | true | yes |
| `truncateCollection` | `idOrName`, `options?` | true | yes |
| `importCollections` | `collections` (table or JSON string), `deleteMissing = false`, `options?` | true | yes |
| `getCollectionScaffolds` | `options?` | scaffold map | yes |
| `createMigrationHelper` | none | table of `createCollection`, `updateCollection`, `deleteCollection` closures | no |
```lua
exports.tDB:createCollection({
name = 'players',
type = 'base',
fields = {
{ name = 'username', type = 'text', required = true },
{ name = 'score', type = 'number' },
{ name = 'banned', type = 'bool' },
},
})
```
## Realtime
| Export | Parameters | Returns | Async |
| --- | --- | --- | --- |
| `subscribe` | `collection`, `topic`, `callback?` | true | yes |
| `unsubscribe` | `collection`, `topic?`: omit to drop all for the collection | true | yes |
| `subscribeToTopic` | `topic`, `callback?` | true | yes |
| `unsubscribeFromTopic` | `topic` | true | yes |
| `unsubscribeByPrefix` | `topicPrefix` | true | yes |
| `isRealtimeConnected` | none | boolean | no |
| `sendRealtimeMessage` | `topic`, `data` | number of clients sent to | yes |
| `getRealtimeClients` | none | array of `{ id, authenticated, authId }` | yes |
Subscribe, then handle the event tDB raises. The name is
`pocketbase::` for a collection and `pocketbase:topic:` for a
custom one:
```lua
exports.tDB:subscribe('bans', '*')
AddEventHandler('pocketbase:bans:*', function(data)
if data.action == 'create' then print(data.record.id) end
end)
```
## Transactions and batches
| Export | Parameters | Returns | Async |
| --- | --- | --- | --- |
| `runTransaction` | `operations`: `{ type = "create"\|"update"\|"delete", collection, id?, data? }` | array: `{ id }` per create/update, `{ deleted = true }` per delete | yes |
| `batch` | none | batch handle | no |
| `batchCreate` | `batch`, `collection`, `data`, `options?` | the handle, chainable | no |
| `batchUpdate` | `batch`, `collection`, `id`, `data`, `options?` | the handle | no |
| `batchDelete` | `batch`, `collection`, `id`, `options?` | the handle | no |
| `batchUpsert` | `batch`, `collection`, `data`, `options?` | the handle | no |
| `batchSend` | `batch` | batch result array | yes |
`runTransaction` runs inside a real database transaction and needs no setting. The `batch*`
exports are PocketBase's batch API and must be enabled in **Admin → Settings → Batch API**
first.
## Raw SQL
The same database the oxmysql exports use, with `{:name}` placeholders and no MySQL
translation — write SQLite here. All async.
| Export | Parameters | Returns |
| --- | --- | --- |
| `sqlQuery` | `sql`, `params?` | array of rows |
| `sqlSingle` | `sql`, `params?` | first row, or nil |
| `sqlScalar` | `sql`, `params?`, `columnName?` | the value, or nil |
| `sqlExecute` | `sql`, `params?` | insert id only |
| `sqlTransaction` | `queries`: `{ sql, params?, expect? }` | true; throws and rolls back the whole batch on failure |
Integers arrive as numbers and `NULL` arrives as `nil`, not an empty string.
```lua
local row = exports.tDB:sqlSingle('SELECT * FROM players WHERE id = {:id}', { id = 1 })
exports.tDB:sqlTransaction({
{ sql = 'UPDATE accounts SET balance = balance - {:n} WHERE id = {:a}', params = { n = 100, a = 'a' } },
{ sql = 'UPDATE accounts SET balance = balance + {:n} WHERE id = {:b}', params = { n = 100, b = 'b' } },
})
```
## Auth
All async. Every one takes the auth collection name first.
| Export | Parameters | Returns |
| --- | --- | --- |
| `listAuthMethods` | `collection`, `options?` | auth methods |
| `authWithPassword` | `collection`, `usernameOrEmail`, `password`, `options?` | `{ token, record }` |
| `authCollectionWithPassword` | same | `{ token, record }` |
| `authWithOTP` | `collection`, `otpId`, `password`, `options?` | `{ token, record }` |
| `authWithOAuth2Code` | `collection`, `provider`, `code`, `codeVerifier`, `redirectURL`, `createData?`, `options?` | `{ token, record }` |
| `authRefresh` / `authRefreshCollection` | `collection`, `options?` | `{ token, record }` |
| `requestOTP` | `collection`, `email`, `options?` | `{ otpId }` |
| `requestPasswordReset` | `collection`, `email`, `options?` | true |
| `confirmPasswordReset` | `collection`, `token`, `password`, `passwordConfirm`, `options?` | true |
| `requestVerification` | `collection`, `email`, `options?` | true |
| `confirmVerification` | `collection`, `token`, `options?` | true |
| `requestEmailChange` | `collection`, `newEmail`, `options?` | true |
| `confirmEmailChange` | `collection`, `token`, `password`, `options?` | true |
| `listExternalAuths` | `collection`, `recordId`, `options?` | array |
| `unlinkExternalAuth` | `collection`, `recordId`, `provider`, `options?` | true |
## Files and mail
| Export | Parameters | Returns | Async |
| --- | --- | --- | --- |
| `getFileUrl` | `record`, `filename`, `options?` | URL string | no |
| `getFileToken` | `options?` | token string | yes |
| `sendEmail` | `to` (string or array), `subject`, `html`, `text?` | true | yes |
`sendEmail` needs mail configured in the admin UI — see [Mail](/docs/tDB/configuration#mail).
## Commands
Server console only, all gated on the `command.tdb` ACE. See
[Importing `.sql` files](/docs/tDB/sql-imports#commands) for what each does in full.
| Command | Notes |
| --- | --- |
| `tdb sql status` | Every `.sql` file with its recorded state, plus ledger rows whose file is gone |
| `tdb sql import ` | Applies one file now |
| `tdb sql import --force` | `--force` is recognised anywhere in the arguments |
| `tdb sql tables [match]` | Every table with its row count, optionally filtered by substring |
| `tdb sql query ` | Runs a read query and prints the rows, 50 at a time |
| `tdb sql plan` | Which tables would be handed to PocketBase, and how each id is handled |
| `tdb sql adopt` | Hands them over now, after taking a backup |
Anything else prints
`usage: tdb sql status | import [--force] | tables [match] | query | plan | adopt`.
Before the database is ready, every subcommand prints
`not ready yet - wait for the startup banner`.
## Events
All server-local. Use `AddEventHandler`.
| Event | Payload |
| --- | --- |
| `pocketbase::` | `{ action = "create"\|"update"\|"delete", record }` |
| `pocketbase:topic:` | whatever was published to the topic |
| `tdb:startupStatus` | a JSON string: the startup box rows, as `{ key, value, color }` |
## Version facts
| Fact | Value |
| --- | --- |
| Resource version | `1.0.0` |
| PocketBase | `0.40.4`, fetched and checksum-verified into `.runtime/` |
| tLib minimum | `1.0` (`tlib_min_version`) |
| Node | `node_version '22'` |
| Provides | `oxmysql`, `mysql-async`, `ghmattimysql` |
| Platforms | `windows_amd64`, `linux_amd64` |
# tDB Configuration (/docs/tDB/configuration)
Everything lives in `config.lua`, in the resource folder. Most servers change nothing.
## Where a credential comes from
Every credential-shaped key in `config.lua` ships blank and should stay blank, so the file
is safe to commit and safe to paste. Three places supply a real value, first one set wins:
| | Where | Set it by |
| --- | --- | --- |
| 1 | a server convar | `set tdb_superuser_password "…"` in `server.cfg` |
| 2 | `config.local.lua` | editing that file; it is gitignored and never packaged |
| 3 | `config.lua` | nothing — it ships blank and stays blank |
The convar name is `tdb_`, then the option's path with dots as underscores, lowercased:
`Config.Superuser.Password` is `tdb_superuser_password`, `Config.Advanced.S3.SecretKey` is
`tdb_advanced_s3_secretkey`.
A convar overrides a password tDB generated earlier.
`config.local.lua` is where tDB stores the password it generates, and is also yours to
edit. It uses `config.lua` syntax and needs only the keys you override:
```lua title="config.local.lua"
Config = Config or {}
Config.Superuser = {
Email = "admin@localhost.local",
Password = "…",
}
```
## Top level
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `Config.ExposeAdmin` | boolean | `true` | Publish the admin UI at `/tDB/` through tLib. `false` keeps the database headless and unreachable from outside the machine |
| `Config.ShowInHub` | boolean | `true` | List the admin UI in tLib's hub. Cosmetic only, [not a security control](#hiding-it-from-the-hub) |
| `Config.Debug` | boolean | `false` | Print tDB's debug lines. Off, a normal boot prints the startup box and nothing else |
| `Config.AutoUpdate` | boolean | `false` | Run `pocketbase update` on start, replacing the shipped build with an unverified newer one under a live database |
### The admin UI
On by default, and there is nothing to open or configure. It is at
`http://:/tDB/` — your FiveM server port, the one players already
connect through, 30120 on a default install — and the path is case-insensitive. Sign in with `Config.Superuser`. For a headless
database, set `Config.ExposeAdmin = false`.
PocketBase's own port is internal: never open or forward it.
tLib's own listener is an optional second door, serving the panel at the same path on port
`7777`. Take it if you need PocketBase's realtime subscriptions, which are server-sent events
and cannot travel over the FiveM server port, or a custom domain. Its settings —
`tlib_http_port` and `tlib_http_public_url` — are in
[tLib's convar reference](https://timmygstudios.com/docs/tLib/convars#http-router), and the
procedure is [tLib's advanced listener guide](https://timmygstudios.com/docs/tLib/installation#advanced-tlibs-own-listener).
If the startup box says **Waiting for tLib's HTTP listener**, tLib's router is not up yet
and tDB publishes the admin URL as soon as it is. The database itself works throughout.
## Superuser
```lua title="config.lua"
Config.Superuser = { Email = "", Password = "" }
```
Leave these blank. To pin a login you already have:
```txt title="server.cfg"
set tdb_superuser_email "admin@example.com"
set tdb_superuser_password "…"
```
With neither convar set, tDB generates both on first start and writes them into
`config.local.lua`. The generated password prints in the console **once**, on the run that
creates it, and is redacted on every start after.
Both the convar and `config.local.lua` hold the superuser password unencrypted. Keep
`server.cfg` and `config.local.lua` off shared hosting panels. To rotate: delete the pair
from `config.local.lua`, unset the convars, restart.
## Backups
```lua title="config.lua"
Config.Backup = {
Enabled = false,
OnStartup = true,
ScheduleSeconds = 0,
KeepLast = 7,
BackupPrefix = "auto_",
}
```
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `Enabled` | boolean | `false` | Master switch for automatic backups |
| `OnStartup` | boolean | `true` | Back up before each start |
| `ScheduleSeconds` | number | `0` | Seconds between backups. `0` disables the timer. Renamed from `Schedule` in 1.0; the old name works and warns until 2.0 |
| `KeepLast` | number | `7` | How many automatic backups to retain. `0` keeps all |
| `BackupPrefix` | string | `"auto_"` | Prefix identifying tDB's own backups, so manual ones are never pruned |
Backups land in the PocketBase data directory under `backups`.
## SQL imports
```lua title="config.lua"
Config.Sql = { Enabled = true, Dir = "sql", OnChanged = "warn" }
```
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `Enabled` | boolean | `true` | Apply `.sql` files from `Dir` on startup |
| `Dir` | string | `"sql"` | Relative to the resource, or an absolute path |
| `OnChanged` | string | `"warn"` | What to do when a file changes after it was applied: `"warn"`, `"error"` or `"apply"` |
`warn` and `error` differ only in log level and neither re-runs the file. `apply` re-runs
it, replaying every `INSERT` it contains, so it suits pure DDL dumps only. Full behaviour is
on [Importing `.sql` files](/docs/tDB/sql-imports).
## Migrations
```lua title="config.lua"
Config.Migrations = { AutoApply = true, Dir = ".runtime/pb_migrations" }
```
PocketBase's own collection migrations, not the `.sql` drop folder. A migration file is
written whenever you change a collection in the admin UI, so schema changes travel with the
resource.
## Advanced
```lua title="config.lua"
Config.Advanced = {
RemoteHost = "",
RemotePort = "",
Dev = false,
AutoMigrate = true,
PublicDir = "pb_public",
DataDir = ".runtime/pb_data",
}
```
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `RemoteHost` | string | `""` | Hostname of a PocketBase you already run. See [Local or remote](#local-or-remote) |
| `RemotePort` | string | `""` | Port of that instance. Both must be set together |
| `Dev` | boolean | `false` | Run PocketBase with verbose logging |
| `AutoMigrate` | boolean | `true` | Let PocketBase write a migration when a collection changes |
| `PublicDir` | string | `"pb_public"` | Directory served as static files, relative to the resource |
| `DataDir` | string | `".runtime/pb_data"` | Where the database and backups live, relative to the resource |
Changing it points PocketBase at a new, empty directory. Stop the server, move the
existing folder yourself, then change the key.
### Local or remote
By default tDB starts and manages its own PocketBase on `127.0.0.1`. To point it at an
instance you already run, set both keys:
```lua title="config.lua"
Config.Advanced = { RemoteHost = "db.example.com", RemotePort = "8090" }
```
In remote mode no local process starts, and `Migrations`, `Backup` and `S3` are ignored.
## Mail
Mail is configured in the PocketBase admin UI, under **Settings → Mail**. There is no SMTP
block in `config.lua`.
## S3
```lua title="config.lua"
Config.Advanced = {
S3 = {
Manage = false, Enabled = false,
Bucket = "", Region = "", Endpoint = "",
AccessKey = "", SecretKey = "", ForcePathStyle = false,
},
}
```
`Manage` decides who owns the setting:
| State | Behaviour |
| --- | --- |
| `Manage = false` (default) | tDB never touches it. Set it in the admin UI and it stays as you left it. Everything else in the block is ignored |
| `Manage = true`, `Enabled = true` | `config.lua` is the truth. Every field is applied on every start, secrets included. An admin-UI edit is reported, then overwritten |
| `Manage = true`, `Enabled = false` | `config.lua` is still the truth, and the truth is "off". Genuinely disables it |
Settings only travel `config.lua` → PocketBase. For `Manage = true`, supply the keys as
`tdb_advanced_s3_accesskey` and `tdb_advanced_s3_secretkey` and leave the `config.lua`
fields blank.
## Hiding it from the hub
```lua title="config.lua"
Config.ShowInHub = false -- default: true
```
It removes the hub entry and nothing else. `/tDB/` still answers to anyone who requests it.
For genuine unreachability use `Config.ExposeAdmin = false`.
# tDB Installation (/docs/tDB/installation)
Prerequisites: a FiveM server on Windows or Linux x86-64,
[tLib](https://github.com/tommy141x/tLib/releases) **v1.0 or later** `ensure`d before tDB,
and no other database resource running — see [Replace oxmysql](#replace-oxmysql).
### Install tLib
Extract the [tLib release zip](https://github.com/tommy141x/tLib/releases) into
`resources/`. tDB fails to start without it.
### Extract tDB
Put the folder in `resources/` and keep the name `tDB`. A rename breaks the `@tDB/...`
paths other resources use.
FTP clients in ASCII mode corrupt the PocketBase binary and the WebAssembly transpiler
without changing their size. Move the `.zip` across and unzip it there, or use SFTP in
binary mode.
### Add it to server.cfg
tDB must start before anything that queries the database.
```txt title="server.cfg"
ensure tLib
ensure tDB
```
### Start the server
On first start tDB creates a superuser and writes the credentials into `config.local.lua`.
**Copy the superuser password out of that first startup box.** It is shown once, on the run
that generates it, and redacted afterwards. It is also in `config.local.lua`, which is
gitignored and must stay that way. To pin your own login instead, set
`tdb_superuser_email` and `tdb_superuser_password` in `server.cfg` — see
[Configuration](/docs/tDB/configuration#where-a-credential-comes-from).
You are done when the startup box reports the database ready and prints an admin URL. If it
says **Waiting for tLib's HTTP listener**, that is not an error — see
[the admin UI](/docs/tDB/configuration#the-admin-ui).
## The admin panel in a browser
**Already working, with nothing to configure.** The panel is served on the FiveM server
port — the one your players connect through:
```txt
http://:/tDB/
```
Your server port is whatever `endpoint_add_tcp` declares — 30120 on a default install. tDB
prints the address in its startup box. The path is case-insensitive, so `/tdb/` works
too, and tLib's hub at `/tLib/` links it. PocketBase's own port is internal and is
never the one to forward.
`Config.ExposeAdmin = false` keeps the database headless instead. The database itself works
either way — queries, migrations and every export run over the server, with no port involved.
### One thing this door cannot do
**PocketBase realtime subscriptions do not work over it.** They are server-sent events, which
the FiveM server port cannot carry. The admin UI and the REST API are unaffected.
If you need realtime, or a custom domain, use tLib's own listener instead: an optional second
door on port `7777` that has to be opened by hand, serving the panel at the same path,
`:7777/tDB/`. The whole procedure — the port, `tlib_http_public_url` and the reverse-proxy
notes — is [tLib's advanced listener guide](https://timmygstudios.com/docs/tLib/installation#advanced-tlibs-own-listener).
Its older `/db` address still answers there, with a permanent redirect.
## Replace oxmysql
1. Remove `oxmysql` from `server.cfg`. tDB answers the `oxmysql`, `mysql-async` and
`ghmattimysql` export names too, so `exports.oxmysql:...` resolves to tDB with no script
edits.
2. Change any file reference: `server_script '@oxmysql/lib/MySQL.lua'` becomes
`server_script '@tDB/lib/MySQL.lua'`. Scripts that only call `exports.oxmysql` need no
change.
3. If a script ships a `.sql` dump, drop it in `tDB/sql/` rather than loading it by hand —
see [Importing `.sql` files](/docs/tDB/sql-imports).
They answer the same export name and point at two different databases. Remove one.
## Working from a git clone
A release download contains the PocketBase binary; a source checkout does not, so fetch it
once:
```bash
bun scripts/fetch-runtime.ts # this platform
bun scripts/fetch-runtime.ts --all # both, for building a release
```
Change `PB_VERSION` at the top of that script to move to a different release.
## Optional: help us fix tDB
tDB does not report its own faults to us. When it throws on your server the
error sits in your console, and unless someone opens a ticket we never learn it
happened — which means the bugs nobody reports are the ones that stay.
One line opts in, in `server.cfg` above `ensure tLib`:
```txt title="server.cfg"
set tlib_telemetry 1
```
That sends errors, warnings, renderer crashes and slow-operation outliers from
our own code. **No IP, no licence key, no server name, no player names or
identifiers**, and `_diag` output is never included. `tlib_telemetry_status`
in the console shows what is on and what decided it.
It is off unless you set it, nothing is gated behind it, and
[Diagnostics](/docs/tLib/telemetry) is the full account of what is and is not sent.
# tDB MySQL compatibility (/docs/tDB/mysql-compatibility)
tDB stores data in SQLite and translates MySQL SQL on the way in. Anything it cannot
translate raises an error naming the construct.
## Translated for you
| MySQL | Becomes |
| --- | --- |
| `ON DUPLICATE KEY UPDATE` | `ON CONFLICT (...) DO UPDATE` |
| `AUTO_INCREMENT`, `ENGINE=`, `DEFAULT CHARSET=` | dropped |
| inline `KEY` / `UNIQUE KEY` in `CREATE TABLE` | separate `CREATE INDEX` statements |
| `ON UPDATE CURRENT_TIMESTAMP` | a trigger |
| `DELETE ... LIMIT`, `LIMIT offset, count` | SQLite's forms |
| backticks, `IF()`, `IFNULL()`, `CONCAT()`, `NOW()`, `UNIX_TIMESTAMP()` | SQLite equivalents |
| `MATCH (a, b) AGAINST (? IN BOOLEAN MODE)` | a substring search — see [the approximation](#full-text-search-is-approximated) |
| `ALTER TABLE … MODIFY`/`CHANGE COLUMN`, `ADD FOREIGN KEY` | the table is rebuilt |
| `SET @v := (SELECT IF(…))` + `PREPARE`/`EXECUTE` | the condition is evaluated and the chosen branch runs |
| `CREATE PROCEDURE … IF NOT EXISTS … END IF` + `CALL` | the same |
| `SIGNAL SQLSTATE '…' SET MESSAGE_TEXT = 'x'` (in a trigger) | `SELECT RAISE(ABORT, 'x')` |
| `UPDATE a JOIN b ON … SET …`, multi-table `DELETE` | an `EXISTS` subquery |
| `IN (?)` with an array, `VALUES ?` with rows | expanded into a list |
| `DATABASE()`, `SCHEMA()` | `'main'` |
| `VERSION()` | `sqlite_version()`, so a script gating on MariaDB takes its not-MariaDB branch |
| `INT UNSIGNED ... AUTO_INCREMENT` | `INTEGER ... AUTOINCREMENT` |
| `AUTO_INCREMENT` on a column of a composite `PRIMARY KEY` | the key narrows to that column; the wider key becomes a separate index |
| `IF c THEN a; ELSE b; END IF;` in a trigger | two triggers with `WHEN` guards |
| `DECLARE v; SELECT e INTO v; ... v ...` | a correlated subquery, when the variable is assigned once and read |
| `UPDATE t JOIN u ON c SET a` in a trigger | `UPDATE t SET a FROM u WHERE c` |
| `CREATE TRIGGER IF NOT EXISTS` | kept verbatim |
## Full-text search is approximated
`MATCH … AGAINST` becomes a substring search across the same columns —
`a LIKE '%'||?||'%' OR b LIKE …`. This is an approximation, not an equivalence:
- **No relevance ranking.** A `MATCH` with no `ORDER BY` of its own comes back in an
arbitrary order.
- **`BOOLEAN MODE` operators are taken literally.** `+john` looks for the text `+john`, and
`john*` for `john*`.
- **It is more permissive than MySQL.** MySQL applies a minimum token length
(`innodb_ft_min_token_size`, 3 by default), so a two-character search returns nothing
there and does return rows here.
## Case-insensitive text
tDB creates text columns `COLLATE NOCASE`, so comparisons ignore case as they do in MySQL:
```sql
-- finds a row stored as 'license:ab12'
SELECT * FROM players WHERE license = 'LICENSE:AB12'
```
A `UNIQUE` key likewise rejects the same value in another case. A column declared `BINARY`,
or with a `_bin` or `_cs` collation, stays byte-exact.
## Refused by name
These raise rather than being approximated:
`DATE_ADD`, `DATE_SUB`, `INTERVAL`, `STRAIGHT_JOIN`, `SQL_CALC_FOUND_ROWS`,
`GROUP_CONCAT ... SEPARATOR`, `INFORMATION_SCHEMA`, `ALTER TABLE ... DROP FOREIGN KEY`,
`DECLARE`, `SELECT ... INTO`, `UPDATE ... JOIN`
Rewrite the statement, or move it to [raw SQL](/docs/tDB/api-reference#raw-sql) and write
SQLite directly. Replacements for the ones that come up most:
| Refused | Write instead |
| --- | --- |
| `INFORMATION_SCHEMA` | `sqlite_master` and the `pragma_*` table functions |
| `DROP FOREIGN KEY` | rebuild the table without the constraint |
| `DECLARE`, `SELECT ... INTO` | a scalar subquery |
| `UPDATE ... JOIN` | `UPDATE t SET a FROM u WHERE c`, or `WHERE ... IN (SELECT ...)` |
## Known limits
- **`COLLATE NOCASE` folds ASCII only.** `Ä` and `ä` still compare as different; MySQL's
`general_ci` folds them.
- **Collation is applied when a table is created.** A table predating tDB keeps binary
collation until it is recreated.
- **`RETURNING` is not supported** through the query path.
- **SQLite type affinity is looser than MySQL's.** A column declared `INT` accepts a string,
so statements relying on MySQL rejecting bad input will not be rejected here.
# tDB Importing .sql files (/docs/tDB/sql-imports)
Scripts ship a `.sql` dump and expect you to load it into MySQL by hand. There is no MySQL
here, so put the file in `tDB/sql/` and restart instead.
```txt
sql/
01-qb-core.sql
02-qb-inventory.sql
03-my-shop.sql
```
Files run in filename order on startup, before tDB reports ready, so anything waiting on
`awaitConnection` finds its tables already there. Number them only when one depends on
another.
## What to expect
- **A file runs once, ever.** What has run is recorded in the `tdb_sql_imports` table.
- **A failure does not stop the server.** The file, line and statement are reported, nothing
is applied, and it is retried on the next restart.
- **A file edited after it ran is reported, not re-run.**
- **A trigger tDB cannot translate is skipped, not fatal.** The file still applies and the
status becomes `PARTIAL` — see [Skipped triggers](#skipped-triggers).
- **mysqldump session noise is ignored:** `SET NAMES`, `LOCK TABLES`,
`/*!40000 ALTER TABLE ... DISABLE KEYS */`, `START TRANSACTION` and friends.
## Changing a file after it has run
tDB tells you but will not re-run it, because replaying a dump replays its `INSERT`s.
`Config.Sql.OnChanged` decides how loudly: `"warn"` and `"error"` differ only in log level
and neither re-runs; `"apply"` re-runs it, which suits pure DDL dumps only.
To replay one file on demand:
```txt
tdb sql import 01-qb-core.sql --force
```
## Commands
Server console only. A player with the `command.tdb` ACE still gets nothing back.
| Command | What it does |
| --- | --- |
| `tdb sql status` | Every `.sql` file with its state: `PENDING`, or its recorded status (`APPLIED`, `PARTIAL`, `FAILED`) with statement count and duration. Flags files changed since they ran, and ledger rows whose file is gone |
| `tdb sql import ` | Applies one file now. Refuses if it already ran or has changed |
| `tdb sql import --force` | Applies it again regardless |
| `tdb sql tables [match]` | Every table with its row count, optionally filtered by substring |
| `tdb sql query ` | Runs a read query and prints the rows, 50 at a time |
| `tdb sql plan` | Which tables would be handed to PocketBase, and how each id is handled |
| `tdb sql adopt` | Hands them over now, after taking a backup |
A resource using `ExecuteCommand` needs `add_ace resource. command.tdb allow` in
`server.cfg`, or FiveM denies it silently. Even then, output only appears in the server
console.
## Where the imported data lives
Each imported table is handed to PocketBase as a **base collection** under its own name,
browsable and editable in the admin UI. There is still one table, read and written by both
SQL and the admin UI.
tDB takes a PocketBase backup before the first table is touched and refuses to continue if
that backup fails. Restore it from **Admin → Backups**.
### What changes when a table is adopted
- **`id` becomes TEXT.** Existing values are preserved and an integer primary key keeps
getting integers. `WHERE id = ?` matches whether you pass `5` or `"5"`.
- **Nullable columns stay nullable**, and `WHERE col IS NULL` keeps matching.
- **An edit in the admin UI cannot blank a `NULL`.** Setting a real value works, but
changing a `NULL` text field to an empty string through the UI leaves it `NULL`. Use
`UPDATE t SET col = '' WHERE ...` for a literal empty string.
- **Foreign keys become triggers.** `ON DELETE CASCADE` and `ON DELETE SET NULL` are
re-created and fire for admin-UI deletes too. `RESTRICT` and `NO ACTION` cannot be
reproduced and are reported.
- **`INSERT INTO t VALUES (NULL, ...)` stops working.** Name your columns, or pass an id.
## Rewritten triggers
Three MySQL trigger shapes are rewritten rather than refused:
| MySQL | Becomes |
| --- | --- |
| `IF c THEN a; ELSE b; END IF;` | two triggers, each with a `WHEN` guard |
| `DECLARE v; SELECT e INTO v; ... v ...` | a correlated subquery in place of the variable |
| `UPDATE t JOIN u ON c SET a` | `UPDATE t SET a FROM u WHERE c` |
A trigger with two `DECLARE`s, a reassigned variable, a nested `IF` or a two-table `UPDATE`
is skipped rather than approximated.
## Skipped triggers
A `CREATE TRIGGER` with no SQLite form is the one statement tDB drops rather than failing
the file over. Every table and row still arrives; what stops happening is whatever the
trigger maintained, usually a cached counter. Each is warned at import time, and
`tdb sql status` lists them:
```txt
PARTIAL phone.sql 106 statement(s), 249ms - 6 trigger(s) skipped: ...
```
A `PARTIAL` file counts as applied and is not re-run. To add the triggers, rewrite them as
SQLite in a second `.sql` file and drop that in too; the counter they maintained is
recomputable with an `UPDATE`.
A `CREATE TABLE` or an `INSERT` that cannot be translated rolls the whole file back. Only
a trigger is ever skipped.
## This is not `Config.Migrations`
`Config.Migrations` is PocketBase's own collection migration system, recording changes you
make in the admin UI. The `sql/` folder is for other people's MySQL dumps. The two never
interact.
# tDB Troubleshooting (/docs/tDB/troubleshooting)
| Symptom | Cause |
| --- | --- |
| [No such export](#no-such-export-when-calling-exportstdb) | tDB has not loaded yet |
| [Only superusers can perform this action](#only-superusers-can-perform-this-action-repeating) | Credentials no longer match the database |
| [The PocketBase setup screen opened](#the-pocketbase-setup-screen-opened-in-my-browser) | You reached a different instance |
| [Batch requests are not allowed](#batch-requests-are-not-allowed) | PocketBase's batch API is off |
| [An error naming a SQL construct](#an-error-naming-a-sql-construct) | No faithful SQLite translation |
| [Admin UI unreachable from outside](#the-admin-ui-is-not-reachable-from-outside) | tLib's port is closed or not forwarded |
| [Waiting for tLib's HTTP listener](#the-startup-box-says-waiting-for-tlibs-http-listener) | Not an error |
| [Update tLib](#the-startup-box-tells-me-to-update-tlib) | tLib never reported HTTP readiness |
| [A table does not exist](#a-script-says-a-table-does-not-exist) | Its schema was never imported |
| [Remote mode never reports ready](#remote-mode-never-reports-ready) | The health probe failed |
## No such export when calling exports.tDB
The calling resource started *before* tDB, not the database being slow — a call made before
the database is up parks until it answers.
1. Check `ensure tDB` sits above the calling resource in `server.cfg`. This is almost always
it.
2. Confirm tDB started — a config error stops the resource and the startup box says so.
3. If the resource must start first, wrap the call in `exports.tDB:onReady(function() end)`.
## Only superusers can perform this action, repeating
The superuser credentials tDB is using no longer match the database.
1. Unset `tdb_superuser_email` and `tdb_superuser_password` in `server.cfg`, and delete the
`Config.Superuser` block from `config.local.lua`.
2. Restart. tDB reprovisions the superuser, writes the new credentials to
`config.local.lua` and prints the password once.
Fixed when the startup box reports the client authenticated.
## The PocketBase setup screen opened in my browser
The instance you reached is not the one tDB started. Find the second PocketBase bound to
that port and stop it.
## Batch requests are not allowed
PocketBase's batch API is off by default. Enable it in **Admin → Settings → Batch API**.
`runTransaction` needs no such setting and is usually the better choice.
## An error naming a SQL construct
That statement has no SQLite translation. Check the name against
[refused constructs](/docs/tDB/mysql-compatibility#refused-by-name), then rewrite it or move
it to [raw SQL](/docs/tDB/api-reference#raw-sql) and write SQLite directly.
## The admin UI is not reachable from outside
1. **Try the FiveM server port first** — 30120 on a default install:
`http://:/tDB/`. Nothing has to be opened for that address, so it
rules out every firewall and NAT question in one step.
2. Confirm `Config.ExposeAdmin = true`.
3. Confirm tLib is running, and that `tlib_http_ingress` has not been set to `false`.
4. **Only if you opted into tLib's own listener** is there a port to open: `tlib_http_port`,
default 7777, in the host firewall and forwarded in NAT — see
[tLib's advanced listener guide](https://timmygstudios.com/docs/tLib/installation#advanced-tlibs-own-listener).
Test from outside the network; a probe from the server itself can pass on a port the
internet cannot reach. Confirm the port you forwarded is tLib's, not PocketBase's
internal 8090.
## The startup box says Waiting for tLib's HTTP listener
Not an error: tLib's router is not up yet. The admin URL appears as soon as tLib reports
ready. If it never clears, tLib is failing to bind — check tLib's log and whether its port
is taken.
## The startup box tells me to update tLib
tLib did not report HTTP readiness, so no admin URL is published. Install tLib 1.0 or
newer, start it before tDB, and read tLib's startup output for the listener error. The
database is unaffected — only the admin UI is.
## A script says a table does not exist
Its schema was never imported; tDB starts empty. Put the dump in `tDB/sql/` and restart —
see [Importing `.sql` files](/docs/tDB/sql-imports). Then check `tdb sql status`: a `FAILED`
row names the statement that stopped it, and a `PARTIAL` row means the schema is there but
some triggers were skipped.
## Remote mode never reports ready
tDB dials `:/api/health` and expects a 200 before registering
anything.
1. Confirm both `RemoteHost` and `RemotePort` are set. One alone does nothing.
2. Open that health URL from the game server itself, not from your desktop.
3. Check the remote PocketBase is reachable on that port, not only behind a proxy on
another.
## Getting help
Open an issue on the
[repository](https://github.com/tommy141x/tDB/issues) with the exact error
text as text rather than a screenshot, the full startup box, your `config.lua` (it holds no
credentials, so it is safe to paste), and the statement involved if it is a SQL error.
# tDetector (/docs/tDetector)

A new overview and a setup walkthrough are being recorded for tDetector. These pages are the
complete reference until they land.
An in-vehicle HUD that alerts when another player's radar gun is transmitting nearby,
and tells you the band, the strength and the direction. A radar on standby is silent.
Three lines in `server.cfg`, and one export on your radar. On `tRadar`, only the three
lines.
## Requirements
| | |
| --- | --- |
| Framework | **Standalone.** QBCore, QBX, ESX and ox_inventory are optional, for [item-based access and the detector item](/docs/tDetector/configuration#who-flips-the-switch). |
| Dependency | **[tLib](/docs/tLib) 1.2.0 or newer** |
| Networking | OneSync (Infinity or Legacy) |
| Radar | At least one radar resource. tDetector loads without one and detects nothing. |
No spaces, no suffix, no `tDetector-main` from a zip. A renamed folder fails in ways
that do not look like a naming problem.
### Supported radar resources
| Resource | What it needs |
|----------|---------------|
| **tRadar** | Nothing. Ships the export and reports its own band. |
| `wk_wars2x` | A one-line export ([below](#patch-your-radar)) |
| `seeker_dual` | A one-line export |
| `rs9000` | A one-line export |
| `ProLaser4` | A one-line export. Reports the laser band as instant-on, held for `Config.instantHoldMs` after the burst. |
| Anything else | See [Integrating any radar](/docs/tDetector/integration), escrowed resources included. |
Run them all at once: tDetector probes each in `Config.radarResources` order and stops at
the first transmitting.
## Install
### Extract the resource
Drop the `tDetector` folder into your `resources` directory.
### Patch your radar
A radar resource has to say that *it* is transmitting. Neither export needs an
`fxmanifest.lua` entry.
In `wk_wars2x/cl_radar.lua`, at the top level after the `RADAR` table is defined:
```lua
exports('IsRadarActive', function()
return RADAR:IsPowerOn() and RADAR:IsEitherAntennaOn()
end)
```
In `seeker_dual/client/exports.lua`, or any client script:
```lua
exports('IsRadarActive', function()
return Radar.power and (Radar.frontXmit or Radar.rearXmit)
end)
```
In `rs9000/client/main.lua`:
```lua
exports('IsRadarActive', function()
return radarOpen and (frontAntenna or rearAntenna)
end)
```
A lidar, so tDetector reports it on the `laser` band with no frequency.
```lua
exports('IsRadarActive', function() return isLaserOut end)
```
Nothing to add. tRadar ships `GetDetectorSignature()` and reports its own band.
The export must return false whenever the antennas are off, even with the unit switched
on. Get this wrong and the detector screams permanently.
An export you add to somebody else's resource is gone the next time you update it, and
it fails **silently**. A radar under asset escrow has no file to edit at all. Both cases
want a [bridge resource](/docs/tDetector/integration#4-the-bridge-resource), which also
reads a radar through its state bags or events with no changes to it.
### Add to `server.cfg`
Your radar starts before tDetector. tLib needs no ordering — the declared dependency
handles it.
```ini
ensure tLib
ensure tRadar # or wk_wars2x, seeker_dual, rs9000, ProLaser4 …
ensure tDetector
```
### Start the server
No further setup. `data.json` is created on first start, and the version banner prints in
the server console.
### Check it
**`/tDetSources`** reports what every configured radar entry returns right now.
**`/tDetSources test`**, in a vehicle with the detector on, runs a 12-second synthetic
sweep of the display.
## It works if
The version banner prints; `/tdetector` opens and **Enable Detector** switches on in a
vehicle; the HUD boots and settles on `SCANNING`; `/tDetSources` names your radar as
`started`, and `TRANSMITTING` while another player has it keyed up; and
`/tDetSources test` sweeps the display.
A detector never hears its own radar, so driving solo never produces an alert. That is
correct. `/tDetSources test` checks the display; detection needs a second player.
## Next steps
- [Usage](/docs/tDetector/usage) — the controls, and how to read the display.
- [Configuration](/docs/tDetector/configuration) — every option, with defaults.
- [Troubleshooting](/docs/tDetector/troubleshooting) — if no alerts appear.
# tDetector Configuration (/docs/tDetector/configuration)
Everything here lives in **`config.lua`**, read at resource start. Run
`restart tDetector` after editing.
Speed unit, sensitivity, layout and HUD position are not here: players set those in
`/tdetector`, and they persist in [KVP](/docs/tDetector/reference#kvp-keys).
## Radar sources
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `Config.radarResources` | table | `{ "tRadar", "wk_wars2x", "seeker_dual", "rs9000", "ProLaser4" }` | Radars that can set the detector off, probed in order; first transmitting wins, one not running is skipped. Bare name or table — see [the entry shapes](/docs/tDetector/integration#reference-the-entry-shapes). |
| `Config.radarStateInterval` | number (ms) | `500` | How often a client re-reads its **own** radar. Also the shortest instant-on burst that can be caught. |
## Range
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `Config.detectionRange` | number (m) | `500.0` | Fallback reach for a radar not reporting its own. The **Ka** figure; other bands scale off it. |
| `Config.detectionRatio` | number | `2.0` | A radar reporting its own range is heard out to that × this. `0` returns every radar to the flat range. |
| `Config.detectionRangeMax` | number (m) | `1000.0` | Ceiling on one source's reach, whatever a radar reports. |
| `Config.screenRange` | number (m) | `8.0` | How near before another vehicle's detector is drawn on the prop's glass. Your own vehicle is exempt. |
| `Config.audioRange` | number (m) | `28.0` | How far the detector is **heard** from outside the car. Must exceed `screenRange`; tLib caps it at 250 m. |
It is not a per-source tuning knob: raising it raises how much warning every radar on
the server gives. See [Strength is not
distance](/docs/tDetector/usage#strength-is-not-distance).
Raise `detectionRange` a long way and one officer with a radar on makes every detector on
the map alert permanently.
## Sensitivity and bands
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `Config.sensitivity.highway` | number | `1.00` | Highway reach, as a fraction of `detectionRange`. |
| `Config.sensitivity.city` | number | `0.45` | City reach. **Not applied to Ka or lidar.** |
| `Config.autoSensitivityAbove` | number (MPH) | `45` | In `Auto`, the speed at which Highway takes over. Always MPH. |
| `Config.bandRange.ka` | number | `1.00` | Ka reach, as a multiple of `detectionRange`. |
| `Config.bandRange.k` | number | `0.85` | K reach. Carries least. |
| `Config.bandRange.x` | number | `1.25` | X reach. Carries furthest. |
| `Config.bandRange.laser` | number | `1.00` | Lidar reach. |
`bandRange` composes with `sensitivity` rather than replacing it, so City reduces X and K
on top of the band multiples.
## False alerts
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `Config.falseAlerts.enabled` | boolean | `true` | `false` makes the detector mean police radar and nothing else. |
| `Config.falseAlerts.siteRange` | number (m) | `120.0` | How far a door opener carries. **Independent of `detectionRange`.** |
| `Config.falseAlerts.kShare` | number | `0.30` | Fraction of doorways on K instead of X. Stable per site. |
| `Config.falseAlerts.sites` | table | 25 entries | `{x, y, z}` per fixed emitter — real vanilla doorways from the game's map files. Replace wholesale for a custom map. |
| `Config.falseAlerts.traffic.enabled` | boolean | `true` | Blind-spot radar in surrounding traffic. |
| `Config.falseAlerts.traffic.range` | number (m) | `60.0` | How far a blind-spot antenna looks at the next lane. |
| `Config.falseAlerts.traffic.share` | number | `0.35` | Fraction of vehicle **models** fitted, from the model hash — so the same car always falses and another never does. |
Not configurable. `kShare = 1.0` moves every doorway to K; it can never reach Ka.
## GPS lockouts
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `Config.lockouts.enabled` | boolean | `true` | Whether MARK can store a lockout at all. |
| `Config.lockouts.radius` | number (m) | `60.0` | How close counts as being at a stored lockout. |
| `Config.lockouts.autoLearn` | number | `3` | Drive-bys before a site locks itself out. `0` disables AutoLearn; MARK still works. |
| `Config.lockouts.max` | number | `100` | Cap on stored lockouts. Oldest dropped first. |
| `Config.lockouts.trafficDismissMs` | number (ms) | `60000` | How long MARK silences a **car**. |
Lockouts are per client in KVP, so one player's MARK never quietens another's detector.
## Alerting
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `Config.instantHoldMs` | number (ms) | `3000` | How long an instant-on alert stays up after the radar keys off. Constant-on alerts are never held. |
| `Config.autoMuteBelow` | number (MPH) | `20` | Mute the tone below this speed; the display keeps working. `0` disables. Always MPH. |
| `Config.speedUnit` | string | `"mph"` | A new player's unit: `"mph"` or `"kmh"`. Anything else, `"kph"` included, is a startup error. A player's own pick persists in KVP. |
## The 3D detector prop
The box on the windshield, visible to everyone in and around the car.
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `Config.vehicleProp.models` | table | the built-in alone | Archetypes offered, as `{ model, label }`. `rdx4000` is always available and always first; adding one means streaming its `.ydr`/`.ytyp` from your own resource. |
| `Config.vehicleProp.default` | string | `"rdx4000"` | Which archetype a vehicle that names none gets. |
| `Config.vehicleProp.placements` | table | empty | Where it sits, keyed by vehicle **spawn name**: `{ x, y, z, rx, ry, rz }` offsets from the vehicle origin, exactly as `AttachEntityToEntity` takes them. An optional `model` overrides the archetype. |
A vehicle with no entry here and none saved in game gets **no prop**, and a car with no
prop relays nothing to its passengers. `/tdetectoredit` is the easier route: in-game
placements live in `data.json` and **win** over this table.
## Access control
Two separate questions.
### Who may use tDetector
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `Config.access` | table | `{ mode = "everyone" }` | The gate. `mode` is `"everyone"`, `"ace"`, `"job"`, `"item"` or `"custom"` — or a list, which passes if **any** does. |
```lua title="config.lua"
Config.access = {
mode = "everyone", -- everyone | ace | job | item | custom
ace = "tdetector.use", -- mode "ace"
job = { police = 0, mechanic = 2 }, -- mode "job": MINIMUM grade
item = "radardetector", -- mode "item"
count = 1, -- how many of `item`; default 1
custom = function(src) return false end, -- mode "custom"
}
```
This is tLib's `access` module — frameworks, inventories and detection order are [its
documentation](/docs/tLib/import-modules#access). A gate whose dependency is absent
denies everyone and says so.
A player who does not pass cannot open `/tdetector` **and is sent no radar data at all**,
both checked server-side on every request.
### Who flips the switch
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `Config.toggleRequiresItem` | boolean | `false` | The item is the **only** on/off switch. `/tdetector` still opens; only the toggle is disabled. |
| `Config.useAsItem` | boolean | `false` | Run the item **alongside** an active `/tdetector` toggle. Not needed when `toggleRequiresItem` is on. |
| `Config.qbItemName` | string | `"radardetector"` | The item's name in your inventory. Works on QBCore, QBX, ESX and ox_inventory. The key keeps its old name so an existing `config.lua` is unaffected. |
The toggle being greyed out is not the lock: the server also refuses to send radar data
to a player not holding the item.
That key is gone. Set `Config.toggleRequiresItem = true`, which enables the item hook
by itself. `Config.useAsItem` is only for running the item *alongside* an active
`/tdetector` toggle.
#### Wiring the item
Add the item to your inventory under the name in `Config.qbItemName`, make it usable, and
`restart tDetector`. Using the item toggles the detector, identically to the `/tdetector`
button. It is picked up from whichever of QBCore, QBX, ESX or ox_inventory is running,
including one that starts after tDetector or restarts. On a server running two of them,
one use that reaches both counts once. The registration is tLib's `tlib.item.onUse`.
On ox_inventory 2.43 or newer the detector item is not spent: tDetector cancels ox's own
use of it, so there is no consume, durability loss or use animation. Older ox_inventory
reports the use after the fact, so mark the item non-consumable in `data/items.lua`.
On QBCore, for example:
```lua title="qb-core/shared/items.lua"
['radardetector'] = {
['name'] = 'radardetector',
['label'] = 'Radar Detector',
['weight'] = 3000,
['type'] = 'item',
['image'] = 'radardetector.png',
['unique'] = true,
['useable'] = true,
['shouldClose'] = true,
['combinable'] = nil,
['description'] = 'We are not liable for your reckless driving.',
},
```
With none of them running, or none accepting the item, tDetector waits ten seconds, prints this and carries on:
```
[tDetector] Config.useAsItem is on, so the "radardetector" item is wired to the detector -- but none of qb-core, qbx_core, es_extended or ox_inventory is running, so the item does nothing.
```
The **Marketplace** and **Sounds** tabs inside `/tdetector` are gated by tLib's admin
level (`tlib.admin` or `tlib.superadmin`), not by the ace in `Config.access`.
## A missing or wrong setting
Nothing silently reverts. A **scalar** setting that is deleted, mistyped or unusable is
replaced by its shipped default — all of them in `TDET_DEFAULTS` at the bottom of
`config.lua` — and warned about once, naming the key, what was found and the line to
paste back. **Table-valued** settings degrade **per field**, so deleting
`Config.bandRange.x` leaves the other three bands untouched.
## Next steps
- [Integrating any radar](/docs/tDetector/integration) — the per-entry shapes for `Config.radarResources`.
- [Usage](/docs/tDetector/usage#reading-the-display) — what these values look like on the glass.
# tDetector Integrating any radar (/docs/tDetector/integration)
Integration answers one question, asked on the *transmitting* player's machine: **is my
radar keyed up right now?** Everything else — range, bands, strength, arrows, sound —
tDetector already does.
`tRadar`, `wk_wars2x`, `seeker_dual`, `rs9000` and `ProLaser4` are configured out of the
box, with ready-made exports under **Install → Patch your radar** on the tDetector index
page. For anything else, stop at the first row that fits.
| | Radar edited? | Survives a radar update? | Use when |
| --- | --- | --- | --- |
| [Export](#1-export) | Usually yes | No | The radar already exports something, or you can edit it |
| [State bag](#2-state-bag) | **No** | Yes | The radar publishes its state into a bag. Best for an escrowed radar |
| [Event](#3-event) | **No** | Yes | The radar fires an on/off event — *last resort* |
| [Bridge resource](#4-the-bridge-resource) | **No** | Yes | The answer needs real logic |
Run **`/tDetSources`** in game first. It reports, per `Config.radarResources` entry,
whether that resource is running, which mechanism is in use, and what was read just
now.
**Try the bare name first.** A name on its own is probed against the exports radars
actually use — `GetDetectorSignature`, `IsRadarActive`, `IsRadarOn`, `GetRadarState`,
`IsTransmitting`.
```lua
Config.radarResources = { "tRadar", "my_radar" }
```
A miss is tried once, remembered, and **cleared when that resource restarts** — so
patching a radar and restarting it is enough.
## 1. Export
tDetector calls the function once per `Config.radarStateInterval`. Naming `export` means
**that export only**, skipping the probe order.
```lua
Config.radarResources = {
{ resource = "my_radar", export = "RadarIsOn", band = "k" },
}
```
| Export | Return |
| --- | --- |
| `GetDetectorSignature()` | `false`/`nil` when idle, or `{ band = "ka", frequency = 34.712, mode = "instant", range = 150.0 }`. All four fields optional. |
| `IsRadarActive()` | `true` while powered **and** transmitting. |
Neither needs an `fxmanifest.lua` entry. `GetDetectorSignature()` may also return a bare
band string, read as a [state bag value](#what-the-value-may-be) is; a table carrying
`active = false` or `transmitting = false` reads as idle whatever else is in it. A
`frequency` outside its band is dropped, and a `range` of zero or less is unreported.
### Constant-on and instant-on
`mode = "instant"` lights the `I/O` badge and holds the alert for a few seconds. The
field is case-insensitive and trimmed — `"instant-on"`, `"i/o"`, `"pulse"`, `"burst"`
and `"trigger"` all read as instant-on, as does `instant = true`. Say nothing and you get
`"constant"`.
### Reporting off the air
`false` is how a radar says it is not radiating, whatever its power state. tRadar answers
`false` while powered but in transmit hold, and while **both antennas are parked**, so an
officer sitting still with both antennas off is invisible to every detector in range. One
parked antenna still reports, because the signature describes the gun and not either
antenna. Your own radar should follow the same rule: report what is on the air, not what
is switched on.
### How far your radar reaches
`range` is optional, in **metres**: how far your radar can clock an ordinary car. It is
heard out to `range × Config.detectionRatio`. Without it, every radar is heard at the
flat `Config.detectionRange`. The server rejects an absurd value and each receiving
client clamps the reach to `Config.detectionRangeMax`.
Report the figure the gun is *capable* of, as tRadar does. Report the operator's
dialled-in range instead and you have built a stealth control: an officer winds the
knob down and goes invisible to every detector on the server.
### An edited radar export is fragile
An export you added to someone else's resource is gone the next time you update it, and
it fails **silently** — no error, no log line, nothing on screen. Put it in a [bridge
resource](#4-the-bridge-resource) instead.
## 2. State bag
**Needs no changes to the radar.** A radar that draws its own NUI usually already
publishes its state into a bag.
```lua
Config.radarResources = {
{ resource = "their_radar", statebag = "radarTransmitting" },
{ resource = "veh_radar", statebag = { key = "on", bag = "vehicle" }, band = "k" },
}
```
`bag` is `"player"` (default), `"vehicle"` or `"global"`.
### What the value may be
| Value | Read as |
| --- | --- |
| `true` | Transmitting, on the band from your config entry |
| `"ka"` / `"k"` / `"x"` / `"laser"` | Transmitting, on **that** band |
| `{ band = "ka", frequency = 34.712, mode = "instant", range = 150.0 }` | Transmitting, all four carried through |
| Anything else | **Idle** |
That last row is strict: `"off"` and `"standby"` read as idle, and so does a misspelled
band.
`/tDetSources` prints the exact bag and key it looked at, and whether that key is
**present** or **ABSENT**. Absent means the name is wrong; present and idle means the
name is right and the radar is not transmitting. That distinction resolves most
integration tickets.
State bags are read fresh every time, so they cannot drift out of sync.
## 3. Event
**Needs no changes to the radar.** tDetector latches onto an event the radar already
fires, subscribing with both `RegisterNetEvent` and `AddEventHandler`.
```lua
Config.radarResources = {
{ resource = "old_radar", event = { on = "rdr:on", off = "rdr:off" }, band = "ka" },
-- or one event whose payload says what happened
{ resource = "old_radar", event = "rdr:stateChanged" },
}
```
The payload is read like a [state bag value](#what-the-value-may-be), and one that reads
as **idle** clears the latch — which is what makes the one-event form work both ways. An
edge with **no payload at all** means "transmitting on the configured band and mode".
Events are *edge-triggered*: a missed edge leaves the latch wrong until the next one.
tDetector clears the latch whenever the radar resource starts or stops, but it cannot
cover a missed edge in ordinary play.
## 4. The bridge resource
`bridge/tdetector_bridge/` is a resource you **copy out** and edit, for when the answer
needs logic config cannot express. Copy it into `resources`, `ensure` it between your
radar and tDetector, name it in `Config.radarResources`, and fill in its one
`isTransmitting()` function — three worked examples are commented out above it. Return
`false` when idle, or `true` / `{ band = ... }` / the full signature table.
Keep it cheap: it runs once per `Config.radarStateInterval`, so no loops over players,
no waits, no blocking natives. A mistake in it is reported once and then reports idle.
A bridge is a **separate Lua state**. It cannot see your radar's locals or globals; it
reaches exactly what tDetector reaches. It does not get you *into* a closed resource —
it gives you somewhere to write logic that an update cannot overwrite.
## Diagnosing it: `/tDetSources`
Per entry, in the **F8 client console**: the resource and whether it is `started`; the
mechanism; which export names **answered**, are **not present**, or were **not tried**;
the exact bag and key, **present or ABSENT**; which events are subscribed and whether the
latch is set; and whether the source is **transmitting right now**, with band, frequency,
mode and reach. The same problems print once at startup on the server console.
The closing line matters most. **Nothing transmitting** while your radar is keyed up
means the wiring is wrong — work back up this page. **Transmitting** but others see no
alert means this side is right: run `tdetector_diag` on the server console and read its
**radar sync** section, which says how many radars the server believes in and whether a
radar resource is running at all. If the server believes the radar, the remaining causes
are range and sensitivity.
**`/tDetSources test`** runs a 12-second sweep on your own display, in a vehicle with the
detector on. If it looks right, every missing alert is a wiring problem.
## When a radar exposes nothing at all
An escrowed radar with no export, no state bag and no event is unreachable, bridge
included. Paste this to its author:
> Could you add a client export so radar-detector resources can tell when the unit is
> transmitting? `exports('IsRadarActive', function() return
> end)` is enough. It needs no `fxmanifest.lua` entry, it is read-only, and it changes
> nothing about how the radar behaves. A state bag carrying the same boolean works too.
## Reference: the entry shapes
```lua
Config.radarResources = {
"wk_wars2x", -- default probe order
{ resource = "my_radar", export = "RadarIsOn", band = "k" }, -- one named export
{ resource = "io_radar", export = "RadarIsOn", band = "ka", mode = "instant" },
{ resource = "their_radar", statebag = "radarTransmitting" },
{ resource = "veh_radar", statebag = { key = "on", bag = "vehicle" } },
{ resource = "old_radar", event = { on = "rdr:on", off = "rdr:off" } },
{ resource = "old_radar", event = "rdr:stateChanged" },
}
```
| Field | Meaning |
| --- | --- |
| `resource` | The resource name as it appears in your resources folder |
| `band` | `"ka"`, `"k"`, `"x"` or `"laser"`, case-insensitive. A fallback only; a radar naming its own band overrides it. Defaults to `"ka"` — K and X share a band with [civilian falses](/docs/tDetector/configuration#false-alerts). |
| `mode` | `"constant"` or `"instant"`. Also a fallback the radar's report overrides. |
| `export` / `statebag` / `event` | Exactly one. Omit all three for the default probe order. |
| `probes` | Export names to try in order instead of the default list. `export` takes precedence. |
Entries are probed **in order** and the first transmitting wins, so put your primary
radar at the top.
## Optional: let the server corroborate the claim
The report reaching the server is a **claim** a modified client could make. tDetector
checks it two ways: at least one name in `Config.radarResources` must be `started`, and
if a radar can answer for itself it is asked and its answer wins.
That second check is a **server-side** export, worth adding only if your radar knows
server-side who is transmitting. Most do not, and leaving it out changes nothing.
```lua
-- A SERVER script in your radar resource. GetPlayerRadarState is read identically.
exports('IsPlayerRadarTransmitting', function(src)
-- true | false | nil ("I have no record of that player")
return transmittingBySource[src]
end)
```
`nil` falls back to the resource-running check. Only `false` refuses a claim, including
after an alert is already up. A bridge is client-side, so it is accepted on the first
check alone.
## Next steps
- [Troubleshooting](/docs/tDetector/troubleshooting) — when the wiring is right and alerts still do not appear.
- [Configuration](/docs/tDetector/configuration) — the range and band values every source is measured against.
# tDetector Layouts (/docs/tDetector/layouts)
A layout is a skin: a folder under `layouts/` holding a `module.json` manifest, a
`ui.html` entry point, and its images. Folders are auto-discovered on server start and
appear in the **HUD Layout** selector in `/tdetector`.
Every element that changes carries a `data-hud-*` attribute and tLib's `HudBinder` writes
state into it — the grammar tRadar's, tLS's and tRadio's skins also use. A skin decides
only how it looks; the timing is shared.
Discovery looks for `module.json`, not `ui.html`. A folder holding only markup is
skipped silently — no console error, no row in the selector. Check this first.
A layout contains no JavaScript. tWeb's marketplace validator rejects `
```
Cache your query selectors in the closure — the callback runs every tick. If a script needs a
key no attribute binds, declare it, or Lua never computes it and your script gets
`undefined`:
```html
…
```
### What a script can and cannot do
| You can | You cannot |
| ------- | ---------- |
| Read everything in `state` and paint it how you like | Reach the host page, or any other layout |
| Build, move and restyle elements inside your own layout | Call a game native or a NUI callback directly |
| Use timers, `requestAnimationFrame`, canvas, WebGL, audio | Read or write player data, or anything outside your folder |
| Ask the game to act, with a `data-hud-btn` | Open a window, navigate the page, or lock the pointer |
| Load images and sounds from your folder, via markup or `new Image()` / `new Audio()` | Use `fetch` or `XMLHttpRequest`, even against your own folder |
| Use any font the player's system has | Load a custom web font with `@font-face` |
To use a specific typeface, embed it as a `data:` URL.
If a skin comes up empty, check the client console. A script that throws is reported there by
layout name and reason, and the rest of the HUD keeps running.
## Buttons
`data-hud-btn=""` fires a `tls:hudButton` client event with the action string. Wire
it to your own handlers in a separate resource, or reuse the built-ins.
```lua
AddEventHandler("tls:hudButton", function(action)
if action == "cycle_pattern" then
ExecuteCommand("+lbar_pattern")
end
end)
```
## Sounds
tLS plays a file from your optional `sounds/` folder on five actions, named verbatim for
the action: `layouts//sounds/.ogg`.
| File | Plays on |
| ---- | -------- |
| `LIGHTS_ON.ogg` | The lights coming on |
| `LIGHTS_OFF.ogg` | The lights going off |
| `TONE_CHANGE.ogg` | A siren tone change, including the start of a burst |
| `AIRHORN.ogg` | The airhorn key |
| `Press.ogg` | A pattern change and the PA key — the generic click |
A missing file plays nothing and is not an error, so ship only what you want.
A sound the server owner mapped to that action wins, so your file is only the fallback.
## UI Studio
Build and publish layouts with the **[UI
Studio](https://timmygstudios.com/marketplace/studio)**.
# tLS LED Names & Model LEDs (/docs/tLS/led-naming)
An LED's **name** drives HUD display and pattern targeting. Follow this standard and a
pattern written for one car works on the next. Set names per LED in the
[Editor](/docs/tLS/editor#led-properties).
## Format
```
[ZONE][FACE?][SIDE?][NUM]
```
| Part | Description |
| ---- | ----------- |
| `ZONE` | 2–4 letter zone code, from the tables below |
| `FACE` | Optional `F` (forward) or `R` (rear), only where the zone has multiple faces |
| `SIDE` | Optional `L` or `R`, only for physically separate side-facing units |
| `NUM` | Sequential, starting at `1` |
1. **All uppercase**, no spaces, no symbols.
2. **Forward and rearward lights** use sequential numbers only, no L/R suffix — `RD1`, `RD2`,
`LBF1`, `LBF2`.
3. **Side-facing lights** take an L/R suffix — `MRL`, `MRR`, `SRL1`, `SRL2`. Omit `NUM` when
there is one per side: `LBAL`, not `LBAL1`.
4. **Names describe physical location only.** Takedown, traffic advisor and alley lights are
*pattern behaviours*, not names.
5. **Numbers count left to right from outside the vehicle** — see
[Numbering direction](#numbering-direction).
6. **Numbering starts at `1`.** Start at `0` only to extend past the core — see
[Numbering beyond the core range](#numbering-beyond-the-core-range).
### Numbering direction
The observer stands outside looking in, so their left is not the vehicle's left every time.
| Face | Names | `#1` sits on the vehicle's |
| ---- | ----- | -------------------------- |
| Front-facing | `LBF#`, `FG#`, `FB#`, `DS#`, `FV#` | **right** |
| Rear-facing | `LBR#`, `RD#`, `RV#` | **left** |
| Right-side facing | `SRR#`, `DOR#` | **rear** |
| Left-side facing | `SRL#`, `DOL#` | **front** |
### Numbering beyond the core range
`#1`–`#6` is the cross-vehicle core that patterns and the HUD target reliably. A face with
more LEDs extends *outward* instead of renumbering: a rear lightbar with 8 LEDs uses
`LBR0`–`LBR7`, keeping `LBR1`–`LBR6` portable. A pattern silently skips a name the vehicle
does not define.
## Zone reference
**Roof**
| Code | Description | Example |
| ---- | ----------- | ------- |
| `LBF#` | Lightbar, front face | `LBF1`, `LBF2` |
| `LBR#` | Lightbar, rear face | `LBR1`, `LBR2` |
| `LBAL` / `LBAR` | Lightbar alley left / right, side-facing | `LBAL` |
| `MBF#` / `MBR#` | Mini bar, front / rear face | `MBF1`, `MBR1` |
| `MBAL` / `MBAR` | Mini bar alley left / right | `MBAL` |
| `BK#` | Beacon / rotator | `BK1` |
`LBAL` / `LBAR` are the side-facing units in the ends of the lightbar. What they do is
decided by the pattern.
**Front exterior**
| Code | Description | Example |
| ---- | ----------- | ------- |
| `FG#` | Front grille | `FG1`, `FG2` |
| `FB#` | Front bumper / push bar, forward-facing | `FB1`, `FB2` |
| `FBL` / `FBR` | Front bumper side end caps, side-facing | `FBL`, `FBR` |
| `HD#` | Hood lights | `HD1`, `HD2` |
**Front interior** *(projects forward through the windshield)*
| Code | Description | Example |
| ---- | ----------- | ------- |
| `DS#` | Dash lights, low mount | `DS1`, `DS2` |
| `FV#` | Front visor lights, high mount | `FV1`, `FV2` |
**Side**
| Code | Description | Example |
| ---- | ----------- | ------- |
| `MRL` / `MRR` | Mirror lights | `MRL`, `MRR` |
| `SRL#` / `SRR#` | Side runner lights | `SRL1`, `SRR1` |
| `DOL#` / `DOR#` | Door lights | `DOL1`, `DOR1` |
| `PIL` / `PIR` | Pillar light sticks, B/C-pillar | `PIL`, `PIR` |
**Rear interior** *(projects rearward through the rear glass)*
| Code | Description | Example |
| ---- | ----------- | ------- |
| `RD#` | Rear deck, low mount | `RD1`, `RD2` |
| `RV#` | Rear visor, high mount | `RV1`, `RV2` |
**Rear exterior**
| Code | Description | Example |
| ---- | ----------- | ------- |
| `RB#` | Rear bumper face | `RB1`, `RB2` |
| `RR#` | Rear runner, body/rocker perimeter | `RR1`, `RR2` |
| `RSP#` | Rear step pad lights | `RSP1`, `RSP2` |
| `LPL` / `LPR` | License plate lights | `LPL`, `LPR` |
**Specialty**
| Code | Description | Example |
| ---- | ----------- | ------- |
| `SPL` / `SPR` | Spotlight, A-pillar or roof edge | `SPL`, `SPR` |
| `SC#` | Scene / work lights | `SC1`, `SC2` |
| `CAB#` | Cabin / interior dome lights | `CAB1` |
## How many lights a face has
A face is addressed by slots **`0` through `7`** — the `1`–`6` core plus the outward `0`
and `7`. A pattern that splits sides cuts that in half, `0`–`3` against `4`–`7`. A face
rarely has eight lights, so each light claims a **span** of the range and answers to all of
it. Two bumper lights become `FB0` (also `1`, `2`, `3`) and `FB4` (also `5`, `6`, `7`) —
one per side.
| Lights | Slots each claims |
| ------ | ----------------- |
| 2 | `0 1 2 3` · `4 5 6 7` |
| 3 | `0 1 2` · `3 4` · `5 6 7` |
| 4 | `0 1` · `2 3` · `4 5` · `6 7` |
| 5 | `0 1` · `2` · `3 4` · `5` · `6 7` |
| 6 | `0` · `1 2` · `3` · `4` · `5 6` · `7` |
| 7 | `0` · `1` · `2` · `3 4` · `5` · `6` · `7` |
| 8 | one each — `0` through `7` |
This is why a pair flashes both colours instead of one. Numbered densely as `FB1`/`FB2`, a
pair sat entirely in the low half and stayed dark through the other half of every pattern.
An odd count leaves the middle light owning a slot either side of the cut, so it flashes on
both beats and a three-, five- or seven-light bar still reads symmetrically.
- Faces of **more than eight** are numbered one slot each from `0` and carry no spans
- A zone that is already one per side — `LBAL`, `MRL`, `SRL` — is not spanned; it is on
one side of the car whatever its number
- A slot you have typed on another LED is never claimed by a span
## Automatic names and groups
You do not have to name anything to get started. An LED you have not named is named from
where it sits on the vehicle and which way it faces, following the zones above — drop a row
of lights along a roof bar and they become `LBF1`…`LBF6`, numbered from the correct end.
Each one also joins the group its zone implies, so a new vehicle arrives with **Lightbar
Front**, **Lightbar Rear**, **Front Visor** and the rest already usable as pattern columns.
- **Anything you type is yours.** Once you set a name or change an LED's groups, that LED is
left alone from then on. Clear the name again to hand it back
- **An automatic name follows the light.** Move an LED to the other end of the bar and it is
renamed to match, because the name describes a physical place
- **Correct one and the rest follow.** Geometry cannot tell a rear deck from a rear visor.
Rename one light of a cluster from `RD2` to `RV2` and the others become `RV` — the zone you
chose beats the guess. Only within a facing direction, so a front-facing name typed onto a
rear cluster is treated as a slip and ignored
- **Names are ordinary names.** They are saved, they drive the HUD and patterns, and they are
what a pattern imported from another vehicle matches against
- The **A–Z** button in the Lights tab sorts the list into the same order. It is a one-off,
not a running sort — your own arrangement is never reshuffled while you work
Where the geometry is genuinely ambiguous, no name is given and the LED stays `LED 7` until
you name it. A door light, a pillar stick and a mirror light can occupy the same place on the
body, so tLS does not guess between them.
Automatic names are a starting point, not a substitute for looking. Rear deck and rear
visor lights in particular are told apart by mounting height, which varies between
builders — rename either one if your layout disagrees.
## One name, one light
A saved pattern stores each cell under the LED's **name**, so a name has to belong to one
light. The editor enforces that:
- **Typing a name another LED already has is refused**, and the field says why. That includes
a name that falls inside another light's automatic span — a light that owns `FV0`–`FV3`
also answers to `FV1`, so a second light cannot be called `FV1`
- **Renaming several selected LEDs at once is refused** when the name is not empty. One name
cannot belong to more than one light
- **Duplicate (Shift+D) starts the copies unnamed**, so the automatic naming gives each its
own place in the numbering, exactly as Mirror does
- A light whose name is still shared — from an older save, or an imported layout — is marked
**!** in the LED list. Its pattern cells are saved under the light itself rather than under
the shared name, so painting one of the pair no longer paints the other. Rename one of them
so a pattern keyed by name can tell them apart
Two lights with the same name used to be saved as one cell. If a pattern was saved that
way, the lost colours are gone: open the pattern, repaint the lights that changed, and save
once. The server console names any vehicle saved with a shared name:
`'' was saved with LED names that more than one light answers to`.
When a pattern keys one light twice — `FV0` and its alias `FV1` with different colours —
the result no longer depends on the order the keys are read in, which differed between
players. The light's own id wins, then its primary name, then an alias, then the
alphabetically first key.
## HUD default LEDs
When no layout declares which LED names to show, the HUD resolves the first group below with
**at least one matching LED** on the vehicle.
| Priority | Names checked | Typical source |
| -------- | ------------- | -------------- |
| 1st | `RD1` – `RD6` | Rear deck lights |
| 2nd | `RV1` – `RV6` | Rear visor lights |
| 3rd | `LBR1` – `LBR6` | Lightbar rear face |
Only LEDs that exist are shown — `RD1`, `RD2`, `RD3` gives three indicators, not six. With
none of these names present, the HUD shows all LEDs. A custom layout overrides this with its
own `data-hud-led` bindings.
## Out of scope
**Factory light circuits** — headlight and tail light flashers — are native vehicle lights,
not placed LEDs. Do not invent names like `HLF` or `TLF`.
## Model-defined LEDs
For vehicle modellers. Author named bones into your model and tLS reads the LED layout off
the skeleton — no `tls.json`, no placement work for whoever installs the vehicle. A **v1
embedded layout** is discovered whenever the vehicle has no saved `leds` section.
- **You get geometry, not behaviour.** Ship a
[patterns-only `tls.json`](#stable-pattern-identities) to light out of the box.
- **You export the bones by hand.** Nothing is read from lightbar meshes, GTA siren lights,
modelling empties or custom properties, and there is no modelling plugin.
### Authoring contract: v1
Include a bone named `tls_v1` to opt in; its placement is unused.
| Bone | Meaning |
| ---- | ------- |
| `tls_led_001` | Centre of the LED rectangle. Its rotation defines the LED's frame |
| `tls_led_001_r` | Right-edge midpoint, in the centre bone's positive local X |
| `tls_led_001_u` | Top-edge midpoint, in the centre bone's positive local Z |
- Number each LED **001 through 064**. Gaps are fine; never renumber during a revision
- 64 is `TLS_MAX_LEDS` in `config/render_config.lua`. A server owner may raise it, but
author against 64
- The centre bone's **+X points right, +Z points up, +Y points out of the lens**. The edge
markers cannot correct a wrong rotation
| Rule | Detail |
| ---- | ------ |
| Parenting | `_r` and `_u` are children of the centre bone, with no independent animation. Parent the centre to whatever the LED follows — chassis, door, bonnet |
| Placement | Put the centre on the intended emitting surface. tLS adds no lens offset |
| Dimensions | Metres. For a 0.10 m × 0.04 m rectangle, `_r` is at local `(0.05, 0, 0)` and `_u` at `(0, 0, 0.02)`. `sw` and `sh` are **half-extents**, so that yields `sw: 0.05`, `sh: 0.02` |
| Bounds | Both half-extents between **0.005 m and 2 m**. Off-axis error within the greater of 0.5 mm or 1% of the larger half-extent |
| LODs | Keep every marker bone present and consistent across streamed variants and LODs |
| Animation | The centre bone may move at runtime — that is how door and bonnet LEDs work — but **animated LED dimensions are not supported** |
### What gets skipped
A failed set is skipped and named in the **client** console (F8); the rest still loads.
| Cause |
| ----- |
| An incomplete set — a centre bone with no `_r`, or no `_u` |
| Non-finite coordinates, reversed axes, or a degenerate size |
| An edge marker not aligned on the axis it belongs to |
| A marker numbered above the server's `TLS_MAX_LEDS` |
A vehicle that streams in without its skeleton ready is retried at most once every five
seconds, so a transient failure is not permanent. The editor forces a fresh scan.
### Stable pattern identities
An embedded LED's **ID and initial name are both its centre bone name**, such as
`tls_led_001`, and its initial group is `Model LEDs`.
- Renaming or removing a marker breaks references to its old identity
- A new marker takes an unused number
A patterns-only `tls.json` references them without repeating placement:
```json
{
"example_vehicle": {
"patterns": [
{
"name": "Example flash",
"fps": 4,
"colors": [{ "r": 255, "g": 0, "b": 0, "a": 1 }],
"frames": [
{ "duration": 1, "cells": { "tls_led_001": 1 } },
{ "duration": 1, "cells": {} }
]
}
]
}
}
```
Declare it in the vehicle resource, using your model's real spawn name in place of
`example_vehicle`:
```lua
tls_config 'tls.json'
```
Do **not** include `leds: []` in a patterns-only config — an explicit empty array disables
the embedded layout.
### Saved layout precedence
| Config | Result |
| ------ | ------ |
| No `leds` field | Use the model layout, if present |
| Explicit `leds` array, **including `[]`** | Use that array exclusively. Never merged with model geometry |
| No valid model layout | The existing manual placement workflow |
An ordinary editor save stores a full explicit layout overriding the model geometry. Your
model file is never written to.
- The **box icon — Import missing model-defined LEDs** in the **Lights** tab appends only
markers whose ID or centre-bone attachment is absent, keeping existing edits and patterns
and respecting the LED cap. It persists only when you save
- To restore one marker, delete that LED and import it again
- Updating the model does not clear a saved override. The only way back to automatic
placement is to back up the config and remove its `leds` section
### Extras, mods and appearance
Version 1 embeds placement, orientation and size only. Extra and mod visibility, livery
restriction, texture and group are not inferred — set those in the editor and save an
explicit layout.
**Do not ship switchable equipment as unqualified model-only LEDs.** They render while the
equipment is disabled.
### Legacy and Enhanced
The same markers work on both generations.
**Do not retrofit markers into an already-exported model** through a generic binary
resource writer. Re-serialising a resource rewrites its page descriptors, which crashes the
game on Enhanced. Go back to the source project.
Confirm in your target runtime that bone names and transforms survived, that markers are
on every LOD, that attached parts carry their LEDs, and that equipment visibility behaves.
# tLS Troubleshooting (/docs/tLS/troubleshooting)
If none of these match, [Still stuck?](#still-stuck) says what to send support.
## Pressing Q does nothing
The vehicle has no LEDs, and every keybind needs at least one. The **Lights** tab says so
outright:
1. Get in and run `/tlsedit`
2. **Lights** tab → **Auto-create LEDs**
3. Add a pattern on the **Patterns** tab
4. Press **Enter**
- With no `siren` bones, place LEDs by hand in the [Editor](/docs/tLS/editor)
- If Q does nothing on a vehicle that *does* have LEDs, check **No User Controls** for that
model on the editor's **Vehicle behavior** tab — it disables every tLS keybind
- tLS shows **no message** on a vehicle that has no lights. That is deliberate: a message
there fired in cars nobody expected tLS to light, and while typing in the editor
## I rebound a siren key and it only works after restarting the game
Rebind under **Settings → Key Bindings → FiveM**; the entries are named *tLS: …*. If a rebind
does nothing, **fully restart FiveM** once and try again.
If a restart does not fix it, send which key, what you rebound it to, and whether you did it
before or after the 2026-10-24 update.
## A short GTA siren chirp plays under my tLS siren
That is GTA's own siren audio leaking under the tLS tone for a moment, usually every few
seconds. With **Traffic pulls over** or **GTA Lights** on, tLS holds GTA's emergency flag, and
the game's own siren sound belongs to that flag. tLS silences it on every tracked vehicle every
frame; it only comes back when something outside tLS un-mutes it.
- Another script calling `SetVehicleHasMutedSirens(vehicle, false)` on the same vehicle
(a siren or ELS resource still running) fights tLS for the flag. Stop it on that vehicle.
- Only vehicles tLS is tracking are covered every frame: inside about 50 m. Beyond that the
mute is re-applied about once a second, so a distant vehicle can still chirp briefly.
- If it persists with nothing else running, send a 30-second clip of the vehicle and the
`tlib_build` stamp at the bottom of `tLS/fxmanifest.lua`.
## GTA's own light pattern flashes over my tLS pattern
The flag that makes traffic pull over also turns on the model's stock `carcols.meta` lights.
It is one bit for both, so no tLS setting can keep the yield and drop the lights. See
[Traffic and GTA's own lights](/docs/tLS/usage#traffic-and-gtas-own-lights) for the three ways
out: turn **Traffic pulls over** off, strip the lights from the model, or override
`visualsettings.dat` on the client.
## AI traffic does not pull over
1. **Vehicle behavior → Traffic pulls over** is on for that model, and the lights are on.
Blackout and a park-killed vehicle release the flag.
2. Only a vehicle with a tLS configuration is covered. A model with no LEDs does nothing.
3. Another resource may be calling `SetReactionToVehicleSirenDisabled(true)`, which stops
every NPC reacting to every siren. Search the server's resources for it.
## A siren audio bank did not load within 30s
The warning names the bank, and which bank it is decides whose problem it is. Read the name
before anything else.
### `'DLC_TLS\TLS' is tLS's OWN siren audio bank under the name it had before 2026-10-24`
Not a third-party pack, and starting or reinstalling one will not help. `DLC_TLS\TLS` is the
name tLS used up to 2026-11-06, and the game never registers it — `dlc_tls` is below the
eight-character minimum for a bank directory.
Update tLS to the latest release, delete the leftover `tLS/audio/dlc_tls/` folder if one is
there, and restart the server. Saved configs keep working: they use `tls_soundset`, which has
not changed.
If you are already on the latest tLS, a third-party siren pack is asking for the old name. The
warning lists the SoundSets that resolve to it — open that pack's `tls_siren_pack` JSON and
point the SoundSet at `DLC_TLS_SIRENS\TLS`, or delete the entry entirely, since tLS maps its
own SoundSets without help.
### `tLS's OWN siren audio bank 'DLC_TLS_SIRENS\TLS' did not load within 30s`
The current name, so this is a payload problem rather than a naming one. Check that
`tLS/audio/dlc_tls_sirens/tls.awc` and `tLS/audio/data/tls.dat54.rel` exist and came from the
same release, then fully restart FiveM — a restart of the resource alone does not remount audio.
### Any other bank name
That bank belongs to a third-party siren pack. Check the pack's resource is started, and that
the bank path in its `tls_siren_pack` JSON matches the pack's own audio folder and `.awc` name.
## Auto-create LEDs: known limits
Auto-create reads the vehicle's model file. These are measured, and every one is fixable by
hand in the editor afterwards:
- A rear traffic advisor modelled as **one long lens strip** (over about 0.6 m) is not read; its
lamps land on nearby trim or are missing
- **Mirror lamps** on a model whose siren bones were left unoriented face straight ahead,
about 20° off, instead of outward
- Two to six extra LEDs can appear on lens-textured trim; they delete in one click
- A slicktop merged into one model has lenses with no bone behind them, so those are placed by
texture and are less reliable
- **Per-LED extras are not assigned automatically.** Bone attachment (doors, boot, bonnet) is
- It has been verified on six vehicles, so a model unlike those may read differently
## The lights work for me but nobody else sees them
State replicates through OneSync entity state bags.
**Fix** — enable OneSync (Infinity or Legacy) and restart the whole server, not just the
resource. If OneSync is already on, confirm you own the vehicle — see
[ownership](#a-player-cant-control-the-lights-on-a-vehicle-someone-else-drove).
## One player sees no tLS lights on any vehicle
That client never received the vehicle configs.
**Fix** — wait a minute; the client retries and the server pushes unprompted within 45
seconds of joining. After that, reconnect and check the server console — an oversized config
is refused and named there.
## `/tlsedit` says "Permission denied"
You do not have tLib's admin ACE. Add it to `server.cfg` and reconnect:
```ini
add_ace group.admin tlib.admin allow
```
It also enables **Set as Server Defaults** and the editor button inside `/tls`.
## `/tlsedit` says "Must be in a vehicle"
The editor edits the vehicle you are sitting in. Any seat works, including a passenger's.
## Editor changes aren't syncing to other players
The editor does not auto-save, and leaving discards the draft.
**Fix** — press **Enter**, or click **Save**, before you exit. Undo history clears on save.
**Sound overrides**, on the Vehicle behavior tab, are the exception: server configuration,
written immediately, not undone by **Escape**.
## My pattern doesn't appear in the 9/0 cycle
Two settings take a pattern out of the cycle while leaving it playable by a rule.
| Cause | Fix |
| ----- | --- |
| Flagged **Trigger Only** | Uncheck it, or drive the pattern from a rule |
| Restricted to a **livery** index | Set **Livery** to *Any*, or put the vehicle on that livery |
## Server-sided sirens aren't playing
A server-sided tone needs four things. Missing any one falls back to the vanilla sound
silently.
| # | Requirement |
| - | ----------- |
| 1 | The tone has **both** a `Server Sound` and a `Server Sound Ref` |
| 2 | The audio bank ships with a resource that is started |
| 3 | **Server-sided Sirens** is enabled in `/tls` |
| 4 | tLS knows which audio bank that SoundSet belongs to |
The fourth catches people. tLS maps its own pack, WM-ServerSirens and OISS; every other
needs one, declared by the pack or written by you in `siren_packs.json`. See
[Configuration → Custom siren packs](/docs/tLS/configuration#custom-siren-packs).
**Diagnose** — press **F8**. A SoundSet with no bank prints:
```
SoundSet 'X' is used by a siren config but maps to no audio bank
```
- If the mapping exists but the bank never loads, the warning names the *bank* instead —
usually a pack resource that is not started, or a wrong path
- A pack that works until the next restart is the classic no-mapping symptom
## I added a WAV to `sirens/` and the tone is silent
Almost always the restart. The game is told which audio files exist when the resource
**starts**, so a file written after that is on disk and not registered yet.
1. Check the server console for the line listing what tLS built. If your file is not there
it was skipped, and the reason is printed beside it —
[Custom Sirens](/docs/tLS/custom-sirens) lists what each message means.
2. Restart tLS — `ensure tLS`.
3. **Reconnect.** A player who stayed connected through the restart does not have the new
audio. This is the step most often missed, because everything else looks correct.
4. Check the tone name matches the console exactly. `My Siren.wav` is the tone `my_siren`, not `My Siren`.
A full server restart is not needed, and never was.
## A player can't control the lights on a vehicle someone else drove
Ownership is per vehicle and held until released.
**Fix** — the owner releases it from `/tls` → **Release Vehicle Ownership**, or the new
player drives the vehicle to claim it.
## I can't turn the car radio off
Q cycles the light stages, so GTA's radio wheel is suppressed.
The radio is switched **off on entry** to a tLS vehicle, so this should not come up unless
something turned it back on.
**Fix** — press **Radio Off/On** on the **Quick** tab of `/tls`, or bind *tLS: Radio
Off/On* in **Keybinds → FiveM**. **Station ◀** / **Station ▶** step through stations.
## My ULC / LVC vehicle still fires its own extras
tLS does not read ULC, LVC or ELS configs — nothing in it knows what a ULC stage is. A car
that still flashes parts you never configured has something else driving its GTA extras:
usually the pack's own ULC/LVC script, still running.
**Fix** — in this order:
1. **Stop the other resource on that vehicle.** Two scripts writing the same extra fight every
frame and the last writer wins. No tLS setting outranks a live ULC script.
2. **Hide the extras you do not want:** `/tlsedit` → **Vehicle behavior** → **Spawn extras**,
and click the numbers to switch off. That writes `siren.disabledExtras`, and tLS forces
those extras off whenever it is tracking the vehicle.
| Limit | Detail |
| ----- | ------ |
| Extras **1–12** only | GTA has no others |
| Player vehicles only | Ambient NPC traffic in configured models is skipped deliberately, so extras are never stripped off a car nobody is driving |
| Not a migration | tLS imports nothing from a ULC config. The vehicle's own LEDs still come from `/tlsedit` → **Auto-create LEDs** — [Moving a fleet off ULC, LVC or another ELS](/docs/tLS/installation#moving-a-fleet-off-ulc-lvc-or-another-els) is the per-vehicle sequence and what it costs |
## My custom function key does nothing
The key is **refused unless a rule on that vehicle uses its condition**, and the refusal is
silent — there is nothing to show, so nothing is shown.
**Fix** — in the editor, add a trigger rule whose condition is **Function 1** (through
**Function 6**) and give it actions. Check you are in the vehicle that has the rule: functions
are configured per vehicle, so a key that works in one car does nothing in another.
## My custom settings disappeared after a server restart
`data.json` was removed or replaced, and a missing file is rewritten empty on the next boot.
- Extracting a new release over the folder cannot replace it
- A folder deleted and re-extracted, a deploy step that mirrors the resource directory, or a
restore from an older backup all will
- Per-player client settings are stored on the client and survive reconnects
**Diagnose** — check the server console on startup:
| Line | Means |
| ---- | ----- |
| `First boot: created data.json` | tLS found no file. On anything but a new install, that is the cause |
| `data.json could not be created` | The resource directory is not writable. Nothing survives a restart until that is fixed |
**Fix** — restore from a backup, then exclude whichever deploy step replaces the resource
directory. Back it up before any update: it is the one file you cannot re-download.
## "Saved in tLS, but `` cannot be written to" after saving a vehicle
The vehicle comes from another resource's `tls.json` (a vehicle pack), and tLS could not write
the new layout into that pack. Your edit is **not lost**: tLS keeps it in its own `data.json`,
so it is live in game, and it writes the finished file to `tLS/exports//tls.json`.
Every admin online gets this notice in game when it happens; the server console carries the
same line with the exact paths.
**Fix** — copy `tLS/exports//tls.json` over `/tls.json` and restart the pack.
Until you do, the pack still holds the old layout, and tLS keeps using its own copy.
This is not a permissions problem and no server setting fixes it. FiveM only lets a resource
write into its own folder, and a plain vehicle pack has no server script that could receive
the file. `add_filesystem_permission tLS write ` and `--allow-fs-write` do nothing, and
the capitalisation of the pack's name is irrelevant: tLS uses the name FiveM reports for it.
If the notice says the copy "could not be staged", the change exists only in `data.json`;
check that the `tLS` folder is writable.
## I exported several vehicles into one pack and only the last one is there
The exports were **staged**, not written. tLS could not write into the target resource, so
each one was written to a staging folder instead.
Exports normally merge: each reads what the target already holds and adds its own vehicle to
it. A staged export is built the same way — but nothing ever reaches the target, so every
replaced rather than added to.
**Diagnose** — the console says so at the time, once per export:
| Line | Means |
| ---- | ----- |
| `Player exported '' to ''` | The export landed. Merging works, nothing to do |
| `EXPORT NOT COMPLETED: ... written to ... instead` | Staged. The three steps that follow it are the rest of the job |
A successful export also confirms itself in chat to whoever ran it; a staged one does not.
**Fix** — copy each staged file into the pack before exporting the next vehicle, so the
following export has something to merge onto. The console names the exact source and
destination path.
There is no server setting that removes the staging step. FiveM only lets a resource write
into its own folder, and a plain vehicle pack with no server script of its own cannot take
delivery of a file from another resource. `add_filesystem_permission` and `--allow-fs-write`
do not change that. The only target tLS can write into directly is a resource that ships its
own server script with tLib's `registerWriteResourceFile()`; for anything else the copy step
is the whole procedure.
Already lost earlier vehicles this way? Nothing is gone — each one is still configured, so
re-export them one at a time.
## `SCRIPT ERROR: @tLS/...` on startup
tLib is missing or started too late. "No such export" is the same problem.
**Fix** — in `server.cfg`, ensure tLib **above** tLS:
```ini
ensure tLib
ensure tLS
```
## `SCRIPT ERROR: native 000000005240da5a: bad cast` when tLS starts
A saved setting on the player's machine was stored with a different type than the one tLS
reads it as, and the read raised. From the release after 1.1 the setting is ignored, tLS uses
its default, and the F8 console names it once:
```text
[tLS] "" is stored as a different type than GetResourceKvpString reads, so it is ignored. ...
```
It lives in the player's own client storage, so it is per player: someone who never changed
that setting does not have it.
**Fix** — update tLS **and** tLib. If the line still appears after that, post it: it names the
key, which is what tLS needs to find out how it was written.
## A tLib version warning in the console
Your tLib is older than the version in tLS's manifest, and tLS refuses to start against it.
**Fix** — update tLib, not tLS:
[releases](https://github.com/tommy141x/tLib/releases). See
[version compatibility](/docs/tLS/installation#version-compatibility).
## `references data file 'audio/data/tls.dat' ... that does not exist`
**A false positive. Do not fix it.** It appears on every start:
```
Resource 'tLS' references data file 'audio/data/tls.dat'
of type 'AUDIO_SOUNDDATA' that does not exist.
```
Renaming the file to `tls.dat`, or pointing `data_file` at `tls.dat54.rel`, silences the
warning and takes **every siren tone** with it. The only symptom is silence.
## The resource won't start at all
The folder is not named `tLS`.
**Fix** — rename it to exactly `tLS`: no spaces, no `-main` suffix from a zip extract.
## Still stuck?
Run `tls_diag` in the F8 console for one paste-safe line, then contact support on
[Discord](https://timmygstudios.com/discord) with:
- The `tls_diag` line. Its `[build …]` field identifies the exact zip you installed, which the
version number cannot — `[build unstamped]` means that copy did not come from a release
- The full console error block, not a paraphrase
- Your `server.cfg` load order around `tLS`
- F8 client console output captured while the problem happens
- Which vehicle model, and whether it reproduces on a stock vehicle such as `police4`
# tLS Usage (/docs/tLS/usage)
What a driver does with a vehicle somebody has already configured. To change what the keys
do, see the [Editor](/docs/tLS/editor).
## Commands
| Command | Who | Purpose |
| ------- | --- | ------- |
| `/tls` | Everyone | Client settings dialog |
| `/tlsedit` | Admin | Vehicle editor. You must be in a vehicle, any seat |
Both are rows on the **Quick** tab of `/tls`. Their keybinds — *tLS: Radio Off/On* and
*tLS: Toggle Blackout* — are unchanged. Remove the commands from any macro naming them.
### Diagnostics
ACE-restricted (`command.`), printing to console rather than chat.
| Command | Console | Purpose |
| ------- | ------- | ------- |
| `tls_diag` | F8 | Print the paste-safe environment line: tLS version, tLib version, game name, build, and Legacy or Enhanced |
| `tls_reload_siren_packs` | Server | Re-read `siren_packs.json` and push the new SoundSet → bank map to every client, with no restart |
| `tls_debug_sync` | F8 | Toggle state-sync tracing. Pass a field name to trace only that field |
| `tls_debug_relay` | Server | The same, server side |
`tls_calibnow` is an internal LED-colour calibration tool. It needs `screencapture` and is
not for a live server.
## Keybinds
Rebind any of these in **Keybinds → FiveM**.
### Lights
| Key | Command | Action |
| --- | ------- | ------ |
| **Q** | `+lbar_toggle` | Lights on/off, or cycle stages if the vehicle has stage triggers |
| **0** | `+lbar_pattern` | Pattern up. Skips `triggerOnly` patterns and patterns hidden by livery |
| **9** | `+lbar_pattern_down` | Pattern down |
Stage cycling runs `Off → 1 → … → Max → Off`. Max is the highest of `stage_1` / `stage_2` /
`stage_3` the vehicle's triggers use.
### Siren
| Key | Command | Action |
| --- | ------- | ------ |
| **R** | `+lbar_siren` | Burst or tone cycle — see below |
| **Alt** | `+lbar_siren_main` | Main siren on/off. Lights must be on |
| **Up Arrow** | `+lbar_siren_aux` | Aux siren on/off. Lights must be on |
| **E** | `+lbar_horn` | Horn with lights off, airhorn with lights on |
| **1 – 5** | `+lbar_tone1..5` | Jump to a tone — see below |
| **Right Alt** | `+lbar_rumbler` | Low-frequency variant on the main siren |
**Already played on an earlier build? Your low-frequency key is still `K`.** FiveM stores each
player's keybinds the first time it sees them and never revisits the default, so a changed
default only reaches people who have not run tLS before. Rebind it under **Settings → Key
Bindings → FiveM** if you want Right Alt. Nothing on the server can move it for them.
**R:**
| Current state | Tap | Hold (>400 ms) |
| ------------- | --- | -------------- |
| No sirens | Burst tone 1 while held | — |
| Main only | Cycle main tone | — |
| Aux only | Cycle aux tone | — |
| Both | Cycle main tone | Cycle aux tone |
**Keys 1–5:**
| Lights | Siren | Press |
| ------ | ----- | ----- |
| Off | — | Burst that tone while held |
| On | None | Start the main siren on that tone |
| On | Different tone | Switch to that tone |
| On | Same tone | Stop the main siren |
The direct keys stop at 5 because 6, 7 and 8 are cruise, takedown and the traffic advisor.
Slots 6–8 are reached by cycling with **R**.
Tones flagged `triggerOnly` are skipped by both, but trigger actions can still start them.
### Modes
| Key | Command | Action |
| --- | ------- | ------ |
| **6** | `+lbar_cruise` | Toggle cruise |
| **7** | `+lbar_takedown` | Toggle takedown |
| **8** | `+lbar_ta` | Traffic advisor: Off → Left → Right → Center, limited to directions the vehicle has triggers for |
| *(unbound)* | `+lbar_blackout` | Toggle blackout |
| *(unbound)* | `+lbar_fn1` … `+lbar_fn6` | Toggle custom function 1–6. What each one does comes from the vehicle's own rules — see [Custom functions](#custom-functions) |
### Turn signals
| Key | Command | Action |
| --- | ------- | ------ |
| **Left arrow** | `+lbar_indicator_left` | Left signal. Pressing it again cancels |
| **Right arrow** | `+lbar_indicator_right` | Right signal |
| **Down arrow** | `+lbar_indicator_hazard` | Hazards |
Pressing the signal you are already using turns it off; pressing the other one switches
straight across, without an off in between.
**These only work on vehicles tLS manages.** A car with no tLS config keeps its own
indicators and its own arrow keys — tLS neither binds nor broadcasts anything for it. That
is deliberate: the other resources that add turn signals drive every land vehicle you get
into, which is what makes them bad neighbours.
The `turn_left`, `turn_right` and `hazards` trigger conditions follow these, so a rule can
drive extra lights from a signal.
### Other
| Key | Command | Action |
| --- | ------- | ------ |
| *(unbound)* | `+lbar_pa` | PA mic, hold to talk. Requires pma-voice |
| *(unbound)* | `+lbar_cinematic` | Cinematic camera |
### Vehicle radio
Q cycles stages, so GTA's radio wheel — also Q — is suppressed. These replace it, work from
any seat, and are unbound until you assign them. The **Quick** tab of `/tls` needs no key.
| Command | Action |
| ------- | ------ |
| `+lbar_radio` | Radio off, or back on to the last station |
| `+lbar_radio_next` | Next station. The cycle passes through off |
| `+lbar_radio_prev` | Previous station |
Vehicles set to **No User Controls** keep GTA's own radio wheel, horn and cinematic camera.
## Client settings (`/tls`)
Most changes apply live. Four tabs — Quick, Display, Appearance, Sounds — plus **Vehicle**
when you own a tLS vehicle or are an admin sitting in one. A server default applies only
where you have never chosen.
### Quick
| Field | Description |
| ----- | ----------- |
| **Blackout** | Run dark. Front seats of a vehicle whose config binds controls |
| **Radio Off/On**, **◀ Station**, **Station ▶** | Shown only when tLS has taken Q on this vehicle |
| **HUD Visible**, **HUD Layout**, **Day/Night Mode** | Mirrors of the Display and Appearance rows — change one and the other follows |
### Display
| Section | Field | Description |
| ------- | ----- | ----------- |
| HUD | **HUD Visible** | Show or hide the HUD overlay |
| HUD | **HUD Layout** | Any folder under `layouts/` |
| HUD | **Reposition HUD** | Opens tLib's shared HUD editor |
| Render quality | **Environmental Lighting** | OFF, Low, Medium, High, Smart — how LEDs light the surrounding world |
| Render quality | **Lighting Quality** | OFF, Low, Medium, High, Smart — the per-LED render pipeline |
| Server-wide (admin only) | **Set as Server Defaults** | Your HUD visibility, HUD layout and both quality settings become the fallback for players who have not picked their own |
### Render quality
These are the two settings that decide what tLS costs you, and both ship on **Smart**.
**Environmental Lighting** — the expensive one, and the first to reach for.
| Tier | Light sources cast, per vehicle, per frame |
| ---- | ----------------------------------------- |
| **Off** | None. LEDs still light; they stop illuminating anything around them |
| **Low** | **At most two**, whatever the LED count — one per side, each the averaged colour of the lit LEDs there |
| **Medium** | One per **group**. LEDs group when they share a colour exactly, sit within half a metre, and face broadly the same way |
| **High** | **One per lit LED**, up to the 64-LED cap |
| **Smart** | High or Medium for your own vehicle, by smoothed frame time. Never above Medium on anyone else's |
High applies to **one vehicle only** — the one you are in, or own. Every other vehicle is
capped at Medium within 60 m and Low beyond, whatever you set. Medium's grouping tests exact
colour equality, so a bar running one red groups into very few lights while a bar alternating
red and blue cannot group those at all.
**Lighting Quality** — how many flat layers make up one lit LED.
| Tier | Layers per lit LED | What is drawn |
| ---- | ------------------ | ------------- |
| **Off** | 0 | Nothing |
| **Low** | 2 | The outer flare and the lens background |
| **Medium** | 2 or 4 | 4 on your own vehicle, 2 on everyone else's |
| **High** | 4 | Outer flare, a hotter core over it, the lens background, and the lens dot texture |
| **Smart** | 2 or 4 | 4 on your own vehicle always; on others, 4 above roughly 85 fps and 2 below |
The cheapest and most expensive LED differ by a factor of two, so Environmental Lighting
buys more.
### Clawing back frame rate
In the order worth trying. **Smart** on both suits most players.
| # | Change | Effect |
| - | ------ | ------ |
| 1 | Environmental Lighting High → Medium | Biggest win, smallest visual change. Medium still casts coloured light on the road |
| 2 | Env Range → 50% | Fewer pixels touched at your current tier, without losing a light |
| 3 | Environmental Lighting → Low | Two flat light sources per vehicle |
| 4 | Lighting Quality High → Medium | Other players' vehicles drop to two layers; yours keeps four |
| 5 | Environmental Lighting → Off | The LEDs remain, fully patterned and coloured. Only the light they cast goes away |
| 6 | Fewer LEDs per vehicle | Most lightbars read correctly with fewer modules than builders tend to place |
Nothing limits tLS to the closest few vehicles: twenty lit tLS vehicles in range and on
screen are twenty vehicles drawn. A configured vehicle sitting dark costs nothing, nothing is
drawn past 500 m, and ambient AI traffic is never tracked at all.
### Appearance
**Day/Night Mode** sits at the top.
- `Combined` uses one set of slider values
- `Day & Night` splits each into a ☀ Day and a ☾ Night value, blended across dawn and dusk —
except Bloom Skew Angle, which has one angle for both
The sliders follow in three sections — **Flare**, **LED core**, **Light cast on the world** —
all stepping in 5s.
| Slider | Range |
| ------ | ----- |
| **Bloom Size** | 10% – 300% |
| **Bloom Skew** | 0% – 100% |
| **Bloom Skew Angle** | −180° – 180° |
| **Vibrance** | 0% – 200% |
| **Flare Opacity** | 0% – 300% |
| **Core Size** | 0% – 100% |
| **Core Brightness** | 0% – 100% |
| **Env Brightness** | 0% – 300% |
| **Env Range** | 10% – 300% |
The two **Env** sliders scale what Environmental Lighting produces without changing how many
lights it casts. At Env Brightness `0` the lights are still drawn and contribute nothing; a
lower Env Range covers fewer pixels and so costs less at the same tier.
Under **Reset and calibration**: **Reset to Defaults**, which touches your sliders only, and
**Auto Calibrate** when `screencapture` is started. Admins also get server-wide
**Enable/Disable Auto-Calibration**, likewise gated on `screencapture`.
### Sounds
**Server-sided Sirens** uses server-bundled audio when a tone has a `serverSound`. Off
forces vanilla GTA siren audio.
Admins also get **Server-wide mappings**, assigning an installed file to each HUD event —
Lights On, Lights Off, Tone Change, Airhorn, Chirp.
- Only an installed file can be newly assigned. Install sounds from the editor's Marketplace
- A mapping to a missing file stays visible, marked `(unavailable)`
- These save immediately, for everyone
### Vehicle
A vehicle is claimed by its driver, or by a front passenger when the driver seat is empty.
The tab appears only to whoever holds the vehicle; the **LED Editor** is a sidebar entry and
needs no ownership, only `tlib.admin` and a vehicle.
| Field | Shown when | Description |
| ----- | ---------- | ----------- |
| **Presence Detection** | You own the vehicle | Arms the `presence` / `presence_mode` conditions while the vehicle is locked and you are away |
| **Release Vehicle Ownership** | You own the vehicle | Hands control to another player |
**LED Editor**, in the sidebar rather than on this tab, needs admin and a vehicle and
launches `/tlsedit`. **Feedback**, last in the sidebar, sends one message to TIMMYG
Studios rather than to this server's staff.
**PA range and preset are not here.** They are server defaults pushed on join, and a player
cannot change them. See [Configuration](/docs/tLS/configuration).
### Repositioning the HUD
**Reposition HUD** opens tLib's shared editor with the lightbar selected; `/tlibhud` opens it
directly. Preview applies live, Save persists, Cancel restores.
| Action | Effect |
| ------ | ------ |
| **Drag** | Move |
| **Scroll wheel** | Scale |
| **Corner handles** | Uniform resize |
| **Alt** (held) | Suspend snapping |
The HUD must have been on screen once, so get in an emergency vehicle first. A widget cannot
be dragged off screen.
Placement lives in tLib now, and a HUD you had already moved keeps its position.
## Stages
Stages come entirely from triggers. No `stage_1` / `stage_2` / `stage_3` condition anywhere
means Q is a plain on/off toggle.
| Stage | Meaning |
| ----- | ------- |
| Off | Lights fully deactivated |
| 1–3 | Whatever triggers and pattern overlays are wired to that stage |
Activating lights suspends **cruise**, restoring it on deactivate, and suspends **takedown**
and the **traffic advisor** while `lightsSuspendTakedown` / `lightsSuspendTA` are on.
## Modes
| Mode | Key | What it does |
| ---- | --- | ------------ |
| **Cruise** | 6 | Steady-speed patrol. Usually a single steady rear pattern via a `cruise` trigger |
| **Takedown** | 7 | Forward scene lights. Rules can force it on when stationary or off when moving |
| **Traffic advisor** | 8 | Directional arrows. The cycle includes only directions with `ta_left` / `ta_right` / `ta_center` triggers |
| **Low-frequency** | Right Alt | Adds the low-frequency sound to the main siren, on tones that have one. Aux is unaffected |
| **Blackout** | unbound | Run dark — see below |
| **Custom functions 1–6** | unbound | Six toggles whose meaning comes entirely from your trigger rules — see below |
| **Presence** | `/tls` → Vehicle | Arms the vehicle while you are away. `presence_mode` is true while the owner is away and the vehicle locked; `presence` adds an on-foot player who is not another tLS owner inside the radius |
### Blackout
Blackout hides every emergency light — the LEDs, the scene lighting they cast, and the high
beams and emergency-lights flag tLS drives — without switching any of it off.
- Stage, pattern, pattern position, cruise, takedown and the traffic advisor keep running
behind it, so toggling back returns the vehicle mid-sequence
- It replicates: a vehicle running dark is dark for everyone
**Blackout is visual only. The siren and horn keep playing.** Kill the siren separately to
arrive quietly.
Bind it under *tLS: Toggle Blackout* in **Keybinds → FiveM**, or tick **Blackout** on the
**Quick** tab. A `blackout` condition lets rules react to it.
### Custom functions
Every other key in tLS does one fixed thing. These six do whatever you wire them to: pressing
one raises a condition — `fn_1` through `fn_6` — and your trigger rules decide what that means
on that vehicle. Nothing about them is predefined, including which vehicles have them at all.
Typical uses:
- Black out only the **front** of the vehicle, leaving the rear lit for traffic
- A rear-facing work light for a scene, separate from takedown
- A quieter second cruise look for a specific unit
- Any look you want **on demand**, rather than tied to a stage, a speed or a door
Setting one up takes two steps, **in this order**:
1. **Make the rule.** In the editor's trigger list, add a rule with condition **Function 1**
(through **Function 6**) and give it the actions you want — a pattern overlay, a stage, a
siren tone, anything a rule can do
2. **Bind the key**, in **Keybinds → FiveM** under *tLS: Custom Function 1* through *6*
**The key is refused until a rule uses its condition.** A function with no rule on the
current vehicle does nothing at all — the traffic advisor refuses a direction it cannot
light for the same reason. If a key seems dead, the rule is missing or belongs to a
different vehicle.
Each function is a **latch**: press to toggle on, press again for off, and nothing else
releases it. They are per-vehicle and they replicate, so other players see whatever your rules
light. Switching lights off does not clear them.
All six ship **unbound**.
## Horn gestures
`E` emits three conditions. With `hornProgrammable` on, the default airhorn and horn sounds
are suppressed and your triggers drive the audio alone.
| Condition | Fires when |
| --------- | ---------- |
| `horn_tap` | Press and release under 400 ms |
| `horn_double_tap` | Two taps within 600 ms |
| `horn_hold` | Held over 500 ms |
## Chirp
A chirp is a 75–125 ms siren burst that **repeats every 4–6 seconds** for as long as chirp is
held on. It is usually wired to `park_kill`, so it starts when the driver exits with sirens
running.
- Chirp is a **latch**, not a one-shot: `park_chirp` turns it on and leaves it on
- It stops when a rule turns it off, a `chirp_overlay` rule releases it, or a script calls
`SetChirp(vehicle, false)`
- On the Sirens tab, **Chirp Tone** picks the slot, and **Play Full Siren** (`chirpByCode`)
holds the tone for the whole chirp
tLS chirps on park by itself, per vehicle, through `park_kill` and **Chirp Tone**. If tChirp
also runs, it asks tLS before each chirp and skips any car tLS is already chirping, so a car
with the `park_chirp` rule chirps once and a car without it is still tChirp's. That needs
a tChirp newer than 2.0; 2.0 and older do not ask, and both chirp the same car.
## PA mic
Hold the PA key to broadcast through the vehicle's public address system, via a bandpass
filter. Needs pma-voice, the driver seat, a vehicle you own, and no active call.
The PA ships **unbound** — assign it in Settings → Key Bindings → FiveM, under
"tLS: PA Mic (hold)". It had B until tLS 2026-10-17, and B is tRadio's push-to-talk
default, so a player running both transmitted on the radio and the PA at once.
| | |
| --- | --- |
| Range and preset | **Server defaults**, not player settings |
| Range | 25 m, bounded 10–100 m. pma-voice multiplies it by roughly 3× in native audio mode, so 25 carries about 75 m |
| Presets | `police` (600–6000 Hz, default and hardest), `fire` (500–5500 Hz, warmer), `clean` (300–7000 Hz, softest) |
| Changing either | The range window and the whole preset list live in `config/pa_config.lua` — add, remove and retune them. See [PA mic range and voice presets](/docs/tLS/configuration#pa-mic-range-and-voice-presets) |
| Per-model off switch | `paEnabled: false` in the vehicle's siren config |
| Reporting | `tls:sync.paActive`, the `lbarPaActive` player state bag, and the `IsPaActive()` export |
## Siren behaviour
| Behaviour | Detail |
| --------- | ------ |
| **Burst** | Tapping R, or a direct-tone key with lights off, plays a one-shot without starting the main siren. `sirenTone` is unchanged |
| **Horn interrupt** | With `hornInterrupt` on (default), the main siren pauses while the airhorn plays and resumes on release |
| **Park kill** | With `parkKill` on (default), all sirens stop when the driver exits and the `park_kill` condition fires |
| **Traffic pulls over** | With `aiYield` on (default), AI traffic yields while the lights are on. See [below](#traffic-and-gtas-own-lights) |
## Traffic and GTA's own lights
AI traffic reacts to one thing: GTA's own emergency-lights flag, the same flag that tints the
street red and blue. A tLS pattern draws its own lights and does not touch that flag, so
traffic would ignore a unit that is lit and wailing. To fix that, tLS holds the flag for you:
- **Traffic pulls over** (`siren.aiYield`, on by default) holds the flag for as long as the
lights are on and releases it when they go off. In the editor it is on the **Vehicle
behavior** tab. A vehicle saved before the setting existed gets it.
- The flag is held **muted**. tLS tells the game to silence its own siren on every tracked
vehicle every frame, so the stock wail does not play under the tLS tone.
- The **GTA Lights** pattern option holds the same flag, but only while that one pattern
plays. Use it to tint the street from a single pattern; use `aiYield` for traffic.
- Blackout and park kill release the flag, so a dark or abandoned unit stops stopping traffic.
**What it costs.** The flag is also what turns on the model's own `carcols.meta` siren
lights, so they flash underneath your tLS pattern. **There is no setting that keeps one and
drops the other, and there is no native that would let us add one** — GTA exposes a single bit
for both, and a sweep of every siren-named native in the Cfx database on 2026-11-24 found
nothing that touches the carcols lights. So the choice is real, and it is yours to make:
- Switch **Traffic pulls over** off to keep only the tLS lights. Traffic then ignores the unit.
- Keep both by taking the stock lights out of the model. Servers report deleting the light
entries from the vehicle's `carcols.meta` siren set (keeping the wigwags), or setting their
scale to zero. GTA still treats the vehicle's lights as active, so traffic still yields. This
is per-model, and tLS never writes to `carcols.meta`.
- Keep both for every model at once with a client-side `visualsettings.dat` override that zeros
the `car.sirenlight.*` emissive values. Community mods do this and report sirens and AI
traffic unaffected. We have not measured it, and two things come with it: it is **global**, so
NPC police lightbars go dark too, and a client in **pure mode** cannot load it. If your server
already ships a visuals pack, that pack sets these keys and will fight the override.
**If traffic still ignores the unit**, another script on the server is disabling the
reaction. `SetReactionToVehicleSirenDisabled(true)` turns it off for every vehicle, and
`OverrideReactionToVehicleSiren` changes what traffic does. tLS calls neither. Ambient AI
cars in configured models are never touched by tLS.
## Traffic signal preemption
A transmitting vehicle turns the lights it is approaching green and holds the rest of that
junction red, the way a real emergency-vehicle preemption system does. It is **off until a
trigger rule asks for it** — there is no key for it, because it belongs to a condition like
"lights on above 15 mph" rather than to a button someone remembers to press.
Add it in the editor's **Triggers** tab as an action:
| Action | Behaviour |
| ------ | --------- |
| **Traffic signal preemption (While active)** | Transmits for as long as the rule's conditions hold. This is the one to reach for |
| **Traffic signal preemption (Latch on/off)** | Fires once on the rising edge and leaves the transmitter where it put it |
Several rules may transmit at once; the transmitter stops when the last of them releases.
### What a junction does
The sequence is modelled on a real controller (MUTCD §4F.19), not on "make it green":
1. cross traffic goes **yellow**, then
2. an **all-red** clearance, then
3. your approach goes **green** while everything else stays red, then
4. the same yellow and all-red on the way out.
**The yellow and all-red intervals are not optional and are not configurable away.** Sending
cross traffic from green straight to red is the one transition a real controller may never
make. On the shipped timings the whole entry sequence is 5.5 s, which is why the detection
range is 550 m — at 60 mph you need about 150 m of warning just to finish it before you
arrive. Shortening the range does not shorten the warning, it removes it.
A junction is released after a minimum green, once the transmitter has been gone for the hold
window — and unconditionally after the maximum call time, so a parked vehicle that is still
transmitting cannot own a crossroads forever.
### What it costs on the wire
One boolean per vehicle. Every client runs the same geometry against that vehicle's own
replicated position, so no junction coordinates are ever sent and there is nothing for a
client to forge. A player who has not streamed the junction does nothing.
### Limits worth knowing before you enable it
- **AI traffic drives straight through it.** `SetEntityTrafficlightOverride` changes the
light and nothing else — Rockstar's own documentation says changing traffic lights does not
change NPC behaviour. This is for the players at the junction, not for the traffic.
- Only the seven standard GTA traffic-light props are recognised. A custom-prop junction from
a map resource never preempts, and that produces no error.
- Each client starts a junction's sequence when it first sees the call, so two players can be
up to half a second apart on the same yellow. The order is identical everywhere.
Every number above — the range, the junction box, the four intervals, the prop list — is in
`config/render_config.lua`, each with the measurement behind it.
## Language
Every string tLS shows is in `config/locales.json`, and you can reword or translate any of
them. See [Translating tLS](/docs/tLS/configuration#translating-tls) for the fallback rules,
what is not in the file yet, and the font answer.
## Elgato Stream Deck
Physical keys for the lightbar:
- Stages, patterns, main and aux sirens, tones, horn, traffic advisor, cruise, takedown,
blackout, low-frequency, chirp and PA, plus a Status key
- Two Stream Deck+ dial actions — Stage and Tone. The Stage dial can be set to walk the
pattern list instead
- Every key shows live state
- Entirely local. Your server is never involved
Download plugin (.streamDeckPlugin)
### Setup
### Install the plugin
Double-click the downloaded `.streamDeckPlugin`, or use the app's plugin menu → *install
from file*. Restart the app.
### Drag the keys you want onto your deck
Every action is under the **tLS** category. Several have Property Inspector options: one
Lights key can step through stages while another jumps straight to stage 2.
There is no third step. **Nothing has to be switched on in game** — tLS connects to the
plugin as soon as both are running.
### Resting states
| The key says | What is actually true |
| ------------ | --------------------- |
| **no link** *(enable in /tls)* | The plugin is running but the game is not connected — the game is closed, or you have not spawned in. There is nothing to enable; the sub-label on this card is out of date |
| **no vehicle** | Connected, but not in a tLS vehicle |
| **read only** *(not the driver)* | In a tLS vehicle you cannot operate — a rear seat, or the LED editor is open |
| **PORT** *(see plugin log)* | Another program has taken the port — see below |
The Status key is the exception: it keeps showing the lightbar in **read only**. The four
states look like this on it, in the order of the table above:
### If a key says "Port in use"
The plugin listens on port **21400**. Close whatever else has that port and restart the
Stream Deck app.
### What a deck key may do
Every key sends the same request your keybind does, through the same checks.
- The **front passenger seat** works, exactly as the keyboard does there
- A key is refused from a rear seat, on a vehicle you are not sitting in, and while the LED
editor is open
### Turning it off
Close or uninstall the plugin. There is no in-game setting: the plugin's presence is what
turns the link on, so with nothing listening on the port tLS does nothing.
# tRadar (/docs/tRadar)

An overview and a setup walkthrough are being recorded for tRadar. These pages are the
complete reference until they land.
Police traffic radar: two antennas, a target and a fast window each, per-window lock, patrol speed, moving and stationary modes, X/K/Ka bands with doppler audio, a power-on self-test and a tuning fork.
One dependency, no database.
## Requirements
| Requirement | Detail |
| --- | --- |
| [tLib](https://github.com/tommy141x/tLib/releases) | **v1.2.0 or newer.** tRadar declares `tlib_min_version '1.2.0'` and refuses to start below it |
| A FiveM server | `lua54` and `node_version '22'`, both declared by tRadar |
| A vehicle | The unit is dash-mounted and reads patrol speed off the car |
No framework is needed. One is consulted only for `Config.access.mode = "job"`, an inventory only for `"item"`.
The source zip has no built files — no `client/ui`, no `server/dist`. It starts and then shows a blank HUD.
## Install
### Extract the resource
Unzip the release **on the server** into `resources/`.
Exports publish as `exports.tRadar`. Rename the folder to `tRadar-v1.0.0` or `tradar` and every call to `exports.tRadar:setPlateFlag` stops resolving. No spaces, no version suffix, exact casing.
### Set the load order
```cfg
ensure tLib
ensure tRadar
```
tLib must start first. The wrong order gives `No such export` — see [Troubleshooting](/docs/tRadar/troubleshooting#no-such-export-or-tradar-fails-to-start).
### Choose who can use it
`Config.access` ships as `mode = "everyone"`. Set a real mode on a live server.
```lua
Config.access = {
mode = "ace", -- or "everyone", "job", "item", "custom", or a list
ace = "tradar.use",
job = { police = 0, sheriff = 0, statepolice = 0 }, -- name = MINIMUM grade
}
```
```cfg
add_ace group.police tradar.use allow
```
Six frameworks resolve for `"job"` — `qbx_core`, `qb-core`, `ND_Core`, `es_extended`, `ox_core`, `nat2k15framework` — and nine inventories for `"item"`, including `ox_inventory`, `qs-inventory` and `qb-inventory`. Teach anything else to answer in `server/sv_access.lua`, outside escrow: define `tradarPlayerJob`, or call `tlib.access.registerFramework` if your framework has grades. An unresolvable job denies.
### Grant admin separately
`tradar.admin` covers the sound library and the 3D prop editor.
```cfg
add_ace group.admin tradar.admin allow
add_ace group.admin command.tradar_diag allow
```
`tlib.admin` is honoured as a fallback, but it opens the admin surface of every t\* resource. `tradar_diag` is gated on the command, not on `tradar.admin`, and the server console can always run it.
`tlib.admin` stops standing in for `tradar.admin` at the next major version. Add the narrower grant now; both can sit in `server.cfg` at once.
### Deploy and check
Get in a vehicle, press **F5**, then press **PWR** on the faceplate.
## It works if
1. **F5** puts the unit on screen. A second press opens the remote.
2. **PWR** runs a self-test: every window shows `888`, then the **TEST** legend lights green.
3. Pointed at moving traffic, the target window shows a speed.
`/tradar` deploys the unit; the faceplate's **PWR** key powers it. The scan threads run only while it is powered.
## Optional surfaces
| Surface | Default | Setting |
| --- | --- | --- |
| Plate reader | **Off** | `Config.plateReaderEnabled = true` |
| Handheld remote | On | `Config.remoteEnabled` |
The remote is drawn only in keypad mode. The plate reader keeps no list of its own — it shows whatever a [CAD or BOLO resource](/docs/tRadar/cad) answers, and never prints `CLEAR`.
## Next
- [Usage](/docs/tRadar/usage) — the controls, and reading the glass.
- [Configuration](/docs/tRadar/configuration) — every option.
- [Troubleshooting](/docs/tRadar/troubleshooting) — if a step above did not work.
# tRadar API reference (/docs/tRadar/api-reference)
Three client exports, three server exports, one event, six commands, three key mappings.
Every call below is `exports.tRadar`. The resource folder must be named exactly `tRadar` or none of them resolve.
## Client exports
| Export | Parameters | Returns | What it does |
| --- | --- | --- | --- |
| `GetDetectorSignature` | none | `table \| false` | The unit's signature while transmitting, `false` otherwise |
| `IsRadarActive` | none | `boolean` | Whether the unit is transmitting |
| `setPlateFlag` | `plate: string`, `flag: table \| nil` | `boolean` | Attaches a flag to a plate, or clears one |
### GetDetectorSignature
This is the whole contract a radar detector reads. [tDetector](/docs/tDetector) already lists `tRadar` in its `Config.radarResources`, so there is nothing to install on either side.
```lua
local sig = exports.tRadar:GetDetectorSignature()
-- false, or:
{
active = true, -- always true when a table is returned
band = 'ka', -- 'x' | 'k' | 'ka'
frequency = 34.7, -- GHz, the spot frequency inside that band
mode = 'instant', -- 'instant' | 'constant'
range = 150.0, -- metres this gun can clock an ordinary car
}
```
Those five keys are the whole shape. **Silence is `false`, not a table with `active = false`.**
It reports **transmission, not power**. A unit is on the air when it is powered **and** out of transmit hold **and** has at least one antenna live **and** is not mid-cold-self-test **and** not faulted.
| State | Reported |
| --- | --- |
| Never powered, or stowed | `false` |
| Powered, in transmit hold | `false` |
| Powered, **both antennas parked** | `false` |
| Powered, one antenna parked | the signature |
| Powered, transmitting | the signature |
| Faulted, or running the cold power-up self-test | `false` |
An antenna is a transceiver with its own source, and the lane key's **OFF** position parks it — so a head with both parked is genuinely not radiating. One parked is still a transmitting gun: the signature describes the **gun**, one band and one frequency, so it answers whether anything is radiating rather than how much.
This is not the same claim as beam range, directly below. Range turns down the receiver; parking an antenna switches a transmitter off. Collapsing the two would either turn a sensitivity knob into a stealth control or leave a genuinely dark gun announcing itself.
**`mode` is derived, not configured.** It is `'instant'` while the transmitter has been up for less than `Config.instantOnWindowMs` (4000 ms), and `'constant'` after. The clock is stamped on the transmit edge only, so re-stating a state the unit is already in does not restart it; keying off and on again is a new edge and a new burst. `Config.instantOnWindowMs = 0` means the unit never claims instant-on.
**`range` is the gun's capability**, `Config.maxRange` (150.0 m). A detector hears a gun at roughly twice that, and tDetector clamps the result to its own `Config.detectionRangeMax`.
tRadar reports `Config.maxRange`, never the operator's beam-range slider. The range control turns down the **receiver**; reporting the dialled value would turn a sensitivity knob into a stealth control.
**`band` and `frequency`** are resolved fresh on every call, in this order:
1. **The installed skin**, if `Config.layoutBands` names it. An entry naming a band but no frequency takes that band's default, never `Config.frequency`.
2. **Otherwise `Config.band` and `Config.frequency`.**
3. **An unknown band becomes Ka**, and takes Ka's frequency.
4. **A missing or invalid frequency becomes the band default.** `nil`, a non-number, NaN, zero and anything negative all fall back.
| Band | Default frequency |
| --- | --- |
| `x` | 10.525 GHz |
| `k` | 24.150 GHz |
| `ka` | 34.700 GHz |
Changing the radar skin re-resolves the band immediately.
### IsRadarActive
The bare boolean form of the same question.
```lua
if exports.tRadar:IsRadarActive() then
-- a beam is on the air
end
```
Both are **client** exports and answer for the local player's unit only. Poll them — there is no event. tDetector reads once per its own `Config.radarStateInterval` (500 ms).
### setPlateFlag
Answers a plate read. Call it from a handler for [`tradar:plateRead`](#tradarplateread).
```lua
exports.tRadar:setPlateFlag('12ABC345', {
level = 'alert', -- 'info' | 'warn' | 'alert' | 'unknown'
label = 'STOLEN',
source = 'tCAD',
})
exports.tRadar:setPlateFlag('12ABC345', nil) -- clears it
```
| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `level` | string | no | `info`, `warn`, `alert` or `unknown`. Anything else becomes `warn` |
| `label` | string | **yes** | Drawn on the plate window. Truncated at 64 characters |
| `source` | string | no | Which resource answered. Defaults to `unknown`, truncated at 64 |
Use `unknown` when your lookup timed out, was rate limited or failed — see [CAD and ALPR](/docs/tRadar/cad#and-when-nobody-answers).
A flag applies only to a window currently showing that exact plate, including a locked one. An answer arriving after the car has gone is dropped. The call returns `false` when `plate` is not a string, is empty, or is over 8 characters; an over-long `label` is truncated and still returns `true`.
## Events
### tradar:plateRead
Fires on every new plate read. Client-side.
```lua
AddEventHandler('tradar:plateRead', function(plate, side, info)
if info.speed > 80 then
exports.tRadar:setPlateFlag(plate, {
level = 'warn',
label = ('%d %s'):format(math.floor(info.speed), info.unit:upper()),
source = 'tCAD',
})
end
end)
```
| Parameter | Type | Value |
| --- | --- | --- |
| `plate` | string | The plate as read |
| `side` | string | `'front'` or `'rear'` |
| `info` | table | `info.plate`, `info.side`, `info.vehicle` (entity handle), `info.speed`, `info.unit` (`'mph'` or `'kmh'`) |
`info.speed` has no cosine reduction and is the number to judge a violation against. The glass shows the antenna's reading, which is lower.
Every event is spelled `tradar:`, lower case. A handler on a retired `tRadar:` name raises nothing, so check for one rather than waiting for an error.
The BOLO events (`tradar:boloList`, `tradar:boloAdd`, `tradar:boloRemove`, `tradar:boloRequest`, `tradar:boloHit`, `tradar:boloRefused`) and the CAD bridge's two (`tradar:plateQuery`, `tradar:plateAnswer`) are internals. Use the server exports below and `setPlateFlag` instead.
## The built-in BOLO list
Officers manage it in the **BOLO** tab of `/tradar`, which appears when `Config.plateReaderEnabled` is on. The list is server-owned, shared, persisted in `data.json`, and gated on the same access check as the radar.
Call these from a **server** script:
| Export | Arguments | Returns | What it does |
| --- | --- | --- | --- |
| `addBoloPlate` | `plate: string` | `boolean` | Adds a plate. `false` if already listed, not a plate, or the list is at its 100-plate ceiling |
| `removeBoloPlate` | `plate: string` | `boolean` | Removes a plate. `false` if it was not listed |
| `getBoloPlates` | — | `table` | A copy of the list, upper-cased |
```lua
RegisterNetEvent('mdt:boloIssued', function(plate)
exports.tRadar:addBoloPlate(plate)
end)
```
**Discord.** `Config.boloWebhook` posts when a plate is added, removed or seen by a reader. Anything that is not a `https://discord.com/api/webhooks/...` URL is treated as unset and reported at startup.
## Commands
| Command | Arguments | What it does |
| --- | --- | --- |
| `/tradar` | none | Opens the settings dialog |
| `/tradar_deploy` | none | Walks the unit: deploy, remote, back out. Bound to **F5** |
| `/tradar_xmit` | none | Transmit / hold, for instant-on. Unbound by default — assign a key in the keybind menu |
| `/tradar_antenna_front` | none | Steps the front antenna's lane filter: off → same → opposite → both. Unbound |
| `/tradar_antenna_rear` | none | The same for the rear antenna. Unbound |
| `/tradar_antenna_front_power` | none | Parks the front antenna, or brings it back on the lane it was watching. Unbound |
| `/tradar_antenna_rear_power` | none | The same for the rear antenna. Unbound |
| `/tradar_lock_front` | none | Locks the front antenna's current target, or releases it if one is held. Unbound |
| `/tradar_lock_rear` | none | The same for the rear antenna. Unbound |
| `/tradar_unlock` | none | Releases both locks without aiming at either. Unbound |
| `/tradaredit` | none | Opens the 3D prop editor. Needs `tradar.admin` (or `tlib.admin`) and a vehicle |
| `/tradarfork` | `rear` (optional) | Strikes the tuning fork. Anything other than `rear` is the front |
| `/tradar_save` | none | Saves the reading on the glass to the radar log. Bound to **J** |
| `tradar_diag` | none | **Server** console. Versions, config errors, the resolved access gate, the detected framework and inventory, the BOLO count, whether the webhook parsed |
```cfg
add_ace group.admin command.tradar_diag allow
```
`tradar_diag` output goes to the server console, and to the caller when there was one. It is safe to paste into a support thread: no credential and no player identity.
`/radar` and `/radarfork` are **removed**.
## Key mapping
| Mapping | Default | Description in the keybind menu |
| --- | --- | --- |
| `tradar_deploy` | `F5` | tRadar: Radar: deploy, then remote |
| `tradar_xmit` | *(unbound)* | tRadar: Radar: transmit / hold |
| `tradar_antenna_front` | *(unbound)* | tRadar: Radar: front antenna — lane / off |
| `tradar_antenna_rear` | *(unbound)* | tRadar: Radar: rear antenna — lane / off |
| `tradar_antenna_front_power` | *(unbound)* | tRadar: Radar: front antenna — on / off |
| `tradar_antenna_rear_power` | *(unbound)* | tRadar: Radar: rear antenna — on / off |
| `tradar_lock_front` | *(unbound)* | tRadar: Radar: lock / release front |
| `tradar_lock_rear` | *(unbound)* | tRadar: Radar: lock / release rear |
| `tradar_unlock` | *(unbound)* | tRadar: Radar: release both locks |
| `tradar_save` | `J` | tRadar: Save the current radar reading |
F5 walks the unit: deploy → open the remote → close the remote. **ESC** does the third step too, and the unit is stowed from the remote's **STOW** key, so F5 never switches it off. With `Config.remoteEnabled = false` the second press stows.
### `tradar_xmit` — instant-on without a cursor
Instant-on is not a setting, it is something an operator *does*: sit in hold, key up once a car is in sight, key off. The unit already models all of it — the window a detector is told about, the latch a detector holds a burst for — but working the **XMIT** key meant opening the remote and clicking it, which is two F5 presses and a mouse move per burst. This is that key, on a key.
It does nothing on a stowed unit, or on one suspended because you stepped out of the car, because there is no glass to click on either. The two **LANE** keys work the same way and fire the same action the faceplate's LANE key does, so they **cycle** — off → same → opposite → both — which is what that key does on a real head.
### Going dark where a detector cannot see you
An antenna that is parked transmits nothing, so a unit with both antennas parked is off the air and no detector in range picks it up. `tradar_antenna_front_power` and `tradar_antenna_rear_power` are that switch: one press parks an antenna, one press brings it back on the lane it was watching rather than stepping past it.
**XMIT** is still the key to hold the whole unit in one press — it keeps the patrol window reading and any lock, which parking the antennas does not. Use the lane keys to run front-only for a shift, and the two `_power` keys to sit somewhere unseen.
Assign it in **Settings → Key Bindings → FiveM → tRadar: Radar: transmit / hold**.
No default is shipped because the obvious letters are already spoken for on an RP server — seatbelt, radio, interaction — and claiming one on first boot would break something a player already relies on, invisibly. tDetector's keys ship the same way. A server that knows what is free can set `default` in `client/cl_hud.lua`.
Deploying re-checks access, so it is rate-limited to one call a second. Keypad mode — F5's second press — takes NUI focus **with input kept**, so you can still drive; the mouse look and attack controls are suppressed while it is up, so the cursor cannot swing your camera or fire out of the window.
Keypad mode had its own key before F5 existed. It is now F5's second press, and the old binding has been removed — two keys reaching one state is a cycle a player can desync by using the other one halfway through.
A FiveM key mapping is permanent once it has been seen, so if you ran an earlier version you keep a dead **tRadar: Work the radar keys** row in your control list. Nothing can remove it from here; it does nothing.
## The radar log
`tradar_save` keeps whatever is on the glass — both windows, both plates, any lock, patrol speed, band, unit, and the colour and model of each plate's vehicle — in the **Log** tab of `/tradar`. The last 25, newest first, surviving a restart.
It records what the **window said**: a held window logs the held number, a blanked patrol window logs as blank. Captures are refused, with a reason, when the unit is stowed or the glass empty.
## Layout actions
Layouts name actions in `data-hud-btn` rather than calling exports. The full list is in [Layouts](/docs/tRadar/layouts#the-action-list).
## Next
- [Troubleshooting](/docs/tRadar/troubleshooting) — `No such export` and the other failures these calls produce.
- [CAD and ALPR](/docs/tRadar/cad) — the shipped answerer for `tradar:plateRead`.
# tRadar CAD and ALPR (/docs/tRadar/cad)
The CAD bridge answers plate reads from whichever CAD your server already runs. Off until you turn it on, and turning it on is one line.
```lua
Config.integrations = {
cad = { enabled = true },
}
```
Every plate read that belongs to a player's vehicle is then looked up, and a hit lights the plate window.
**There is no API key to set.** Every path into a CAD is an export call into that CAD's own resource — no URL, no key, no convar.
## Supported CADs
| CAD | Resource | Answers |
| --- | --- | --- |
| LACORE | `lacore` or `lacore-mdt` | Registration, BOLOs, insurance. No rate limit |
| SonoranCAD | `sonorancad` | Registration, BOLOs, warrants, stolen |
| ImperialCAD | `ImperialCAD` | A vehicle record |
| wasabi_mdt | `wasabi_mdt` | A vehicle record. No rate limit |
| tk_mdt | `tk_mdt` | **BOLO only** |
Leave `provider` as `nil` and whichever is running is used, in the order above. Name one to pin it.
It does **not** fall through to another CAD. `tradar_diag` names it.
It answers BOLOs only, so `false` means *no BOLO on file*, not *comes back clear*. tRadar renders it as no flag, and tk_mdt is last in the preference order.
## What a hit looks like
A flag on the plate window, through the same `setPlateFlag` door a CAD of your own would use.
| What the CAD said | Level | Flag |
| --- | --- | --- |
| Stolen | `alert` | `STOLEN` |
| Active BOLO | `alert` | `BOLO` |
| Active warrant | `alert` | `WARRANT` |
| Uninsured | `warn` | `NO INS` |
| Nothing on file | — | no flag |
| Several at once | `alert` | `STOLEN · BOLO` |
Only `alert` blinks.
tRadar reads SonoranCAD's own active flag and shows historical records as nothing.
## And when nobody answers
An empty flag field means *the CAD answered, and nothing is on file*. A lookup that did not come back gets a fourth level, **`unknown`** — dim, no blink, not red.
| On the glass | What happened |
| --- | --- |
| nothing | The CAD answered. Nothing is on file |
| `NO ANSWER` | A timeout, a rate limit, or the CAD is not running |
| `CAD ERROR` | The CAD answered with a fault, or its export raised |
| `STAND BY` | You asked again inside the interval floor |
| `NO CAD` | No supported CAD is running, or the pinned one is not |
tRadar never prints `CLEAR`.
## Locking a plate runs it
Locking bypasses the NPC filter and the answer cache, and tells you when the answer cannot be had. A throttled automatic read is dropped silently.
## Spending your CAD's budget
SonoranCAD's lookup endpoint is **30 requests per minute, per API key** — per community, shared with your CAD resource's own traffic and every other officer.
Two officers reading steadily cross 30 a minute, so `NO ANSWER` is normal on a busy server. `tradar_diag` counts throttled reads and timeouts separately.
Only a real answer is remembered, so a CAD that comes back up is used on the very next read.
## Alongside the built-in BOLO list
Both at once is supported. The [built-in BOLO list](/docs/tRadar/api-reference#the-built-in-bolo-list) is the shift's own, kept in `data.json`; the bridge is a second answerer on the same event. The last answer wins, but a CAD answering *clear* only clears a flag the **CAD** set, so a plate your shift watches keeps lighting.
## Every setting
| Setting | Default | What it does |
| --- | --- | --- |
| `enabled` | `false` | The whole feature. `false` and not one message is sent |
| `provider` | `nil` | `nil` to use whichever supported CAD is running; or `lacore`, `sonoran`, `imperial`, `wasabi`, `tkmdt` to pin one |
| `npcFilter` | `true` | Only a vehicle a player is in or has owned, never an emergency vehicle |
| `queryOnRead` | `true` | Look up every new read the filter lets through. `false` keeps only the lock path |
| `queryOnLock` | `true` | Look up a plate when an officer locks the window |
| `minIntervalMs` | `2000` | Floor per officer. Two seconds is 30 a minute |
| `answerTtlMs` | `60000` | How long one answer is reused for the same plate. `0` never reuses |
| `timeoutMs` | `15000` | How long to wait before saying nobody answered |
| `notifyOfficer` | `true` | SonoranCAD only: pop the lookup on the officer's own CAD |
## When it is not working
Run `tradar_diag` on the server console and read its `integration` section.
```
cad = sonoran selection = auto
detected = sonoran
floor = 2000 ms/officer answer TTL = 60000 ms timeout = 15000 ms
asked = 142 coalesced = 18 from cache = 61 in flight = 1
answered = 63 hits = 4 clear = 55 no answer = 4 timed out = 2
throttled = 9 access denied = 0
```
| What you see | Where to look |
| --- | --- |
| `cad = off` | `Config.integrations.cad.enabled` |
| `cad = NONE ANSWERING` | The next line names a typo, a stopped resource, or no CAD |
| `detected` lists `(no export)` | SonoranCAD's lookups plugin is switched off inside the CAD |
| `asked = 0` while reads happen | The NPC filter, or `queryOnRead` |
| `access denied` climbing | The gate that decides who may open the radar |
| `timed out` climbing | Reachable but slow. Raise `timeoutMs` |
| `throttled` climbing | Normal on a busy server |
## Next
- [API reference](/docs/tRadar/api-reference#setplateflag) — the export a CAD of your own answers through.
- [Configuration](/docs/tRadar/configuration) — `Config.integrations`.
# tRadar Configuration (/docs/tRadar/configuration)
Everything lives in `config.lua`, outside escrow. Edit the file, restart the resource. There is no database, no convar and no in-game admin panel for server settings.
Two more files sit outside escrow with it: `server/sv_access.lua`, where a framework tLib does not already resolve is taught to answer, and `layouts/`, which is plain HTML and PNG.
## The four most servers change
| Option | Why |
| --- | --- |
| `Config.access` | Defaults to `mode = "everyone"`. Set a real mode on a live server |
| `Config.band` | `ka` is every modern frontline gun. `x` and `k` are older units, and the doppler audio differs |
| `Config.plateReaderEnabled` | Off by default. Turn it on for ALPR |
| `Config.maxRange` | 150 m. Raise it if the unit feels blind, lower it if it feels psychic |
Mode, lanes, which antennas are on, the speed unit, auto-lock and its limit, beam range and volume are set from `/tradar` and saved per player. The options below set the **limits those controls run inside**, not the values.
`Config.access` covers the driver and a front passenger working the keypad. It does not cover watching: a passenger always sees the picture the driver's unit is drawing.
## Full reference
### General
| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `Config.access` | table | see `config.lua` | Who may run `/tradar`, as one block: `mode` (`everyone`, `ace`, `job`, `item`, `custom`, or a list of them), plus `ace`, `job` (a job-name-to-minimum-grade map), `item`/`count` and `custom`. Six frameworks and nine inventories resolve out of the box, as independent choices. |
| `Config.requireVehicle` | boolean | `true` | Require the player to be in a vehicle. The unit is dash-mounted and reads patrol speed off the car. Checked continuously, not just on deploy: step out and the unit is hidden until you get back in, keeping its power, settings and any lock. |
| `Config.vehicleClasses` | number[] \| nil | `nil` | Restrict to these `GetVehicleClass` ids on top of the access mode. `nil` allows any vehicle; `{ 18 }` is emergency only. |
| `Config.speedUnit` | string: `mph` \| `kmh` | `"mph"` | The server's starting unit. Players change their own and it is remembered. |
| `Config.defaultRadarLayout` | string | `"KBX-2200"` | The head a player starts with. A missing name falls back to the first installed radar skin. |
| `Config.defaultPlateLayout` | string | `"PRX-400"` | The plate-reader skin a player starts with. |
| `Config.defaultRemoteLayout` | string | `"RCX-150"` | The remote skin a player starts with. |
| `Config.plateReaderEnabled` | boolean | `false` | Whether the plate reader surface exists at all. Off by default — it is a second window on screen. |
| `Config.remoteEnabled` | boolean | `true` | Whether the handheld remote exists. It is only drawn in keypad mode. |
| `Config.dopplerAudio` | boolean | `false` | Whether the continuous speed tone starts on. Off by default; each player has their own `Doppler Audio` tickbox in `/tradar`, so this is the starting value and not a lock. Does not affect what a bystander hears — that is `audioRange`. |
| `Config.defaultVolume` | number, 0–1 | `0.5` | Starting level for the doppler and lock tones, 0.0–1.0. Players change their own. |
| `Config.maxRange` | number | `150.0` | Metres the unit can clock an ordinary car. Also the range it reports to detectors. |
| `Config.minPlayerRange` | number | `50.0` | Floor on the player's own beam-range slider, in metres. `maxRange` is its ceiling. |
| `Config.coneAngle` | number | `6.0` | Beam HALF-angle in degrees, off the antenna axis. A 12–15° wide antenna is 6–7.5° here. |
| `Config.rangeFactorMax` | number, 1 or more | `2.0` | How far past `maxRange` the largest vehicle still reads, as a multiple. `1.0` means nothing out-reaches a car. |
| `Config.targetHoldMs` | number | `400` | How long a lost reading stays on the glass before the window blanks. |
| `Config.band` | string: `x` \| `k` \| `ka` | `"ka"` | The band on the air — `x` (10.525 GHz), `k` (24.150), or `ka` (34.700). Sets the doppler audio and what detectors hear. |
| `Config.frequency` | number \| nil | `nil` | Exact frequency in GHz, overriding the band default. `nil` uses the band's own. |
| `Config.layoutBands` | table | see `config.lua` | Per-faceplate band overrides, so one server can ship a Ka head and a K head. |
| `Config.instantOnWindowMs` | number | `4000` | How long the transmitter may be up and still be reported to a detector as instant-on rather than constant-on. |
| `Config.minSpeedKmh` | number | `8.0` | Below this, the unit shows nothing rather than a number — the doppler shift is down in the clutter. |
| `Config.maxSpeedKmh` | number | `320.0` | Above this, the unit shows nothing rather than a number. |
| `Config.stationaryMaxSpeed` | number | `3.0` | How fast the patrol car may move in stationary mode before the unit stops reading entirely. |
| `Config.fastThreshold` | number | `3.0` | How much quicker than the tracked target a vehicle must be before the FAST window lights, in display units. |
| `Config.fastLimitMax` | number | `200` | Ceiling on the auto-lock limit a player may dial in. `0` removes auto-lock and all four of its controls — the arm and the limit, on Quick and on Unit alike. |
| `Config.rearAlertMargin` | number | `10.0` | How much faster than the patrol car same-lane traffic must be overtaking before the rear alert fires. |
| `Config.patrolBlankBelow` | number | `0.0` | A patrol speed below this is not shown at all. |
| `Config.selfTestMs` | number | `900` | How long one check takes. The first 60% of it drives every window to `888`. |
| `Config.selfTestIntervalMs` | number | `900000` | How often a powered unit re-checks itself. 15 minutes by default. |
| `Config.selfTestFailChance` | number, 0–1 | `0.0` | Chance a scheduled check fails, 0.0–1.0. A failure latches: no speeds until a later check passes. |
| `Config.patrolShadowPull` | number, 0–1 | `0.2` | How hard an obstructing lorry drags the ground channel, as a fraction of the closing rate. Ships on; `0` disables it. |
| `Config.patrolShadowMaxError` | number | `10.0` | Ceiling on the error that shadowing can cause, in display units. |
| `Config.calibrationHighMph` | number | `0.0` | Top of the tolerance window a unit draws its fixed offset from at power-up. `0` is an exact instrument. |
| `Config.calibrationLowMph` | number | `0.0` | Bottom of that window. The published tolerance for real equipment is +1/−2 mph. |
| `Config.sampleMs` | number | `100` | How long one reading integrates. A doppler counter counts over a window, it does not sample an instant. |
| `Config.accuracyMph` | number | `1.0` | How far a reading may smear across that window before the unit refuses it rather than printing a number. |
| `Config.forkHz` | number \| nil | `nil` | The fork the operator carries, in Hz. `nil` issues the one matching this band — the ordinary case. |
| `Config.forkMph` | number | `65.0` | What the issued fork is stamped with. Display only; the reading comes from the frequency. |
| `Config.forkRingMs` | number | `4000` | How long a struck fork rings. |
| `Config.rfiEnabled` | boolean | `true` | Whether the unit carries an RFI sensor. A conforming radar inhibits the speed display while interference is present, rather than showing a number that may not have come off a car. The transmitter stays up; a locked window and the patrol window both survive. |
| `Config.rfiRange` | number, 0 or more | `60.0` | Metres. How close an interfering source has to be. |
| `Config.rfiHoldMs` | number, 0 or more | `1500` | How long one detection keeps the display inhibited. |
| `Config.rfiFromRadar` | boolean | `true` | Another radar on the air nearby interferes. The documented case, and the one officers are trained around: two units working the same stretch. |
| `Config.rfiSameBandOnly` | boolean | `true` | Only a unit on your own band interferes. True is the honest physics — a receiver's passband is tuned to its band, so a Ka head is not inhibited by an X one. |
| `Config.rfiFromOwnSiren` | boolean | `false` | Your own siren interferes. Real but historic: strobe supplies and high-power two-way transmitters troubled older installs, and a modern conforming head is hardened against the equipment on its own roof. Note that sirens run for most of a pursuit. |
| `Config.rfiFromNearbySiren` | boolean | `false` | A nearby vehicle's siren interferes. Same reasoning as `rfiFromOwnSiren`. |
| `Config.plateRange` | number | `30.0` | Metres. Plates are read off a much shorter ray than speeds are. |
| `Config.boloWebhook` | string | `""` | Discord webhook for BOLO activity — a plate added, removed, or seen by a reader. Posted as a Components v2 message. Empty disables it; anything that is not a `https://discord.com/api/webhooks/...` URL is treated as unset and reported at startup. |
| `Config.integrations` | table | see `config.lua` | Reporting plate reads to the CAD this server runs, as one block: `cad.enabled`, `cad.provider` (nil to use whichever supported CAD is running, or one of `lacore`, `sonoran`, `imperial`, `wasabi`, `tkmdt` to pin it), `cad.npcFilter`, `cad.queryOnRead`, `cad.queryOnLock`, `cad.minIntervalMs`, `cad.answerTtlMs`, `cad.timeoutMs` and `cad.notifyOfficer`. Off by default, and it holds no credential — every path is an export into the CAD's own resource. |
| `Config.screenRange` | number, 0 or more | `8.0` | Metres within which another vehicle's counting unit is still drawn on the prop. A READING distance, much shorter than any audio range; the vehicle you are aboard is exempt from it. |
| `Config.audioRange` | number, 1 or more | `32.0` | Metres within which the unit is HEARD by anyone near the car — lock tones, the rear-traffic alert and the doppler, from the direction of the vehicle. Must comfortably exceed `screenRange`: you should hear a unit well before you are close enough to read it. The falloff is solved from this number, so gain at exactly this distance is −50.5 dB whatever you set it to; tLib caps it at 250. |
| `Config.vehicleProp` | table | see `config.lua` | The radar prop on the dash: which models are offered, which is the default, and where it sits on each vehicle. Placements saved in-game win over this table. |
## Options that mislead
| Option | What to know |
| --- | --- |
| `Config.access.mode` | A list is an **OR**: `{ "ace", "job" }` passes if either does. `custom` is a function taking a player id. Every failure denies — an absent framework, an unset ace, a `custom` that throws |
| `Config.coneAngle` | A **half**-angle. Antennas quoted 12–15° wide are 6–7.5° here. Put the width in and the unit reads cars a lane and a half over |
| `Config.band` | Changes the doppler audio as well as what a detector listens for |
| `Config.calibration*` | Both `0`, so a unit reads true. Open the window and heads drift at every power-up |
| `Config.patrolShadowPull` | Live by default. The tell is the patrol window sagging below the speedometer. `0` disables it |
| `Config.rangeFactorMax` | Both ways: `2.0` clocks a lorry twice as far out **and** loses a motorcycle inside the quoted range |
| `Config.maxRange` | Bounded by what the game streams, a few hundred metres. Past that, readings depend on how busy the server is |
| `Config.fastThreshold`, `Config.targetHoldMs` | Anti-flicker margins. Lower either and a window flickers |
## Startup validation
tRadar validates `config.lua` at boot and prints every problem at once, naming the key, what was expected, what was found, and the fix.
- **A deleted key takes its shipped default.** Cut the file down to what you changed.
- **A misspelled key is a warning naming the key you meant.**
- **A value out of range is an error, never quietly replaced.** The radar refuses to deploy until you fix it.
## Settings that are gone
An update leaves your `config.lua` in place, so a file predating the `Config.access` block still carries the three flat keys. Nothing reads them.
| Gone | Replaced by | What to edit |
| --- | --- | --- |
| `Config.accessMode` | `Config.access.mode` | The same word in `mode`, inside the block |
| `Config.acePermission` | `Config.access.ace` | Copy the ace name into `ace`, set `mode = "ace"` |
| `Config.jobs = { "police" }` | `Config.access.job` | A name-to-minimum-grade map: `job = { police = 0 }`. `0` accepts any grade |
A file still carrying the old keys falls back to `Config.access`, and with no such block to `mode = "everyone"`. tRadar names each dead key at every start:
```
[tRadar] config.lua: Config.accessMode is not a setting this resource reads, so it is doing nothing.
```
`tradar_diag` prints the mode actually in force.
### Event names
The PascalCase `tRadar:` spellings are **removed in 1.0.0**, and a wrong FiveM event name raises nothing. Lowercase the `tRadar:` in your own resources: `tradar:plateRead`, `tradar:boloAdd`, `tradar:boloRemove`, `tradar:boloHit`, `tradar:boloRequest`, `tradar:boloList`.
Missing `tradar:plateRead` is the expensive one: your CAD is never asked about plates, so every read shows no flag. The server exports `addBoloPlate`, `removeBoloPlate` and `getBoloPlates` are unchanged.
## tradar_diag
Prints versions, the config verdict, the live access mode, the device's tuning, the installed layouts and whether tDetector is running, to the **server** console. Safe to paste into a support thread.
```cfg
add_ace group.admin command.tradar_diag allow
```
## Next
- [Usage](/docs/tRadar/usage) — what the operator does with all of this.
- [Layouts](/docs/tRadar/layouts) — the faceplates and `Config.layoutBands`.
# tRadar Layouts (/docs/tRadar/layouts)
A layout is a skin: a folder under `layouts/` holding a `chassis.png` and an inert `ui.html`. Five ship; more install through tLib's marketplace with no file edit and no restart.
| Folder | Device class | Size | What it is |
| --- | --- | --- | --- |
| `KBX-2200` | `radar` | 520 × 157 | Dual-antenna head, both windows each |
| `SLX-1100` | `radar` | 520 × 145 | Single-antenna compact head |
| `CHX-800` | `radar` | 520 × 131 | Eight-key control head |
| `PRX-400` | `plate` | 420 × 101 | Plate reader |
| `RCX-150` | `remote` | 220 × 488 | Handheld remote, no glass |
Players pick a skin per device class in `/tradar`. `Config.defaultRadarLayout`, `Config.defaultPlateLayout` and `Config.defaultRemoteLayout` set what a new player starts with; an uninstalled name falls back to the first installed skin of that class.
## Per-skin bands
`Config.layoutBands` gives one faceplate its own band, so a server can ship a Ka head and a K head without editing either. Faceplates print the band they are on.
```lua
Config.layoutBands = {
["KBX-2200"] = { band = "ka", frequency = 34.7 },
["SLX-1100"] = { band = "k" },
}
```
The shipped entries are **KBX-2200** 34.7 GHz, **SLX-1100** 35.5 GHz, **CHX-800** 33.8 GHz. A skin with no entry uses `Config.band`; omit `frequency` and the band's own default is used, never `Config.frequency`.
The same head on X and on K — the lit letter above the target window is the only change, and it is how an officer knows which gun they are holding:
`["KBX-2200"] = "ka"` is **silently ignored** and the skin keeps `Config.band`.
## Building your own
A layout declares what it is on its root element. That declaration — never the folder name — puts a skin in the right picker.
```html
```
A skin sized in viewport units, or one that overflows, is never registered with the HUD editor and cannot be repositioned at all.
Bind it to the live view with tLib's `data-hud-*` grammar.
| Attribute | What it does |
| --- | --- |
| `data-hud-text` | Prints a published value |
| `data-hud-led` | Lights an element from a boolean |
| `data-hud-show` | Shows an element while a value is truthy |
| `data-hud-eq` | Shows an element while a value equals a given one |
| `data-hud-attr` | Copies a value onto an attribute |
| `data-hud-btn` | Makes an element a key, naming the action it fires |
tWeb's marketplace validator rejects `