Exports & API
hz_lib exposes 140+ exports usable from any resource. All exports are available via exports['hz_lib'].
Meta / Detection
-- Client & server
local Bridge = exports['hz_lib']:GetBridge() -- full Bridge table (advanced usage)
local framework = exports['hz_lib']:GetDetectedFramework() -- 'esx', 'qbcore', 'qbox', etc.
local inventory = exports['hz_lib']:GetDetectedInventory() -- 'ox_inventory', etc.
-- Client only
local notify = exports['hz_lib']:GetDetectedNotifications() -- 'ox_lib', etc.
local dispatch = exports['hz_lib']:GetDetectedDispatch() -- 'cd_dispatch', etc.
local target = exports['hz_lib']:GetDetectedTarget() -- 'ox_target', etc.
local menu = exports['hz_lib']:GetDetectedMenu() -- 'ox_lib', 'qb-menu', etc.
-- Server only
local banking = exports['hz_lib']:GetDetectedBanking() -- 'qb-banking', 'hz_banking', 'none', etc.
Framework
Client
-- Get current player job
local job = exports['hz_lib']:GetPlayerJob()
-- Get full player data
local data = exports['hz_lib']:GetPlayerData()
Server
-- Get player info
local job = exports['hz_lib']:GetPlayerJob(source)
local data = exports['hz_lib']:GetPlayerData(source)
local charId = exports['hz_lib']:GetPlayerCharId(source)
local name = exports['hz_lib']:GetPlayerName(source)
-- Money
local canPay = exports['hz_lib']:CanAfford(source, 500)
exports['hz_lib']:AddMoney(source, 500, 'bank')
exports['hz_lib']:RemoveMoney(source, 500, 'cash')
-- Job queries
local cops = exports['hz_lib']:GetPlayersWithJob({'police', 'sheriff'}, 0)
-- Usable items
exports['hz_lib']:RegisterUsableItem('phone', function(source)
-- player used the item
end)
Inventory (Server)
-- Check items
local count = exports['hz_lib']:GetItemCount(source, 'bread')
local itemData = exports['hz_lib']:GetItemData(source, 'bread')
local has = exports['hz_lib']:HasItem(source, 'bread', 1)
local canFit = exports['hz_lib']:CanCarry(source, 'bread', 5)
-- Add / Remove
exports['hz_lib']:AddItem(source, 'bread', 5)
exports['hz_lib']:RemoveItem(source, 'bread', 1)
exports['hz_lib']:AddItemToFit(source, 'bread', 5) -- Only add if can carry
-- Stash
exports['hz_lib']:OpenStash(source, 'my_stash', 'My Stash', 50, 100000)
local content = exports['hz_lib']:GetStashContent('my_stash')
Since v1.2.0, GetItemData(source, item, meta) returns an item of that name whose metadata holds every key and value of meta, or nil when none matches:
local card = exports['hz_lib']:GetItemData(source, 'id_card', { citizenid = 'ABC12345' })
if not card then
-- the player does not carry that exact card
end
- ox_inventory, qb-inventory and the QBCore native inventory search every stack of the item; ps, qs, codem, origen, tgiann, core and ak47 check the stack the inventory returns first.
- The ESX native inventory keeps no metadata, so a lookup with
metareturnsnil.GetItemDataalso returnsnilwhen the player has none of the item,RemoveItemreturnsfalsewhen the player does not have enough, andAddItemreturnsfalsefor an unknown item.
Banking / Society (Server)
Money on a society account (job or gang boss account), routed to the bank set in HZBridge.Banking.
local balance = exports['hz_lib']:GetSocietyMoney('mechanic')
exports['hz_lib']:AddSocietyMoney('mechanic', 500, 'Repair')
local paid = exports['hz_lib']:RemoveSocietyMoney('mechanic', 200, 'Parts') -- false if refused
-- Can the detected bank really read balances and take money?
local supports = exports['hz_lib']:GetBankingSupports() -- { get = true|false, remove = true|false }
Some banks only allow adding money. When supports.get or supports.remove is false, a balance of 0 or a false from RemoveSocietyMoney means "not supported", not "empty". With HZBridge.Banking = 'none', adding and removing return false and the balance is 0.
Notifications
Client
exports['hz_lib']:Notify('Item added!', 'success', 3000)
Server
-- Notify one player
exports['hz_lib']:NotifyPlayer(source, 'Welcome!', 'info', 5000)
-- Notify all players
exports['hz_lib']:NotifyAll('Server restart in 5 minutes', 'warning', 10000)
Types: 'info', 'success', 'warning', 'error'
Dispatch (Client)
exports['hz_lib']:SendDispatch({
title = 'Robbery in progress',
message = '10-90 at Fleeca Bank',
coords = GetEntityCoords(PlayerPedId()),
jobs = {'police'},
blip = { sprite = 161, color = 1, scale = 1.0 },
})
Target (Client)
-- Add target to entity
exports['hz_lib']:AddTargetEntity(entity, {
{ label = 'Open', icon = 'fas fa-door-open', action = function(e) end },
})
-- Add target to zone
exports['hz_lib']:AddTargetZone('my_zone', {
coords = vector3(0, 0, 0),
size = vec3(2.0, 2.0, 2.0), -- box size, optional (default 2 x 2 x 2)
rotation = 0.0, -- optional
options = { { label = 'Interact', action = function() end } },
})
-- Add target to model
exports['hz_lib']:AddTargetModel('prop_vendmach_01', {
{ label = 'Buy drink', icon = 'fas fa-coffee', action = function() end },
})
-- Remove
exports['hz_lib']:RemoveTarget('my_zone')
Menu / UI (Client)
Context Menu
-- Quick: register + show in one call
exports['hz_lib']:ContextMenu('my_menu', 'My Menu', {
{
title = 'Option 1',
description = 'Description here',
icon = 'fas fa-star',
onSelect = function(args) print('selected!') end,
},
{
title = 'Sub Menu',
menu = 'my_submenu', -- Opens another registered context
},
})
-- Or register and show separately
exports['hz_lib']:RegisterContext({
id = 'my_menu',
title = 'My Menu',
options = { --[[ ... ]] },
})
exports['hz_lib']:ShowContext('my_menu')
-- Hide / Query
exports['hz_lib']:HideContext()
local openId = exports['hz_lib']:GetOpenContext()
Input Dialog
local result = exports['hz_lib']:InputDialog('Enter Details', {
{ type = 'input', label = 'Name', placeholder = 'John Doe', required = true },
{ type = 'number', label = 'Amount', default = 100 },
{ type = 'select', label = 'Type', options = {
{ value = 'a', label = 'Option A' },
{ value = 'b', label = 'Option B' },
}},
})
if result then
local name, amount, type = result[1], result[2], result[3]
end
Alert Dialog
local response = exports['hz_lib']:AlertDialog({
header = 'Confirm Action',
content = 'Are you sure you want to proceed?',
centered = true,
cancel = true,
})
if response == 'confirm' then
-- User confirmed
end
TextUI
exports['hz_lib']:ShowTextUI('[E] Interact', {
position = 'right-center',
icon = 'fas fa-hand-pointer',
})
exports['hz_lib']:HideTextUI()
local isOpen = exports['hz_lib']:IsTextUIOpen()
Progress Bar
local completed = exports['hz_lib']:ProgressBar({
duration = 5000,
label = 'Crafting...',
canCancel = true,
disable = { move = true, combat = true },
anim = { dict = 'mini@repair', clip = 'fixing_a_player' },
})
if completed then
-- Finished
else
-- Cancelled
end
-- Circle variant
local done = exports['hz_lib']:ProgressCircle({ duration = 3000, label = 'Loading...' })
-- Query / Cancel
local active = exports['hz_lib']:IsProgressActive()
exports['hz_lib']:CancelProgress()
List Menu
exports['hz_lib']:RegisterMenu({
id = 'my_list',
title = 'Select Item',
options = {
{ label = 'Item 1', description = 'First item' },
{ label = 'Item 2', description = 'Second item' },
},
}, function(selected, scrollIndex, args)
print('Selected index:', selected)
end)
exports['hz_lib']:ShowMenu('my_list')
exports['hz_lib']:HideMenu()
Close All
exports['hz_lib']:CloseAllMenus() -- Close any open menu/context/input/alert/progress
Callbacks
Server
-- Register a server callback
exports['hz_lib']:RegisterCallback('myResource:getData', function(source, arg1, arg2)
return { money = 1000, name = 'John' }
end)
-- Call a client callback from server
local result = exports['hz_lib']:TriggerClientCallback(source, 'myResource:clientCheck')
Client
-- Call a server callback (blocking)
local data = exports['hz_lib']:TriggerCallback('myResource:getData', arg1, arg2)
print(data.money) -- 1000
-- Register a client callback
exports['hz_lib']:RegisterClientCallback('myResource:clientCheck', function()
return GetEntityCoords(PlayerPedId())
end)
Minigames (Client)
-- Progress with coordinates
local success = exports['hz_lib']:MinigameProgress(coords, 5000, {
label = 'Searching...',
})
-- Sequence minigame
local passed = exports['hz_lib']:SequenceMinigame(coords, 5, {
label = 'Enter code',
})
-- Skill check
local passed = exports['hz_lib']:SkillCheck('medium', {'w', 'a', 's', 'd'})
NPC Dialogue (Client)
A dialogue box at the bottom of the screen for talking to an NPC. The NPC's line types out, in time with its voice when you pass duration, then up to four numbered choices appear. While it is open, the camera frames the NPC over the player's shoulder, the NPC's mouth moves as it talks and both characters look at each other. The HUD is hidden, and the pause menu, combat and movement are blocked until it closes.
Players choose with the keys 1 to 4, the arrow keys and Enter, or the mouse. Enter (or a click on the line) shows the whole line at once. Escape closes the box. The key prompts follow HZBridge.Locale ('en' or 'fr').
| Export | Parameters | Returns |
|---|---|---|
OpenDialogue | (data) | dialogue id, or nil, 'busy' / nil, 'invalid' |
SayDialogue | (id, data) | boolean |
CloseDialogue | (id?) | boolean |
IsDialogueOpen | () | boolean |
SelectDialogue | (id, optionId) | boolean |
local dialogueId
dialogueId = exports['hz_lib']:OpenDialogue({
ped = ped, -- the NPC who speaks
name = 'Rosa Ortiz',
role = 'Mechanic',
text = 'Hey. What can I do for you?',
duration = 1900, -- length of the voice line you play (ms), optional
options = {
{ id = 'repair', label = 'Repair my car' },
{ id = 'leave', label = 'Never mind', close = true },
},
onSelect = function(optionId)
if optionId == 'repair' then
exports['hz_lib']:SayDialogue(dialogueId, {
text = 'That will be $250. Deal?',
options = {
{ id = 'pay', label = 'Deal', close = true },
{ id = 'no', label = 'Too expensive', close = true },
},
})
elseif optionId == 'pay' then
TriggerServerEvent('my_garage:repair')
end
end,
onClose = function(reason)
-- 'select', 'escape', 'replaced', 'closed', 'too_far' or 'stopped'
end,
})
if not dialogueId then
-- another resource's dialogue is on screen
end
OpenDialogue fields (SayDialogue takes the same, except ped and camera):
| Field | Default | Description |
|---|---|---|
ped | — | The NPC who speaks. Without it: no camera and no distance check |
name | — | Name shown as the title |
role | — | Small line above the name. false in SayDialogue removes it |
text | — | The NPC's line |
duration | reading pace | Length of the voice line in ms: the text types out over exactly that time |
options | none | Up to 4 { id, label, close? }, shown once the line is written. close = true closes the box after the choice |
camera | true | Frame the NPC. false keeps the gameplay camera |
focus | true | Keyboard and mouse go to the box. false = display only, no input |
talk | true | false = hz_lib does not move the NPC's mouth (when your resource animates it itself) |
maxDistance | 4.0 | Distance from the NPC, in metres, past which the dialogue closes |
onSelect | — | function(optionId, dialogueId), called on each choice |
onClose | — | function(reason), called once when the dialogue ends |
| Reason | When |
|---|---|
'select' | The player picked an option with close = true |
'escape' | The player pressed Escape |
'replaced' | Your resource opened a new dialogue |
'closed' | You called CloseDialogue |
'too_far' | The player walked past maxDistance, the NPC disappeared, or the NPC or the player died |
'stopped' | Your resource (or hz_lib) stopped |
- One dialogue on screen at a time. A new
OpenDialoguefrom your resource replaces yours. Another resource's dialogue is never taken over: you getnil, 'busy'. SayDialogueandCloseDialogueonly act on your own dialogue; withoutid, they target it.- Choice with
close = true: the camera, HUD and controls come back first, thenonSelect, thenonClose('select'). You can open your own menu fromonSelect. - Choice without
close: reply withSayDialoguefromonSelect. If you don't, the same choices come back. A line sent withoptions = {}(or no options) shows no choices. nameandroleleft out ofSayDialoguestay as they were.- hz_lib plays no voice: play your NPC's voice line yourself and pass its length as
duration. The game's menu sounds play on hover, choice and Escape. SelectDialogue(id, optionId)picks a choice on the player's behalf (scripted scenes, tutorials): the row shows selected for a moment, then it runs exactly like a player's choice. It returnsfalsewhile the line is still typing, or for an unknown id or option.- No camera when the player is in a vehicle, or when another script's camera is already active. If a wall is behind the player's shoulder, another angle is used.
- Texts are shown as given: translate them in your resource. An error in your callbacks is printed in the F8 console and does not break the dialogue.
Objectives Tracker (Client)
Shows the steps of a job or mission on the player's screen: a title, then each step with its state. The step in progress can carry a detail line, a counter and a progress gauge. hz_lib draws it, so every HZ script shares the same look, your theme colours and a single place on screen.
| Export | Parameters | Returns |
|---|---|---|
SetObjectives | (id, { kicker?, title, steps }) | boolean |
UpdateObjective | (id, stepId, patch) | boolean |
ClearObjectives | (id) | boolean |
-- Create (or replace) the 'delivery' tracker of your resource
exports['hz_lib']:SetObjectives('delivery', {
kicker = 'Delivery',
title = 'Objectives',
steps = {
{ id = 'load', text = 'Load the truck', detail = 'Warehouse 3, Elysian Island', value = 0, max = 12, unit = 'crates', state = 'current' },
{ id = 'drop', text = 'Deliver to Grove Street', state = 'todo' },
},
})
-- Progress, then the next step
exports['hz_lib']:UpdateObjective('delivery', 'load', { value = 5 })
exports['hz_lib']:UpdateObjective('delivery', 'load', { state = 'done' })
exports['hz_lib']:UpdateObjective('delivery', 'drop', { state = 'current' })
-- Job over
exports['hz_lib']:ClearObjectives('delivery')
Step fields:
| Field | Type | Description |
|---|---|---|
id | string | Step id, used by UpdateObjective |
text | string | Step label |
state | string | 'todo' (default), 'current' or 'done' |
detail | string | Second line, shown under the current step only |
value | number | Counter shown on the right of the step |
max | number | With value: shows value / max and a gauge on the current step |
unit | string | Unit after the counter (L, crates…) |
UpdateObjectivemergespatchinto one step (value,state,text,detail…). It returnsfalsewhen the tracker or the step does not exist.- Ids belong to your resource: two resources can both use
'delivery'without clashing. Several trackers stack in one column. - Five rows at most: the oldest done steps leave first, otherwise four steps and a
+Nrow. - Texts are shown as given: translate them in your resource.
- The tracker hides while the pause menu or the map is open, and is removed when your resource stops.
- When hz_lib restarts, it fires the client event
hz_lib:objectives:ready: send your trackers again from there.
AddEventHandler('hz_lib:objectives:ready', function()
if onJob then exports['hz_lib']:SetObjectives('delivery', currentTracker) end
end)
The list shows on the left of the screen by default. You can move it in /hzpanel > Appearance > Objectives tracker: Screen side (left or right) and Height (% from the top, default 26). Raise the height if the list covers another HUD element.
Admin Panel (Server)
-- Open the centralised admin panel for a player (same effect as them typing /hzpanel).
-- Second arg optionally preselects a module's tab.
exports['hz_lib']:OpenPanel(source)
exports['hz_lib']:OpenPanel(source, 'hz_weather')
See the Admin Panel guide for the schema DSL, field types, and view registration.
Theme (Server & Client)
The Appearance tab in the admin panel writes a single shared theme used by every HZ NUI. Resources can read the current theme synchronously, or subscribe to live updates.
Server
-- Get the current effective theme (accent + surfaces + gradient mode + radii + fonts).
local theme = exports['hz_lib']:GetTheme()
-- Subscribe to admin changes server-side.
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
-- Live updates from the admin panel.
RegisterNetEvent('HZ-Bridge:theme:updated', function(theme)
SendNUIMessage({ action = 'theme', data = theme })
end)
-- Pull the current theme on resource start so first paint is themed.
TriggerServerEvent('HZ-Bridge:theme:request')
The server replies via TriggerClientEvent('HZ-Bridge:theme:updated', src, theme) so the same handler runs for both initial sync and live updates.
