Skip to content

Building, tests & screenshots ​

Layout ​

fxmanifest.lua                 globs only: a feature module adds files and never edits the manifest
shared/lib/                    00 NpScanner namespace, zones / sides / classes, logging, bridge selection, util + validators
                               01 locale · 02 integration registry · 03 item and weapon metal registry
shared/config.lua              core config
shared/config/<module>.lua     one file per area (listed ahead of time in fxmanifest for np_admin)
shared/locales/{en,de}/        core.lua + one file per module, flat keys, one `['key'] = 'text',` per line
shared/np_admin_settings.lua   np_admin Resource settings and nodes, after every config file
bridge/np_admin.lua            the np_admin lib, vendored byte-identical
bridge/framework/{client,server}/   esx | qbx | qb | standalone   (esx first)
bridge/inventory/server/            np | ox | qb | esx | none     (np first)
integrations/{server,client}/  one adapter per optional np_* sibling with a built-in fallback (np_npchandler and
                               np_prophandler are required and called directly)
server/core/NN_*.lua           init (staff, jobs, duty) · db · rpc · inventory API · hooks · events · players · ask ·
                               modules · exports · log
server/modules/<m>/            detection, venues, sessions (core domain) + gate, wand, findings, lockers, cases,
                               tray, xray, console, shifts, watchlist, placement, props, smuggling, ground, phone, npcs
client/core/NN_*.lua           state · nui · rpc · answer · world (points, targets, interact) · game helpers · exports · sync
client/modules/<m>/            the client half of each module
sql/install.sql, sql/<m>.sql   core and module schemas
web/                           React NUI (index.html) and the np_phone app (phone.html), one package
web/design/                    Nimbus UI tokens and CSS, vendored unchanged
install/                       item snippets (ox, qb), crafting recipes, np_identification types
tests/                         plain-Lua harness, one process per tests/test_*.lua

Load order: shared (lib → config.lua → config/* → locales → zz_init.lua → bridge/np_admin.lua → np_admin_settings.lua), server (oxmysql → framework bridge → inventory bridge → core → integrations → modules → zz_ready.lua), client (framework bridge → core → integrations → modules → zz_ready.lua). Files inside a folder load in name order.

Globals: NpScanner (both sides), Config, Locales and npAdmin. Nothing else is global. Server-authoritative rules: the client draws and asks, the server validates every parameter and checks permission, job, duty and position (GetEntityCoords(GetPlayerPed(src))), never trusts a client answer, and uses locks (withLock) around check-then-write flows such as seize, return and locker.

Build ​

sh
cd web
npm ci
npm run build          # gen:strings + FiveM guard check + tsc --noEmit + vite build → web/dist/index.html, web/dist/phone.html
npm test               # gen:strings + contract check + vitest
npm run dev            # browser mock with a gallery of every screen, HUD layer and shot (http://localhost:5189/)
npm run screenshots    # headless Chrome → web/screenshots/*.png
node scripts/check-contract.mjs --strict

npm run build first runs scripts/check-fivem-guard.mjs: in FiveM a blurred surface renders as a black box over the game, so the HTML sets html.nb-fivem before the first paint and the CSS turns backdrop-filter off under it. The guard fails the build when that rule or the code that sets the class is missing. A test also keeps the Nimbus silver line rules intact (no raw hex, rgba or font sizes in module CSS).

The contract check (web/scripts/check-contract.mjs) compares the web side with the Lua side: every rpc('x') the NUI calls is registered in Lua, every RpcMap method has a mock, every NUI action Lua sends has a handler, every screen or HUD layer Lua opens exists, and every error code Lua returns has an error.<code> text in English and German.

Browser mock ​

npm run dev runs the UI without FiveM, with mock data. URL parameters pick a screen:

Parameter Values
screen a screen id (findings, tray, xray, console, placement, case, operator, …) or a named shot (gate-alarm, gate-random, wand-sweep, wand-refused, findings-unrevealed, digging, …)
hud one or more HUD layers, comma separated (gate-operator, wand, wand-consent, ground, prompt, progress)
locale de
bg dark or none
clean 1: no gallery and no animations, for screenshots
brand, strength A server theme, e.g. brand=3d74ff&strength=tiles

The phone app runs at phone.html?app=checkpoint|checkpoint_wallet&tab=<id>&locale=de.

Tests ​

sh
bash tests/run.sh                  # luac -p on every Lua file, then every suite in its own Lua process
bash tests/run.sh gate             # only suites whose name contains "gate"
VERBOSE=1 bash tests/run.sh        # show the resource's log lines

The harness (tests/harness.lua) boots the whole resource against fakes for the natives, oxmysql (an in-memory SQL that understands the statements the resource uses), the framework (esx, qbx, qb, standalone) and the inventory (np, ox, qb, esx, none), with players, loadouts, jobs and a controllable clock. A suite is a file tests/test_<name>.lua:

lua
local H = dofile((arg[0]:match('^(.*)/[^/]+$') or 'tests') .. '/harness.lua')
H.boot({ framework = 'esx', inventory = 'np' })
H.addPlayer({ id = 1, identifier = 'char1:a', loadout = { { name = 'WEAPON_PISTOL', ammo = 12 } } })
H.test('gate alarms on a pistol', function()
  local result = H.run(function() return NpScanner.Gate.run(1, 'courthouse_gate_1', { force = true }) end)
  H.check(result.alarm)
end)
H.finish()

The suites cover the core, detection, sessions, venues, the gate (server and client), the wand, findings, lockers, cases, the tray, X-ray, the console, shifts, the watchlist, placement, props, smuggling, the ground detector, the phone apps, the integrations (against the sibling repositories and against fakes), np_admin, the boot of every framework and the seams between layers (test_seams.lua: locale files, error codes, the manifest against the files on disk, net events against their receivers, and that no file uses ACE permissions).

Screenshots ​

npm run screenshots builds the UI, serves web/dist with vite preview and renders with headless Chrome from the browser mocks: every focus screen to web/screenshots/<id>.png, every HUD layer to hud-<id>.png, every named shot, and every phone tab to phone-<app>-<tab>.png, at 1920 × 1080 (phone 430 × 932). The lists come from the app itself, so a new screen folder, shot or tab is picked up on its own. Options: a name filter (scripts/screenshots.sh findings), LOCALE=de, SCALE=3 and SKIP_BUILD=1. This site copies them with npm run sync:images.

Adding a feature module ​

A module is files only: it never edits the manifest, core files or another module.

  1. Config shared/config/<m>.lua (already listed for np_admin): Config.<M> = { … }, its items in Config.Items, and a group in Config.AdminSettings.
  2. Locales shared/locales/{en,de}/<m>.lua, keys prefixed with the module name, plus every error.<code> it returns.
  3. Server server/modules/<m>/*.lua: NpScanner.Module.define({ name, onReady, onPlayerLoaded, … }), NpScanner.DB.migration('scanner_<m>_NNN', { … }) (and the same statements in sql/<m>.sql), NpScanner.RPC.register('<m>.<name>', fn, opts) with a schema, NpScanner.Log.add, NpScanner.emit.*.
  4. Client client/modules/<m>/*.lua: NpScanner.Interact.zone, NpScanner.keymap, NpScanner.openScreen, NpScanner.hud, NpScanner.call.
  5. Web web/src/screens/<m>/ (defineScreen, mock.ts, types.ts with the RpcMap augmentation).
  6. Tests tests/test_<m>.lua.

An export a module adds goes through NpScanner.Api.provide(name, fn) or NpScanner.Api.export(name, fn).