Bridges ​
np_inventory talks to frameworks only through NpInv.Framework. Each bridge file calls
NpInv.Bridge.shouldLoad('framework', name, resource) and returns early unless its resource is started and selected
(Config.Framework, or 'auto'). Files are numbered, so auto tries qbx_core → qb-core → es_extended, and
9_standalone.lua claims the slot when nothing else loaded. Detection runs once at start, so start the framework
before np_inventory, or set Config.Framework.
An explicitly selected framework also loads when it is installed but not started yet. That is the qbx case: with
provide 'ox_inventory', qbx_core depends on np_inventory and starts after it. The bridges look the framework up
lazily, on the first call. Every bridge call goes through pcall, so a missing export degrades instead of erroring.
Server contract ​
bridge/framework/server/. 0_common.lua holds shared helpers; qb and qbx share one implementation (qbFamily)
because their Player API is the same.
| Contract | Used for |
|---|---|
name |
'qbx', 'qb', 'esx' or 'standalone' |
getIdentifier(src) |
The character that owns the inventory |
getName(src) / getCharInfo(src) |
Inventory header, logs, document metadata |
getJob(src) |
Shop discounts, recipe job locks, the job chip |
getMoney / addMoney / removeMoney(src, account, n) |
'cash', 'bank', 'black_money' for shops and trades |
setCash(src, n) / setMoney(src, account, n) |
Item mode: framework cash (and ESX black money) := item count |
hasGroup(src, groups) |
Stashes, shops, benches, the evidence locker, police |
isDowned(src) / isCuffed(src) |
Robbing, blocked uses and opens |
isVehicleOwned(plate) |
Persistent trunks and gloveboxes |
hasLicense(src, name) |
Shop locks ('weapon', 'driver') |
addStatus(src, deltas) |
Hunger, thirst, stress from consume |
getSkill(src, name) / skills |
Recipe skill locks and the bench header. skills = true marks a framework with a skill system (qb / qbx); Config.Skills.get wins over both |
revive(target, heal) |
The adrenaline built-in item |
knows(src, target) |
Real names in the give picker (default false) |
canUseItem(name) / useItem(src, item) |
Framework usable items |
legacyItems(owner) |
The one-time import |
loadedPlayers() |
Players already logged in when np_inventory (re)starts |
onLoaded / onUnloaded / onMoneyChange |
Login, logout, cash changed outside np_inventory |
setItems(src, items) |
qb only: the Player.PlayerData.items mirror |
What each bridge does ​
| Contract | qbx (qbx_core) |
qb (qb-core) |
esx (es_extended) |
standalone |
|---|---|---|---|---|
| owner | citizenid |
citizenid |
identifier |
np_character CID, else license |
| name / document data | charinfo |
charinfo |
firstName, lastName, dateofbirth, sex, nationality |
np_character, else the player name |
| job | PlayerData.job |
PlayerData.job |
xPlayer.job |
none |
| money | Player.Functions.AddMoney / RemoveMoney / SetMoney |
same | add/remove/setAccountMoney (cash = ESX money) |
np_inventory_money |
| black money | the item | the item | the black_money account (synced in item mode) |
the item |
| groups | qbx_core:HasGroup, job and gang grade |
job and gang grade, QBCore.Functions.HasPermission |
job grade, xPlayer.getGroup() |
np_admin node np_inventory.group.<name> |
| downed / cuffed | metadata.isdead / inlaststand / ishandcuffed + state bags |
same | isDead + state bags |
state bags |
| vehicle owned | player_vehicles |
player_vehicles |
owned_vehicles |
SetVehicleOwned only |
| licences | metadata.licences |
metadata.licences |
user_licenses (esx_license, cached 60 s) |
np_admin node np_inventory.license.<name> or a <name>_license item |
| status | SetMetaData (0–100) + hud:client:UpdateNeeds / UpdateStress |
same | esx_status:add / remove |
local event np_inventory:status |
| skills | metadata.skills[name] |
same | none (requirements skipped) | none (requirements skipped) |
| revive | hospital:client:Revive |
same | esx_ambulancejob:revive |
np_inventory revives and heals itself (np_inventory:client:revive) |
| usable items | qbx_core:CanUseItem |
QBCore.Functions.CanUseItem |
ESX.GetUsableItems / ESX.UseItem |
none |
| legacy import | players.inventory |
players.inventory |
users.inventory |
none |
| xPlayer inventory functions | ESX's own, or np_inventory with Config.Esx.overrideInventory |
|||
| login | QBCore:Server:PlayerLoaded |
same | esx:playerLoaded |
playerJoining (without np_character) |
State bags read for downed / cuffed: isDead, dead, downed, inLastStand, handcuffed, isCuffed, cuffed.
Every framework also loads on np_character:loaded (and ox's setPlayerInventory); loading is idempotent.
Standalone ​
Without a framework:
- Owner: the np_character CID when np_character runs, otherwise the player's
license. Without np_character the inventory loads as soon as the player joins. - Money:
np_inventory_money(cash,bank,blackper owner). In item mode themoneyitem is the cash; the column is only used in account mode. - Groups: np_admin permission nodes. A player is in group
policewhen np_admin grants themnp_inventory.group.police(to their np_admin group or to them alone). The groups used inConfig.Stashes,Config.Shops,Config.CraftingandConfig.Policeare registered in np_admin, so they show up in its permission matrix. There is no ACE and nogroup.<name>fallback any more. - Licences: the node
np_inventory.license.weapon, or aweapon_licenseitem in the pockets. - Without np_admin running, only the fallback (console,
np_admin_fallbackidentifiers) passes these checks, so standalone jobs and licences effectively need np_admin. - Status: hunger / thirst / stress deltas are fired as
np_inventory:status (src, deltas)for your own script. - Vehicles: nothing is owned until a resource calls
SetVehicleOwned(plate, true).
Client side ​
bridge/framework/client/ defines name, onLoaded, onUnloaded, isDowned(), isCuffed() and
getPlayerData() (name, id and job for the header and the client-side group hints of prompts). The client asks the
server for its state when the framework says the character loaded (QBCore:Client:OnPlayerLoaded,
esx:playerLoaded, np_character:loaded). The server owns every inventory; the client bridge only decides when to
ask and whether to block the UI (dead, cuffed).
np_hud ​
Config.UseNpHud = 'auto' checks whether np_hud is started. While it runs:
| np_inventory | np_hud export |
|---|---|
| Use progress | Progress({ id, label, icon, tint, duration, canCancel, disable }) / CancelProgress() |
| World prompts (stash, shop, bench, drop, …) | ShowPrompt / HidePrompt |
| Toasts (client and server) | Notify |
| Open screen | ClaimZones('all'), released on close |
The item feed, the overload chip, document cards and every inventory screen are always np_inventory's own. While a screen is open it claims every np_hud zone, so the status chips and the minimap don't show behind the panels, and toasts stay in np_inventory's own stack until it closes. See np_hud → Sharing the screen.
Tables ​
sql/np_inventory.sql, created at start with Config.AutoCreateTables:
| Table | Holds |
|---|---|
np_inventory |
One row per persisted inventory: id, type, owner, items (JSON array of { slot, name, count, metadata }), updated_at |
np_inventory_logs |
at, action, actor, target, inv_from, inv_to, item, count, metadata, coords, extra |
np_inventory_crafting |
Crafting queue per owner and bench (JSON, times in unix ms, consumed items with metadata) |
np_inventory_shops |
Shop stock: { "<item index>": count } per shop id |
np_inventory_money |
Standalone only: owner, cash, bank, black |
Persisted: pockets, equipment, stashes (including personal, bench and confiscation stashes), owned trunks and gloveboxes, bags and evidence. Memory-only: drops, searchables, temporary stashes and unowned vehicles. Stashes, trunks, gloveboxes and bags nobody touched for 10 minutes are unloaded from memory (and saved first).
- Unknown items in a row (a typo in the config, a removed item) are kept aside and written back, so they come back when the item exists again.
- Bag rows whose bag no longer exists anywhere are purged after
Config.Containers.purgeDays(7). - Writes are write-behind: dirty inventories are flushed every
Config.SaveInterval, on logout / drop, on resource stop and on txAdmin's shutdown event. Logs are batched every 5 s.
Framework tables np_inventory reads: players (inventory for the import), player_vehicles (qb / qbx); users
(inventory), owned_vehicles, user_licenses (ESX).