NUI contract ​
The NUI is React 18 + TypeScript (strict) + Vite with two pages: web/dist/index.html (every screen) and
web/dist/phone.html (the np_phone app). It uses the Nimbus UI CSS unchanged, Quicksand and Font Awesome bundled
offline, and is drawn for 1080p and zoomed with the window height.
The server is authoritative: the client never sends an outcome or a price. Positions, plates, the vehicle a player sits in, jobs, money and items are read on the server. Timed actions (installs, repairs, chops, roadside fixes) are refused before 80 % of their duration.
Lua → NUI ​
SendNUIMessage({ action, data }); from the server TriggerClientEvent('np_mechanic:nui', src, action, data).
| Action | Data | Effect |
|---|---|---|
init |
{ locale, config, player, shops, synced, errors } |
Stored (re-sent after ui.ready). errors = every error text in the active language |
state |
PlayerState |
Stored |
shops |
ShopView[] |
Stored |
sync |
{ key, data } |
synced[key] (module state) |
screen:open / screen:update / screen:close |
{ id, data, focus } / { id, data } / { id? } |
Screens |
toast, prompt:show, prompt:hide, progress:start, progress:cancel |
The fallback layer, only without np_hud |
Focus: 'full' (mouse and keyboard, one screen at a time), 'keys' (the NUI gets the keyboard while the game keeps
its input) or false (overlay). Focused screens close when the player dies, is cuffed or unloads. Escape closes the
top 'full' screen.
PlayerState = { identifier, name, admin, job: { name, label, grade, onduty }, skills: { engine, … }, staffOf: string[],
dutyOf: string[], police: boolean }
ShopView = { id, brand, label, coords, zones, lifts, mode, categories, services, legal, accent, blip, hours?, open, enabled, job? }
NUI → Lua ​
One callback:
fetch('https://np_mechanic/rpc', { method: 'POST', body: JSON.stringify({ method, params }) })
// → { ok: true, data } | { ok: false, error: 'code' }
Client-local methods (camera, preview, labels, waypoints) are handled on the client. Everything else is forwarded to
the server dispatcher (np_mechanic:rpc → np_mechanic:rpcResult), which applies a token bucket per player
(Config.Rpc, 8 per second, burst 16), per-method cooldowns, and the gates of each method (in the shop's zone, staff,
on duty, admin).
Dispatcher error codes: unknown_method, rate_limited, not_ready, invalid_params, no_player, forbidden,
unknown_shop, not_in_shop, wrong_job, off_duty, not_staff, cooldown, internal_error; on the client
timeout. Every module adds its own codes; each has a text in English and German.
Screens ​
| Id | Focus | Module |
|---|---|---|
tuner |
full | Tuning |
workshop |
full | Order board |
workshop.install |
overlay | Install step with the torque check (SPACE is read by Lua) |
workshop.invoice |
full | Collection bill |
workshop.bay |
overlay | Lift chip |
repair |
full | Diagnosis |
repair.bill |
full | Repair bill |
underground |
full | Underground counter |
underground.knock |
full | Knock pad |
underground.inspect |
full | Police inspection |
business |
full | Boss tablet |
business.jobs |
full | Delivery board |
business.rate |
full | Customer rating |
roadside |
overlay | Roadside street card / customer card |
phone |
full | The Mechanic app without np_phone |
Sync keys ​
Module state pushed to the client (synced[key]): workshop.lifts, workshop.mine, workshop.board,
underground, business, business.tablet, roadside.
The np_phone app ​
phone.html is a second Vite entry that runs inside np_phone through its app SDK. The app calls
phone.rpc(method) → np_phone → np_mechanic's dispatcher, with the same rate limit and cooldowns as the NUI. Only a
whitelist of methods is forwarded (phone.home, phone.vehicle, phone.service, phone.workshops, phone.orders
and the customer and mechanic roadside.* calls). The live roadside view arrives through sendAppMessage.
Look ​
- Plain Nimbus by default: grey glass, grey tiles, white glyphs, a white selection ring and white primary buttons. Colour only for meaning: green gain / OK / money in, red loss / illegal / danger, orange warning, blue police / info.
- No shop colour unless
ShopView.accentis on. A shop's identity is its logo plate. - Custom CSS uses Nimbus tokens only, scoped under
.npm-root.background-origin: border-box !importantis set on every surface (no silver line on gradient borders). Nobackdrop-filterof its own: in FiveM a blurred surface renders as a black box, and the build checks this.