Development ​
Layout ​
fxmanifest.lua globs only: a module never edits it
shared/lib/ global NpGangs, bridge selection, bus, util, geometry, locale
shared/config/NN_*.lua core defaults; shared/config/<module>.lua per module
bridge/np_admin.lua the np_admin lib, byte-identical to np_admin/lib/np_admin.lua (global npAdmin)
shared/np_admin_settings.lua np_admin's settings page for np_gangs
shared/locales/en|de/*.lua one file per module
bridge/framework/{client,server}/ esx | qbx | qb | standalone
bridge/inventory/server/ np | ox | qb | none
integrations/*.lua one file per sibling np_* resource, loaded on both sides
server/data/seed.lua the example layout
server/core/NN_*.lua init, schema, RPC, events, hooks, timers, ledger, gangs, slots, turfs, grip, bandana,
stash, lester, notify, sync, actions, api
server/modules/<m>.lua lester trial election territory colours stashout trusted street graffiti rob
protection takeover corner trade; admin/ is a folder
server/boot.lua last: schema, stores, ready
client/core/, client/modules/ the client half of every module
web/ React NUI
sql/install.sql, sql/seed.sql schema and the example data
layouts/ map layouts the editor exports / imports
tests/ plain-Lua harness, one process per tests/test_*.lua
mockups/ the original HTML mockups and their renders
Load order: shared lib → config → np_admin lib → np_admin settings → locales → bridges → integrations → server data → core → modules →
server/boot.lua. There is one global table, NpGangs. Code resolves NpGangs.X when it is called, never in a
file-level local. Every Lua file must also parse with plain lua 5.4 / 5.5, so the harness can load it.
Commands ​
tests/run.sh # luac -p on every Lua file + all suites (plain lua 5.4, no game needed)
tests/run.sh flow # one suite
cd web && npm test # contract check (RPCs, screens, mocks) + unit tests
cd web && npm run build # FiveM guard + typecheck + build
cd web && npm run dev # http://localhost:5186/?screen=street&locale=de renders a screen with mock data
web/scripts/screenshots.sh # every screen and variant to web/screenshots/*.png (headless Chrome)
mockups/render.sh # the original HTML mockups to mockups/renders/*.png
Mock mode URL parameters: ?screen=<id>&variant=<name>&locale=de&shot=1. ?screen=kit shows every shared component.
The contract check fails when a typed RPC has no mock or a screen has no mock entry.
After re-rendering, run npm run sync:images in this docs repo.
Tests ​
tests/run.sh runs 32 suites, each in its own process:
- Core (
test_core: es_extended + np_inventory + siblings): stores, RPC, hooks, events, timers across a restart, bandana, stash, Lester, notifications, API, staff. - One suite per module: lester, trial, election, territory, colours, stashout, trusted, street, graffiti, rob, protection, takeover, admin, drugs (against a fake and against the real np_drugs adapter), corner, trade.
- Client suites: client, Lester client, turf life, admin client, drugs client.
test_flow: the modules together end to end. Three players found a gang through the whole session, walls, protection, a second gang, pressure, three decisions, dissolving; the np_drugs path.- Bridges:
test_core/test_qbx(qbx_core + ox_inventory) /test_qb(qb-core + qb-inventory) /test_standaloneall runtests/bridge_smoke.lua, every module on that combination. test_geometry,test_integrations(declared exports against the sibling repositories),test_np_admin(the lib byte-identical, the manifest, no ACE; staff, settings, audit log and tools with a fake np_admin and without it),test_np_shops(storefronts, the members' price hook, robberies) andtest_project(locales, manifest, SQL, and that API.md and the code name the same exports, hooks and events, both ways).
The harness loads the files the fxmanifest lists, runs threads on a fake clock, records client and local events, and
fails a test on any thread error, nil SQL parameter or unserialisable payload. What it cannot see (natives, peds,
props, coordinates) is on Before you open it.
Adding a module ​
A module is a set of new files; the manifest is globs only.
| File | What goes in |
|---|---|
shared/config/<m>.lua |
Config.<M> = {…} or additions to an existing table |
shared/locales/en/<m>.lua, de/<m>.lua |
Strings with keys prefixed <m>., including error.<code> for new codes |
server/modules/<m>.lua |
RPCs, street actions, timers, bus listeners, onBoot / onReady |
client/modules/<m>.lua |
Key mappings, points, Actions.on, openScreen |
web/src/screens/<m>/index.tsx, mock.ts |
The screen and its mock data |
tests/test_<m>.lua |
Scenarios in the harness |
integrations/<sibling>.lua |
Only when the module talks to another resource |
A street action is registered once on the server and handled once on the client; the row appears in the street menu
as soon as it is registered, with the bandana, rank, distance, cooldown and beforeAction checks for free:
-- server/modules/graffiti.lua
NpGangs.Actions.register('spray', {
status = function(ctx) -- cheap: runs for every menu open
local wall = NpGangs.Points.nearest(ctx.coords, 'wall', 3.0)
if not wall then return { ok = false, reason = 'too_far', sub = NpGangs.t('graffiti.no_wall') } end
return { ok = true, sub = NpGangs.t('graffiti.in_range'), target = wall.id }
end,
run = function(ctx, params, status) -- bandana, rank, status, cooldown and beforeAction already passed
return { wall = status.target, duration = 12000 }
end,
})
The street module is the reference implementation (server/modules/street.lua, client/modules/street.lua,
web/src/screens/street/, tests/test_street.lua).
Contract ​
docs/ARCHITECTURE.md is the contract for
the data model, the NUI protocol, every RPC, the events, the bridges, the integration layer and the server rules. It
changes in the same commit as the code. The public API is
docs/API.md, summarised on
Exports & hooks and Events.