NUI contract ​
The NUI is React 18 + TypeScript (strict) + Vite 5 with a Zustand store and two pages: web/dist/index.html (every
screen, the ui_page) and web/dist/phone.html (the np_phone app). It uses the Nimbus UI CSS unchanged, Quicksand,
Font Awesome and the brand logos bundled offline, and is drawn for 1080p and zoomed with the window height.
The server is authoritative: the client never sends an outcome (litres, a price, money, a fuel level it computed for
a refuel) or a position. Positions are read on the server, vehicles are resolved by net id on the server, and timed
actions (pump, charge, pour, fill, load, unload) are refused before 80 % of their duration (too_fast). Litres follow
the server clock, never the client's.
Lua → NUI ​
SendNUIMessage({ action, data }); from the server TriggerClientEvent('np_fuel:nui', src, action, data).
| Action | Data | Effect |
|---|---|---|
init |
{ locale, config, player, stations, synced } |
Stored (re-sent after ui.ready). config.errors = every Lua error text in the active language |
stations / station |
StationView[] / StationView |
Stored (all / one) |
sync |
{ key, data } |
synced[key] (module state: the run, broken pumps and spills, offices, …) |
screen:open |
{ id, data, focus } |
Shows the screen with data |
screen:update |
{ id, data } |
Replaces the data of an open screen |
screen:close |
{ id? } |
Closes one or all |
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; opening another closes the previous one), '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.
StationView = { id, kind, brand, name, district?, coords, radius, fillPoint?, chargers?, blip?, owned, ownerName?,
forSale?, salePrice?, fuels: { id, price /* cents */, level /* 0..100 */, available, grid? }[] }
PlayerState = { identifier, name, staff } // staff = UI hint only
NuiConfig = { framework, inventory, hud, payments, phone, fuelTypes, brands, lowPercent, reservePercent, errors }
FuelTypeDef = { id, label, unit: 'l' | 'kWh', price, tint, icon }
Screens ​
| Id | Layer / focus | Opened by | Screenshot |
|---|---|---|---|
pump |
full | E at a pump | pump, pump@wrongfuel, pump@declined, pump@airfield |
pump.meter |
overlay (keys) | A paid fill | pump.meter, pump.meter@done |
ev.charge |
full (setup), overlay (live) | E at a charger | ev.charge, @live, @done, @declined |
vehicles.gauge |
overlay | Driving without np_hud | vehicles.gauge, @low, @reserve, @empty, @diesel, @electric |
stations.owner |
full | /station, the office, the Fuel app |
stations.owner, @prices, @stock, @deliveries, @staff, @finances, @employee |
stations.buy |
full | A station's office | stations.buy, @offer, @cooldown |
supply.orders |
full | F7, /fuelorders, a depot |
supply.orders, @job, @empty |
supply.tanker |
overlay | A run (depot, driving, fill point) | supply.tanker, @loading, @drive, @ready, @unload |
admin.network |
full | /fueladmin |
admin.network |
admin.editor |
full | /fueladmin editor |
admin.editor, @depots, @ev, @readonly |
_kit |
– | Browser only | The component gallery |
NUI → Lua ​
One callback:
fetch('https://np_fuel/rpc', { method: 'POST', body: JSON.stringify({ method, params }) })
// → { ok: true, data } | { ok: false, error: 'code' }
Client-local methods (ui.ready, ui.close, progress.done, pump.pay, ev.pay, supply.map, admin.walk,
admin.edit) are handled on the client. Everything else is forwarded to the server dispatcher (np_fuel:rpc →
np_fuel:rpcResult), which applies a token bucket per player (Config.Rpc, 10 per second, burst 20), per-method
cooldowns and staff checks. Calls time out after 10 s; those that wait for the player in np_payments' sheet
(pump.begin, ev.begin, jerrycan.fill.finish, supply.take, supply.load.begin, stations.buy,
stations.owner.deposit) wait up to 3 minutes.
| Module | Server methods |
|---|---|
| vehicles | vehicles.state, vehicles.report, vehicles.setfuel |
| pump | pump.open, pump.quote, pump.begin, pump.finish, pump.cancel |
| jerrycan | jerrycan.state, jerrycan.fill.begin, jerrycan.fill.finish, jerrycan.pour.begin, jerrycan.pour.finish |
| ev | ev.open, ev.begin, ev.finish, ev.stop |
| stations | stations.view, stations.mine, stations.market, stations.buy, stations.sell, stations.owner.get, stations.owner.prices, stations.owner.withdraw, stations.owner.deposit, stations.owner.society, stations.owner.order, stations.owner.order.cancel, stations.owner.staff.hire, stations.owner.staff.fire, stations.owner.staff.role |
| supply | supply.board, supply.take, supply.abort, supply.rig, supply.load.begin, supply.load.finish, supply.unload.begin, supply.unload.finish, supply.status |
| admin | admin.state, admin.network, admin.station.save, admin.station.create, admin.station.remove, admin.stock.set, admin.depot.save, admin.teleport |
The phone app does not use this dispatcher: it calls np_phone app RPCs (finder:list, station:get,
station:route, station:call, spending:list, alarms:list, alarms:set, alarms:remove,
favourites:toggle), and Manage station posts phone.manage to np_fuel's client.
Error codes ​
Every code has a text in English and German; the NUI shows the screen's own text, else the Lua text from init.
| Where | Codes |
|---|---|
| Dispatcher | unknown_method, rate_limited, not_ready, invalid_params, no_player, forbidden, cooldown, internal_error; client timeout, stopped |
| Timed actions | invalid_token, too_fast |
| Stations and vehicles | unknown_station, unknown_fuel, fuel_not_sold, no_stock, tank_full, no_vehicle, wrong_fuel, invalid_coords, invalid_brand, invalid_amount, busy, too_far, not_available, dead |
| Payments | not_enough_money, no_economy, payment_cancelled, payment_declined, payment_failed |
| Pump | out_of_order, wrong_vehicle, wrong_fuel_confirm, no_nozzle, unpaid_bill (an open pay inside bill), unknown_bill |
| Linked shops | not_linked, insufficient_funds |
| Jerry can | no_jerrycan, can_empty, can_full, no_station |
| EV | not_electric, no_charger, battery_full |
| Stations | price_out_of_bounds:<fuel>, price_changed, no_society, … |
| Supply | order_size, order_too_big, station_unowned, station_funds, unknown_order, order_taken, no_rig, not_at_depot, depot_fuel, compartment_full, job_full, level_locked, no_licence, no_hazmat, own_order, … |
A code may carry a detail after a colon (no_stock:diesel).