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.

Available since hz_lib v1.1.0. Older versions only shipped the framework / inventory bridge.

Opening the panel

In-game (chat, F8 console, or keybind):

/hzpanel

  • Console-only (server F8) — /hzpanel from the server console does not open the NUI. Type it from in-game.
  • Requires the ACE permission configured under HZBridge.Panel.AcePermission (default admin) — see Permissions setup below.
  • Press Escape or click the close button to leave. Sessions are token-gated and expire after HZBridge.Panel.SessionTokenTtlMs without activity (5 min default) — re-open to refresh.
You can also open straight to a specific module's tab from another script:

-- 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.

qb-core boilerplate gotcha: a fresh qb-core 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_ace lines to copy-paste, with your license already interpolated
Look at the red error in your console — the fix is right there. Available since v1.1.1.
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.

RightGrants
viewRead the module's settings
configChange its saved settings
manageUse 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.admin by 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 AcePermission or command. 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 example hzaccess_recover admin).
The settings behind this (on/off, several roles, group discovery) are in Access control.

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:

ModuleWhat you can tune
hz_libGlobal theme — accent, surfaces, gradient mode, radius scale, fonts, objectives tracker position
HZ-WeatherZones (editor + map), forecast, time, seasons, events, config
HZ-TelevisionChannels, defaults, performance toggles
HZ-LoadingLoading Creator (live editor of the loading screen), telemetry
HZ-PauseMenuGeneral settings, server branding, HUD integration
HZ-TextUiTextUI Designer (look of the prompts)
HZ-BankingFeatures, 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-BetsOdds, stake limits, event sources
Third-party scripts can add their own tab simply by shipping a 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

TypeRenders asNotes
booleanToggle switch
numberNumeric input with min / max / stepSlider variant when step ≤ 1 and range is bounded
stringText input, optional pattern + maxLength
enumDropdown (single choice)Choices via choices = { 'a', 'b', 'c' }
enum-multiConstrained multi-select (toggle chips)New in v1.1.0 — stored as list<string>
colorHex colour pickerValidated as #RRGGBB
keybindKeybind capture (single key + modifiers)
list<string>Tag input (free-form add/remove)
list<object>Inline table editor with itemSchema columns
vehicle-listVehicle picker gridAuto-populated from GetAllVehicleModels()
weapon-listWeapon picker gridStatic catalog built into the panel
actionButton that fires a server eventUse for "Apply preset" / "Reset" style triggers
enum-actionDropdown of actions
viewFull-width custom React componentBuilt into hz_lib's panel, see Custom views

Sections, groups, tabs

  • section(id, { label, tab, dependsOn }, body) — visual grouping inside a module tab. tab is the sub-tab id (declared via module(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. opts supports default, description, requiresRestart, serverOnly, deprecated, hidden, dependsOn, plus the type-specific extras. serverOnly = true keeps 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. Return nil (ok) or a string (error message).
  • migrations({ [N] = function(values) ... end }) — bump schemaVersion and 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

AxisKeysEffect
Accentaccent / accentHi / goldSignature colour, its hover variant, and the colour for values (money, XP). Default: cyan #00B4FF / #0095D9 / amber #FFB830.
Surfacessurface / subpanel / tintOuter panel / inner sub-panel / hover tint. RGB only — opacity decided per consumer.
Gradient modegradientMode = 'gradient' \| 'solid'solid (default) collapses every accent gradient to a flat fill — calmer / office-tool feel.
RadiiradiusNone / Xs / Sm / Md / Lg / XlSix-tier corner scale. Default 0/4/8/12/16/20.
FontsfontDisplay / fontBody / fontNumberGoogle Fonts for titles and labels, body text, and numbers. Default Barlow Condensed / Barlow / Barlow Condensed.
Seven built-in presets set all of these in one click: Cyan (the default), Vice, Ember, Toxic, Amethyst, Crimson and Mono. Every value stays editable afterwards. You can also save your own presets: they are kept on your own game client, not shared with the other admins.

Objectives tracker position

The same tab places the objectives tracker shown by HZ jobs and missions (see Objectives Tracker):

SettingValuesEffect
Screen sideleft (default), rightSide 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).

Shortcut: add '@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 buggy bridge_schema.lua can fail to load (logged) but can't crash the server.
  • Rate-limited writes — default 10 writes per 5s per source. Configurable via HZBridge.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 / max checks, then section-level invariant functions before the value lands on disk.
  • Audit log — every accepted save writes a line to data/_audit.log. Past 10 MB, the file is renamed data/_audit.<date>.<time>.log and a new one starts. hz_lib never deletes these files (HZBridge.Panel.AuditRetentionDays is 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>.json through a temporary file first. Fields marked requiresRestart are also staged in data/<module>.pending.json and 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.lua in your hz_lib folder (open, not encrypted)
  • Saved config per module: data/<module>.json, plus data/<module>.pending.json for changes waiting for a restart
  • Staff roles: data/_access.json
  • Audit: data/_audit.log