Integration
How to make your framework and other resources use np_hud's notifications, seatbelt, progress bar and hotbar.
Framework notifications
There are two ways to do it.
- Capture (no edits): set
Config.CaptureFrameworkNotify = true. np_hud then also listens to the net eventsQBCore:Notify,esx:showNotificationandox_lib:notify. The framework's own UI still shows the message, so players see it twice. Capture only catches notifications the server sends through those events. Direct client calls (QBCore.Functions.Notify(...),ESX.ShowNotification(...),lib.notify(...)) never go through an event. - Redirect (recommended): change the framework's notify function once so that every notification goes to np_hud, and leave
CaptureFrameworkNotify = false. Each snippet below is a few lines. Keep them in a patch file, because a framework update overwrites them.
np_hud maps the type names itself (primary → info, warn → warning, danger → error, …).
-- qb-core/client/functions.lua: replace the body of QBCore.Functions.Notify
function QBCore.Functions.Notify(text, texttype, length, icon)
if GetResourceState('np_hud') == 'started' then
local title, message = nil, text
if type(text) == 'table' then title, message = text.caption, text.text end
exports.np_hud:Notify({ title = title, message = message, type = texttype, duration = length, icon = icon })
return
end
-- original body below (fallback when np_hud isn't running)
end-- es_extended/client/functions.lua
function ESX.ShowNotification(message, notifyType, length, title, position)
if GetResourceState('np_hud') == 'started' then
return exports.np_hud:Notify({ title = title, message = message, type = notifyType, duration = length })
end
return IsResourceFound('esx_notify') and exports['esx_notify']:Notify(notifyType or 'info', length or 5000, message, title, position)
end-- ox_lib/resource/interface/client/notify.lua: at the top of function lib.notify(data)
if GetResourceState('np_hud') == 'started' then
return exports.np_hud:Notify({ title = data.title, message = data.description, type = data.type,
duration = data.duration, icon = type(data.icon) == 'string' and data.icon or nil })
end- qb-core: the
QBCore:Notifynet event calls this function, so server-sideTriggerClientEvent('QBCore:Notify', …)is covered too. - ESX:
esx:showNotificationcalls this function, so server-side calls are covered too. GTA colour codes (~r~) are only stripped in capture mode. If your scripts use them, strip them in the snippet:message:gsub('~%a~', ''). - ox_lib:
ox_lib:notifyis registered asRegisterNetEvent('ox_lib:notify', lib.notify), so one change covers client and server calls. - Qbox: qbx_core sends everything through ox_lib (
Notify→lib.notify), so patch ox_lib. To change only qbx, editqbx_core/client/functions.lua→Notify(...)and callexports.np_hud:Notify({ title = title, message = description, type = notifyType, duration = duration })instead oflib.notify.
Seatbelt
np_hud owns the replicated state bag LocalPlayer.state.seatbelt, so the server can read Player(src).state.seatbelt.
- Other resources read the state bag or call
exports.np_hud:SetSeatbelt(true|false)/GetSeatbelt(). - Another seatbelt script: set
Config.Seatbelt.enabled = false, then have that script callLocalPlayer.state:set('seatbelt', on, true). The HUD icon follows the bag. - Cruise control: np_hud doesn't ship one. A cruise script can set
LocalPlayer.state:set('cruise', true, false)and the vehicle zone shows the indicator.
Progress bars
To replace progressbar or ox_lib's progressBar, call exports.np_hud:Progress(...). See Progress bars.
Interaction prompts
Call ShowPrompt / HidePrompt from ox_target, from zone scripts or from your own resources. See Interaction prompts.
Inventories
Push the hotbar from your inventory with SetHotbar. See Hotbar.
Cutscenes and other UIs
Hide the HUD while another full-screen UI is open:
exports.np_hud:SetVisible(false)
-- ...
exports.np_hud:SetVisible(true)The HUD also hides itself while the pause menu is open, while the character is loading, and when the player turns it off with /hud.
np_helicam
No setup needed. np_hud listens for np_helicam's local client events:
np_helicam:fullscreen: the HUD hides while the helicopter camera or a ground unit's live feed is up. np_helicam draws its own overlay there.np_helicam:contextMap: while np_helicam has the minimap (camera context map or the F7 Air Support map), the HUD hides and leaves the minimap alone. When np_helicam gives the minimap back, np_hud re-applies its own layout.
If np_hud starts while the camera is already up, it asks np_helicam's client exports IsFullscreen and IsMinimapHeld. Start order doesn't matter.