Admin Panel
hz_lib ships a centralised admin panel that every HZ-Script module plugs into. Instead of each script shipping its own command + UI for config, everything lives behind a single /hzpanel accessible to admins. The panel auto-builds a typed editor for every config field declared in each module's bridge_schema.lua.
Opening the panel
In-game (chat, F8 console, or keybind):
/hzpanel
- Console-only (server F8) —
/hzpanelfrom the server console does not open the NUI. Type it from in-game. - Requires the ACE permission configured under
HZBridge.Panel.AcePermission(defaultadmin) — see Permissions setup below. - Press
Escapeor click the close button to leave. Sessions are token-gated and expire afterHZBridge.Panel.SessionTokenTtlMswithout activity (5 min default) — re-open to refresh.
-- server export — opens the panel for `src` and preselects the named module
exports['hz_lib']:OpenPanel(src, 'hz_weather')
Permissions setup
The panel is gated by the canonical FXServer admin ACE node. Two server.cfg lines are required:
add_principal identifier.license:YOUR_LICENSE group.admin
add_ace group.admin admin allow
Replace YOUR_LICENSE with the player license from your server (visible by typing /hzpanel once — the failed-check console output prints all your identifiers + a copy-paste-ready block with your license already interpolated).
You can paste both lines directly into the server console for an instant fix — no restart required. If you put them in server.cfg, restart FXServer (or re-exec server.cfg) so they're loaded.
server.cfg ships with add_ace group.admin command allow but not add_ace group.admin admin allow. qb-core's own admin menu uses its DB-based qbcore_admins table rather than the canonical admin ACE node, so the line is absent. Almost every hz_lib permission ticket comes from this — add the second line and you're done.A player who holds the command ACE (allowed to run any command) can also open the panel. On first boot, the framework admin groups (admin, god, superadmin, owner on ESX, QBCore, QBox or Ox Core) are added as staff roles with full access to the modules, so admins tracked by your framework can open the panel without the ACE setup. But ACE is the recommended path because it's framework-agnostic and auditable in one place.
If the check fails, the server console prints :
- The exact ACE node being checked
- All your player identifiers
- An ACE probe matrix (which nodes are granted, which aren't)
- The two exact
add_principal+add_acelines to copy-paste, with your license already interpolated
command.hzpanel does NOT grant the panel. A common mistake is to try add_ace identifier.X command.hzpanel allow. That node is unused by hz_lib — the check is on the configured AcePermission (default admin), not on the command name.Custom ACE node
If you don't want to use the canonical admin node (e.g. you only want a specific subset of staff to open the panel without giving them every other admin command), configure a custom node in config.lua :
HZBridge.Panel.AcePermission = 'hzbridge.panel.admin'
Then in server.cfg :
add_principal identifier.license:YOUR_LICENSE group.hzbridge.staff
add_ace group.hzbridge.staff hzbridge.panel.admin allow
The fallback (when AcePermission is nil or '') is 'admin' — aligned on the config default since v1.1.1. Older versions used 'hz_lib.admin' as the fallback, which was a documented mismatch and locked out customers who only had the canonical admin ACE granted. Upgrade to v1.1.1 if you're affected.
Staff roles
Access is not all or nothing: each staff role gets, per module, any of three rights.
| Right | Grants |
|---|---|
| view | Read the module's settings |
| config | Change its saved settings |
| manage | Use its live actions (for example, set the weather now) |
- Edit the roles in /hzpanel > Access control. Only a role allowed to edit access sees this tab, and only an ACE group can get that right.
- On first boot, the group behind
AcePermission(group.adminby default) gets full access and the right to edit access, so installing hz_lib locks nobody out. - A player whose groups match no role still gets full access if he holds
AcePermissionorcommand. A player who matches a role keeps that role's limits. - Rights are checked again on every action: a demoted admin loses access on a panel that is already open.
- Locked out? Run
hzaccess_recover <group>in the server console (for examplehzaccess_recover admin).
What you can edit
The panel auto-discovers every resource that ships a bridge_schema.lua file at its root. With hz_lib v1.2.0, these HZ resources ship a schema and get their own tab:
| Module | What you can tune |
|---|---|
| hz_lib | Global theme — accent, surfaces, gradient mode, radius scale, fonts, objectives tracker position |
| HZ-Weather | Zones (editor + map), forecast, time, seasons, events, config |
| HZ-Television | Channels, defaults, performance toggles |
| HZ-Loading | Loading Creator (live editor of the loading screen), telemetry |
| HZ-PauseMenu | General settings, server branding, HUD integration |
| HZ-TextUi | TextUI Designer (look of the prompts) |
| HZ-Banking | Features, economy, branding, access, shared accounts, cash and robberies, costs and limits, savings, loans, bills (1.0.1) |
| HZ-Fuel (1.0.1) | Payment, fuel, charging and jerry can prices, consumption, delivery driver pay and deposit |
| HZ-Bets | Odds, stake limits, event sources |
bridge_schema.lua — see the schema DSL section below.
A value saved in the panel wins over the script's own config file. A dot marks each setting changed in the panel, and its reset button drops the panel value: the setting follows the script's config file again (hz_lib 1.2.1 and newer). Up to hz_lib 1.2.0, the reset button saved the panel's own default instead.
The schema DSL
Each module's bridge_schema.lua is a small Lua DSL that declares the config the panel exposes. The DSL runs in a sandboxed environment (no _G, no raw io, restricted string / table / math subsets) so a buggy or malicious schema can't break the server.
Minimal example
-- resources/your-script/bridge_schema.lua
module('your-script', {
schemaVersion = 1,
label = { en = 'Your Script', fr = 'Ton script' },
}, function()
section('general', {
label = { en = 'General', fr = 'Général' },
}, function()
field('Enabled', 'boolean', {
default = true,
label = { en = 'Enabled', fr = 'Activé' },
description = {
en = 'Master on/off switch for the script.',
fr = 'Interrupteur global du script.',
},
})
field('PlayerLimit', 'number', {
default = 32, min = 1, max = 256, step = 1,
label = { en = 'Max concurrent players', fr = 'Joueurs simultanés max' },
})
end)
end)
That's it — open /hzpanel, the "Your Script" tab appears with two typed fields, value changes are written back to disk and broadcast to every client that subscribes.
Field types
| Type | Renders as | Notes |
|---|---|---|
boolean | Toggle switch | |
number | Numeric input with min / max / step | Slider variant when step ≤ 1 and range is bounded |
string | Text input, optional pattern + maxLength | |
enum | Dropdown (single choice) | Choices via choices = { 'a', 'b', 'c' } |
enum-multi | Constrained multi-select (toggle chips) | New in v1.1.0 — stored as list<string> |
color | Hex colour picker | Validated as #RRGGBB |
keybind | Keybind capture (single key + modifiers) | |
list<string> | Tag input (free-form add/remove) | |
list<object> | Inline table editor with itemSchema columns | |
vehicle-list | Vehicle picker grid | Auto-populated from GetAllVehicleModels() |
weapon-list | Weapon picker grid | Static catalog built into the panel |
action | Button that fires a server event | Use for "Apply preset" / "Reset" style triggers |
enum-action | Dropdown of actions | |
view | Full-width custom React component | Built into hz_lib's panel, see Custom views |
Sections, groups, tabs
section(id, { label, tab, dependsOn }, body)— visual grouping inside a module tab.tabis the sub-tab id (declared viamodule(name, { tabs = { ... } })).dependsOn = { field = 'X', equals = true }collapses the section when the parent condition is false.group(id, { label }, body)— inline collapsible group inside a section.field(id, type, opts)— a single field.optssupportsdefault,description,requiresRestart,serverOnly,deprecated,hidden,dependsOn, plus the type-specific extras.serverOnly = truekeeps the value on the server (never sent to players): use it for secrets such as webhook URLs.invariant(sectionId, fn)— cross-field validation. Runs on every save attempt. Returnnil(ok) or a string (error message).migrations({ [N] = function(values) ... end })— bumpschemaVersionand ship a migration to rewrite old saved values forward.
Custom views
Some HZ scripts need more than a form: a map editor, a forecast graph, a loading screen editor. They declare a view field, with an events allowlist of the server events the view may trigger. The React component itself is built into hz_lib's panel, and the panel source is not shipped: a third-party schema uses the field types above.
HZ-Weather ships six views: Map, ZoneEditor, Events, Forecast, SeasonsPanel, TimePanel.
Theme cascade (Appearance)
The Appearance tab in hz_lib centralises the visual tokens every HZ NUI shares. A single change retints HZ-Weather, HZ-AudioMixer, HZ-Television live — no restarts. New scripts plugging in inherit the cascade automatically as long as their NUI reads the canonical --hz-* CSS variables.
Axes you control
| Axis | Keys | Effect |
|---|---|---|
| Accent | accent / accentHi / gold | Signature colour, its hover variant, and the colour for values (money, XP). Default: cyan #00B4FF / #0095D9 / amber #FFB830. |
| Surfaces | surface / subpanel / tint | Outer panel / inner sub-panel / hover tint. RGB only — opacity decided per consumer. |
| Gradient mode | gradientMode = 'gradient' \| 'solid' | solid (default) collapses every accent gradient to a flat fill — calmer / office-tool feel. |
| Radii | radiusNone / Xs / Sm / Md / Lg / Xl | Six-tier corner scale. Default 0/4/8/12/16/20. |
| Fonts | fontDisplay / fontBody / fontNumber | Google Fonts for titles and labels, body text, and numbers. Default Barlow Condensed / Barlow / Barlow Condensed. |
Objectives tracker position
The same tab places the objectives tracker shown by HZ jobs and missions (see Objectives Tracker):
| Setting | Values | Effect |
|---|---|---|
| Screen side | left (default), right | Side of the screen where the steps are listed |
| Height (% from the top) | 0 to 90 (default 26) | Raise it if the list covers another HUD element |
How modules consume it
The full payload is broadcast every time the admin saves:
-- server (any resource)
AddEventHandler('HZ-Bridge:theme:updated', function(theme)
-- theme: { preset, accent, accentHi, gold, surface, subpanel, tint,
-- gradientMode, radiusNone, radiusXs, radiusSm, ..., radiusXl,
-- fontDisplay, fontBody, fontNumber,
-- fonts = { display, body, number, href } }
end)
-- client
RegisterNetEvent('HZ-Bridge:theme:updated', function(theme)
SendNUIMessage({ action = 'theme', data = theme })
end)
fonts holds ready-to-use CSS font stacks and one Google Fonts stylesheet URL (href). In your NUI, write each key as a CSS variable on :root (e.g. --hz-accent-rgb, --hz-surface-rgb, --hz-radius-md). Components reference the variables via rgb(var(--hz-accent-rgb) / 0.45) / var(--hz-radius-md) so the cascade is automatic.
Get the current theme synchronously on boot (server):
local theme = exports['hz_lib']:GetTheme()
Or request it via TriggerServerEvent('HZ-Bridge:theme:request') — the server replies with TriggerClientEvent('HZ-Bridge:theme:updated', src, theme).
'@hz_lib/ui/relay.lua' to your client_scripts and load https://cfx-nui-hz_lib/ui/hz-ui.css and https://cfx-nui-hz_lib/ui/hz-ui.js in your page. The relay sends the theme to your NUI and the kit applies it, on load and on every change.Safety + audit
- Sandboxed schemas — DSL runs without raw
io,os,debug, and with a restricted standard library. A buggybridge_schema.luacan fail to load (logged) but can't crash the server. - Rate-limited writes — default
10 writes per 5sper source. Configurable viaHZBridge.Panel.RateLimitWrites/RateLimitWindowMs. - Session tokens — every panel open issues a token that expires after 5 minutes without activity; expired tokens get a fresh bootstrap on next request.
- Validation pipeline — every save goes through field type validation, optional
pattern/min/maxchecks, then section-levelinvariantfunctions before the value lands on disk. - Audit log — every accepted save writes a line to
data/_audit.log. Past 10 MB, the file is renameddata/_audit.<date>.<time>.logand a new one starts. hz_lib never deletes these files (HZBridge.Panel.AuditRetentionDaysis not applied in v1.2.0): delete the old ones yourself if you need a retention limit. - Atomic writes — the saved config per module is written to
data/<module>.jsonthrough a temporary file first. Fields markedrequiresRestartare also staged indata/<module>.pending.jsonand apply when the resource restarts. - Rights checked on every action — not just at panel open. A revoked admin can't keep editing on a still-open panel.
Reference
- Schema DSL source:
modules/panel/schema_dsl.luain your hz_lib folder (open, not encrypted) - Saved config per module:
data/<module>.json, plusdata/<module>.pending.jsonfor changes waiting for a restart - Staff roles:
data/_access.json - Audit:
data/_audit.log
