Development ​
Layout ​
fxmanifest.lua
shared/lib/ NpInv namespace and utils, locale loader, item registry (defaults, weight, durability, views)
shared/config.lua Config.*
shared/config/ items, weapons, shops, crafting, stashes, vehicles, searchables
shared/locales/ en / de
shared/zz_init.lua builds NpInv.Items after every config and locale file
bridge/framework/client/ 0_common 1_qbx 2_qb 3_esx 9_standalone
bridge/framework/server/ 0_common 1_qbx 2_qb 3_esx 9_standalone
client/ 00_state 01_nui 02_rpc 03_open 04_callbacks 05_hotbar 06_use 07_weapons 08_drops
09_weight 10_feed 11_give_trade 12_search 13_status 14_settings 15_api
16_compat_ox 17_compat_qb
server/ 00_server 01_db 02_rpc 03_inventory 04_ops 05_hooks 06_players 07_open 08_use
09_drops 10_vehicles 11_stashes 12_shops 13_crafting 14_give 15_trade 16_search
17_weapons 18_logs 19_admin 20_exports 21_compat_ox 22_compat_qb
sql/np_inventory.sql schema (also run at start with Config.AutoCreateTables)
web/ NUI (React 18 + Vite 5 + TS strict + zustand)
design/ Nimbus UI tokens and components (imported unchanged)
mockups/ concept HTML and renders
docs/ ARCHITECTURE.md (contract), IDEAS.md
tests/ plain-Lua harness + run.sh
Files are numbered so the glob order in fxmanifest.lua is deterministic. Code resolves NpInv.X when it's called,
never at file load. Every inventory mutation is synchronous Lua (no Wait inside), so it's atomic; handlers that need
the database load first, re-validate, then mutate.
| Server file | Does |
|---|---|
03_inventory.lua |
The inventory class: load / save / unload, plan and canCarry, add / remove, container weight, decay rescaling, views, update pushes |
04_ops.lua |
Move, split, stack, swap, transfer, sort, take all |
05_hooks.lua |
registerHook / removeHook |
06_players.lua |
Pockets and equipment, bonuses, armour, cash sync, feed |
07_open.lua |
Sessions, access checks, rob / frisk, bags |
08_use.lua |
Use flow, documents, rename, actions, framework usable items |
20_exports.lua / 21_compat_ox.lua / 22_compat_qb.lua |
Native, ox and qb exports |
NUI ​
cd web
npm install
npm run dev # http://localhost:5177, browser mock mode
npm run build # check:fivem && tsc --noEmit && vite build → web/dist (build before starting the resource)
Outside FiveM, src/dev installs a fake Lua backend that answers every web → Lua callback and drives the UI through
the same path SendNUIMessage uses. Item, category and panel labels follow locale (German by default). The sample
data has a player with a full hotbar, a trunk, a
backpack, a frisk target, a shop, a crafting bench and a trade partner. A small dev bar switches screens. Like the server, the mock takes ingredients from pockets → bag → bench storage
and sends pat-down placeholders.
The mock and its background images are only loaded under vite dev or a --mode mock build (a compile-time guard in
main.tsx), so the production web/dist contains neither. npm run build also runs scripts/check-fivem-guard.mjs
against src, index.html and ../design.
| URL parameter | Values |
|---|---|
screen |
inventory (default: pockets + trunk), interactions (tooltip, context menu, drag check, split), give, trade, hud (hotbar, feed, progress, prompt, overload chip), equipment, crafting, shop, frisk, document, stash |
material |
liquid |
locale |
de, en |
brand / strength |
e.g. %233d74ff / tiles (theme ramp) |
bg |
game: a GTA capture behind the UI |
shot |
1: no dev bar, no animations (for screenshots) |
The UI scales from 1080p (zoom = max(0.75, innerHeight / 1080), or Config.Scale). Drag & drop is pointer-based,
because CEF has no HTML5 drag and drop. web/src/styles/inventory.css uses only Nimbus --nb-* tokens.
Screenshots ​
cd web
npm run screenshots # = scripts/screenshots.sh, renders every screen
scripts/screenshots.sh trade # only screenshots whose name contains "trade"
SCALE=3 scripts/screenshots.sh inventory # high-DPI render for edge checks
The script builds web/dist and a mock build into web/dist-mock, serves it with vite preview on port 4320, and
renders 13 screens at 1920 × 1080 with headless Chrome into web/screenshots/ (inventory, interactions, give,
trade, hud, equipment, crafting, shop, frisk, document, inventory-liquid, inventory-en,
inventory-game). Set CHROME= if Chrome is not in /Applications. Then run npm run sync:images in this docs
repo.
Tests ​
tests/run.sh # VERBOSE=1 shows resource log lines and stubbed natives
It runs luac -p on every Lua file, then four suites, each in its own Lua process: tests/test_server.lua,
tests/test_client.lua, tests/test_qb.lua and tests/test_esx.lua. tests/harness.lua stubs FiveM natives,
oxmysql (an in-memory store), exports, events, state bags, GlobalState and time (a controllable clock and
cooperative threads). Needs Lua 5.4 (LUA= / LUAC= override the binaries).
- Server: add / remove / stack / split / merge / swap / sort, weight and slot limits, unique items, metadata
stacking, durability, degrade and decay (also inside a cooler), bags (no nesting, weight propagates), equipment
rules and bonuses, hotbar use, drops, trunk and glovebox access (distance, lock, seat, class size, model override,
ownership), stashes (groups, personal, PIN), shops (money, stock, licence, discount), crafting (ingredients,
keep, queue timing, cancel refund with metadata, collect), give, trade (lock reset, countdown, atomic swap, stale bag offers), rob / frisk, searchables,expect, hooks, ox signatures, runtime shops, confiscation, admin commands, cash sync, persistence round trip, rate limits, and fuzzing every RPC with junk payloads. - Client: NUI callback wiring, queue and boot, open flow and target detection, hotbar keys, the use flow with its token, weapons (equip, sync, reload, jams, holster, weapon lost), overload, drops, feed and status, trade, world points, settings, the API exports and a web reload.
- Seam checks (read from the sources): every web
post('<name>')has a Lua callback, every LuaNpInv.send('<action>')is a web action, every clientNpInv.rpc('<name>')is a server RPC, and every serverTriggerClientEvent('np_inventory:…')has a client handler. - qb / esx: fake qb-core and es_extended: the qb-inventory exports the way qb-core calls them, ox-style calls next
to them, the
PlayerData.itemsmirror, framework usable items, black money (an item on qb, synced with the account on ESX) and status events.
The web build (npm run build, TypeScript strict) must pass as well.
Contract ​
docs/ARCHITECTURE.md is the single
source of truth for the item and inventory objects, the NUI protocol, the server RPCs, hooks, the bridge contract, the
config, the database and the exports. It describes the code as built; when the two disagree, one of them is fixed. See
the NUI contract for a summary.