Events, state bags & commands ​
Server events ​
server
Local server events (AddEventHandler), fired with TriggerEvent after np_inventory did the work:
| Event | Arguments | Fired when |
|---|---|---|
np_inventory:server:ready |
np_inventory started and loaded the players that were already online | |
np_inventory:server:playerLoaded |
src, owner |
A character's inventory is loaded |
np_inventory:server:playerUnloaded |
src, owner |
Saved and unloaded (logout, drop, character switch) |
np_inventory:server:itemAdded |
src | nil, invId, item, count |
Items were added to an inventory. src is the owning player, nil for stashes, trunks, … |
np_inventory:server:itemRemoved |
src | nil, invId, item, count |
Items were removed |
np_inventory:server:used |
src, item |
A use completed (also framework usable items). item is the slot before the use |
np_inventory:server:opened |
src, invId |
A player opened an inventory (the secondary, or their own) |
np_inventory:server:closed |
src, invId |
… and closed it |
np_inventory:server:action |
src, action, item, invId, slot |
A custom item action passed its hooks |
np_inventory:status |
src, deltas |
Standalone only: consume deltas for hunger / thirst / stress, for your own status script |
AddEventHandler('np_inventory:server:used', function(src, item)
if item.name == 'cigarettes' then TriggerClientEvent('my_smoke:start', src) end
end)
AddEventHandler('np_inventory:server:itemAdded', function(src, invId, item, count)
if src and item.name == 'goldchain' then print(('%d got %d gold chains'):format(src, count)) end
end)
Client events ​
client
Local client events (AddEventHandler):
| Event | Arguments | Fired when |
|---|---|---|
np_inventory:opened |
type, id |
The inventory opened (type = 'player' for your own) |
np_inventory:closed |
It closed | |
np_inventory:itemCount |
name, count |
The total count of an item in your pockets changed (0 when it's gone) |
np_inventory:currentWeapon |
item | nil |
A weapon was drawn or put away |
np_inventory:robbed |
active, by |
Someone started (or stopped) robbing you |
np_inventory:radio |
item |
The radio was used and no radio resource or pma-voice is running (Config.BuiltinItems.radio.event) |
np_inventory:phone |
item |
The phone was used and np_phone isn't running (Config.BuiltinItems.phone.event) |
With ox compatibility the same changes are mirrored as ox_inventory:itemCount and ox_inventory:currentWeapon
(Compatibility).
Listened to:
| Event | Arguments | What np_inventory does |
|---|---|---|
np_ccs:shotFired |
weaponHash, to |
A prone shot from np_crouch-crawl-shoot. If weaponHash is the drawn weapon, it counts as one shot for durability and jams. When an IsPedShooting frame for the same shot arrives within 150 ms it is counted once, not twice. Its bullet fallback never sets IsPedShooting, so without this those shots would not wear the weapon |
AddEventHandler('np_inventory:itemCount', function(name, count)
if name == 'radio' and count == 0 then exports['pma-voice']:setRadioChannel(0) end
end)
AddEventHandler('np_inventory:currentWeapon', function(item)
print(item and ('drew %s (%s)'):format(item.name, item.metadata.serial) or 'holstered')
end)
Server → client net events ​
These are internal (TriggerClientEvent from np_inventory to np_inventory). Listed so you know what they are; don't
trigger them yourself.
| Event | Arguments | Purpose |
|---|---|---|
np_inventory:rpc |
id, result |
RPC answers |
np_inventory:client:open / :close |
payload / |
Server-forced open (admin, OpenInventory, a bag opened without the UI) / close |
np_inventory:client:update |
{ inventories, money? } |
Fresh views for everyone who has them open; the owner always gets pockets and equipment |
np_inventory:client:secondary / :container |
{ secondary | container = view | false } |
Right panel / bag panel swapped or closed |
np_inventory:client:feed |
entries |
Item feed (+2 Water) |
np_inventory:client:notify |
{ type, title, message, icon?, tint? } |
Toast (np_hud's Notify is used instead while it runs) |
np_inventory:client:drops / :dropAdd / :dropRemove |
list / drop / id | Ground drops |
np_inventory:client:use |
{ token, slot, inv, name, use, client, close, item } |
An accepted use: play the progress, answer use:finish |
np_inventory:client:weapon |
{ action, slot, name, hash, ammo, durability, components, clip, … } |
Draw, holster, update |
np_inventory:client:status |
deltas |
Health / armour from consume |
np_inventory:client:shop / :shopRegistered |
payload / info | Shop screen / a runtime shop's prompt data |
np_inventory:client:builtinShops |
ids |
Built-in shops switched off while np_shops runs (Config.NpShops; {} = all on). Broadcast on every switch and sent on login. The start state is GlobalState.np_inventory_shops_off |
np_inventory:client:stashRegistered |
{ id, label, coords, radius, groups, icon, tint, personal?, pin? } |
A runtime stash with coords (pin is only true, never the PIN). Broadcast and sent on every login |
np_inventory:client:itemRegistered |
name, def |
A runtime item (RegisterItem). Broadcast and sent on every login |
np_inventory:client:revive |
{ heal } |
Adrenaline revive when the framework has no revive event (standalone) |
np_inventory:client:crafting / :craftingUpdate |
payload | Crafting screen and queue ticks |
np_inventory:client:give |
payload | Give picker |
np_inventory:client:trade / :tradeRequest |
action, data / data |
Trade window / incoming request |
np_inventory:client:document |
{ item, from, own? } |
Show a document card |
np_inventory:client:robbed |
{ active, by? } |
To the victim of a rob |
np_inventory:client:anim |
{ type, target? } |
Give, receive, search, drop and pick-up animations |
On qb / qbx np_inventory also sends hud:client:UpdateNeeds and hud:client:UpdateStress after hunger, thirst or
stress changed, and on ESX esx_status:add / esx_status:remove.
State bags ​
| State bag | Set by | Meaning |
|---|---|---|
LocalPlayer.state.invOpen |
np_inventory | The inventory UI is open (local) |
LocalPlayer.state.handsUp |
np_inventory | Hands up (replicated). The server reads it for robbing |
LocalPlayer.state.invBusy |
your scripts | true blocks opening, the hotbar and uses, and closes an open inventory (ox compatible) |
LocalPlayer.state.invHotkeys |
your scripts | false disables the hotbar keys (ox compatible) |
LocalPlayer.state.proneDeployed |
np_crouch-crawl-shoot | true while aiming prone. No auto reload on an empty clip, npinv_reload does nothing, and reloads never call MakePedReload (it breaks the prone pose). See Exports → Prone fire |
GlobalState.np_inventory_usable |
np_inventory (server) | Names of items that are only usable through a framework callback |
np_inventory also reads the common downed and cuffed state bags of other players (isDead, dead, isDowned,
downed, isCuffed, cuffed, handcuffed) on the client to decide who is robbable; the server asks the framework.
-- your minigame
LocalPlayer.state:set('invBusy', true, false)
-- …
LocalPlayer.state:set('invBusy', false, false)
Keys ​
Registered with RegisterKeyMapping, so players rebind them under Settings → Key Bindings → FiveM:
| Mapping | Default | Action |
|---|---|---|
npinv |
TAB (Config.Keys.inventory) |
Open the inventory with the closest trunk, glovebox, drop, stash or robbable player |
npinv_slot1 … npinv_slot5 |
1–5 (Config.Keys.hotbar) |
Use / draw the hotbar slot |
npinv_reload |
R |
Reload the drawn weapon from ammo items, or clear a jam. Does nothing while prone deployed (np_crouch-crawl-shoot reloads through reloadWeapon()) |
npinv_handsup |
X (Config.Keys.handsUp) |
Hands up / down |
npinv_cancel |
X |
Cancel a progress bar (only np_inventory's own bar; np_hud handles its own) |
npinv_trade_accept / npinv_trade_decline |
Y / N |
Answer a trade request |
World prompts use E (open a stash, shop, bench, evidence locker, search a prop, pick up a drop) and G (open a
drop). Inside the inventory see Controls.
Commands ​
| Command | Side | Description |
|---|---|---|
/trade [id] |
client | Ask the closest player (or server id id) to trade |
/giveitem <id|inventory> <item> [count] [metadata json] |
server | Admin: add items to a player (server id) or an inventory (stash:lsmd_locker, trunk:AB12CD34, a stash id, …). Metadata as JSON: /giveitem 3 weapon_pistol 1 {"registered":"LSPD"} |
/clearinv <id|inventory> [keep …] |
server | Admin: empty it, keeping the listed item names |
/openinv <id|inventory> |
server | Admin: open it in admin mode (no access checks). In game only |
/itemlist [filter] |
server | Admin: list items (name, label, weight, category); in chat, or a table in the server console |
The admin commands need the permission node np_inventory.admin, granted in np_admin (see
Installation → Permissions); the server console may always use them. The same
operations are np_admin staff actions under Resource tools: Give item, Clear inventory, Open inventory and
Open stash / inventory id.
Offline characters' pockets can't be opened with /openinv. Every admin command is logged (admin).
Logs ​
Every give, trade, drop, pick-up, purchase, craft, rob, frisk, confiscation, admin command, lockpick attempt,
adrenaline revive, legacy import overflow (import) and move into someone else's inventory is written to np_inventory_logs (batched every 5 s and on stop): action, actor (character), target,
inventories, item, count, metadata, coordinates and extra data. The actions listed in Config.Logs.actions are also
posted as a Discord embed to the webhook (set np_inventory_webhook "…" in server.cfg). While np_admin runs, every
row is also forwarded to its audit log under the category np_inventory; the database log
and the webhook stay as they are.