NUI contract ​
The contract between the server Lua, the client Lua and the NUI. You only need it to change the UI or to build on the RPC layer. Other resources use the exports, hooks and events.
Rules ​
- Server-authoritative. The client sends a shop id, item names, counts, a payment method id and a counter index.
Prices, stock, discounts, licenses, ages, weights, loot, durations and outcomes are computed on the server. Positions
come from the server (
GetEntityCoords(GetPlayerPed(src))). - Units: money is whole dollars, weights are grams, fuel is liters (kWh for EVs, same field). Timestamps are unix
seconds; durations on the wire are ms unless the name says
secondsorminutes. - Optional fields may be missing. Test with
== nullon the web, never=== null. Empty Lua tables arrive as[]. - UI preferences (list / grid, Liquid Glass) are client KVP (
np_shops:pref:<key>), never the database.
Transport ​
Lua → NUI: SendNUIMessage({ action, data }), queued until the NUI calls ui.ready. From the server:
np_shops:nui (action, data).
NUI → Lua: one callback.
fetch('https://np_shops/rpc', { method: 'POST', body: JSON.stringify({ method, params }) })
// → { ok: true, data } | { ok: false, error: 'code' }
Client-local methods are answered by the client. Everything else goes to the server dispatcher through the net event
np_shops:rpc (reqId, method, params) and comes back as np_shops:rpcResult (reqId, ok, dataOrError).
Screens ​
| Screen | Opened by | Focus | Data |
|---|---|---|---|
shop |
catalog.open (counter, OpenShop) |
yes | StorefrontView, variant retail (list / grid), weapons, food, luxury, pawn or service |
pump |
fuel.open (pump) |
yes | PumpView |
owner |
ownership.dashboard (office, phone, /shopowner) |
yes | OwnerDashboard |
kitchen |
food.queue (kitchen point, staff on duty) |
yes | { shop, orders, onDuty } |
admin |
admin.open (/shopadmin, np_admin tool) |
yes | AdminView |
HUD robbery |
sync key robbery |
no | RobberyHud |
HUD peek |
client, near a counter | no | ShopPeek |
Opening a screen takes NUI focus and hides the np_hud zones in Config.Hud.claim. Opening another screen closes the
first. The client closes the screen when the player dies, gets cuffed, unloads, or walks more than
Config.Catalog.closeDistance from the counter. ESC calls ui.close. HUD pieces never take focus.
Actions (Lua → NUI) ​
| Action | Data |
|---|---|
init |
{ locale, strings, brands, shops, states, player: { identifier, name, job, grade, admin, editor }, config: { keys, inventory, imagePath, logoBase, currency, brandAccent, prefs }, sync, modules } |
sync |
{ key, value }: one per-player state value changed |
open / close |
{ screen, data } / { screen? } |
shop:stock |
{ shopId, items: { name, stock, state, restockAt? }[] } while the shop is open |
shop:state |
{ shopId, state } |
shop:receipt |
Receipt (also the answer of checkout.pay; pushed for a staffed checkout paid on another client) |
kitchen:order |
Order: new or changed order for the open kitchen |
owner:update |
Part of OwnerDashboard |
admin:shops |
The editor's shop list after a save or delete |
peek:show / peek:hide |
ShopPeek / {} |
hud:notify, hud:progress, hud:progressCancel, hud:prompt, hud:promptHide |
Only without np_hud |
Main shapes ​
type ShopState = { open: boolean; reason?: 'hours' | 'robbed' | 'owner' | 'admin'; until?: number }
type ItemView = {
name: string; label: string; description?: string; tab: string
icon: string; tint: string; image?: string
weight: number // grams per unit
price: number; basePrice: number // price for this player now (offer, happy hour, job discount applied)
offer?: { price: number; untilAt: number }; bulk?: { from: number; pct: number }[]
currency: string // 'money' | 'black_money' | item
stock?: number // missing = unlimited
state: 'in' | 'low' | 'out' | 'locked'
restockAt?: number; notify?: boolean
lock?: { reason: 'license' | 'age' | 'job' | 'business_license' | 'limit' | 'wait'; detail?: string }
minAge?: number; maxCarry: number
kind?: 'weapon' | 'food' | 'combo' | 'luxury'
weapon?: { class: string; caliber?: string; ammo?: string; stats: Record<string, number>; components: { name: string; label: string; price: number; icon: string; tint: string }[] }
luxury?: { engravable: boolean; certificate: boolean; finance: boolean; engravingPrice?: number }
ammo?: { rounds: number; caliber?: string }
}
type CartLine = { name: string; count: number; components?: string[]; engraving?: string;
combo?: { id: string; side: string; drink: string; size?: 'regular' | 'large' } }
type Quote = {
shopId: string
lines: { name: string; label: string; count: number; unit: number; total: number
discounts: { kind: 'offer' | 'bulk' | 'happy_hour' | 'job' | 'loyalty' | 'hook'; label: string; amount: number }[]
to: 'pockets' | 'pickup' | 'order'; currency?: string; error?: string }[]
subtotal: number; discount: number; tax: number; total: number
extra?: Record<string, number> // totals in another currency, charged on top
weight: { cart: number; free: number; max: number }
points?: { earn: number; balance: number }
methods: PaymentMethod[]
hash: string // pass back to checkout.pay
}
type PaymentMethod = { id: string; kind: 'cash' | 'bank' | 'card' | 'company' | 'black' | 'business' | 'finance'
label: string; sub?: string; icon: string; tint?: string; balance?: number
disabled?: boolean | string; brand?: string; number?: string }
StorefrontView adds the tabs, items, view, variant, capacity, methods, loyalty, staffed, pickup, location,
hours, robbable, and per variant food, luxury, pawn, service, ownership and ring (a cart a clerk rang
up; checkout.ring asks the customer, checkout.ringAnswer opens the screen with it). Receipt, Order, PumpView, OwnerDashboard, RobberyHud, ShopPeek, PawnView and AdminView are typed
in web/src/screens/*/types.ts.
Client-local methods ​
ui.ready -> true NUI mounted: queue flushed, last init sent again
ui.close { screen? } -> true
ui.pref { key: 'view' | 'liquid', value } -> true
shop.waypoint { shopId } -> true GPS to the shop's first counter
fuel.start { shopId, pump, grade, liters, method, extras? } -> FuelResult quote → nozzle → pay (np_shops:fuel:apply sets the level)
weapons.preview { shopId, name, components? } -> { active: true }
weapons.previewRotate { yaw?, pitch?, zoom? } -> true
weapons.previewStop {} -> true
robbery.hold { shopId, target: 'register' | 'safe' | 'case', case? } -> true
Server RPC methods ​
Every method has a schema. The dispatcher checks, in order: known method → rate limit (Config.RateLimit) → ready →
sane params (depth ≤ 5, ≤ 256 keys) → loaded character → admin node or job → alive → one call per player and method in
flight → schema → cooldown → handler. Handlers that act at a shop check the distance (too_far, not_found).
| Module | Methods |
|---|---|
| catalog | catalog.open, catalog.peek, catalog.item, catalog.stock, catalog.notify |
| checkout | checkout.quote, checkout.pay, checkout.ring, checkout.ringAnswer, checkout.receipts, checkout.receipt, checkout.loyalty, checkout.pickup |
| weapons | weapons.inspect, weapons.serials |
| food | food.combos, food.orders, food.collect, food.queue, food.claim, food.ready, food.cancel |
| fuel | fuel.open, fuel.quote, fuel.pay, fuel.bill.pay |
| luxury | luxury.inspect, luxury.finance |
| pawn | pawn.open, pawn.sell |
| services | services.open |
| robbery | robbery.check, robbery.start, robbery.finish, robbery.cancel |
| ownership | ownership.dashboard, buy (a linked shop answers { redirected: 'np_fuel' } and opens np_fuel's station screen), sell (linked_station), setOpen, setNpc, setPrice, hire, fire, setRole, duty, deposit, withdraw, ledger, stash, wholesale, wholesaleCancel, deliveries, deliveryAccept, deliveryComplete |
| admin | admin.open, shop, save, delete, here, restock, resetRobbery, teleport (node np_shops.editor) |
| phone | phone.discover, phone.orders, phone.receipts, phone.myShops, phone.waypoint |
checkout.quote { shopId: s, location?: i, lines: CartLine[1..50], method?: s } -> Quote
checkout.pay { shopId: s, location?: i, lines: CartLine[1..50], method: s, hash: s, tip?: i, requestId?: s } -> Receipt
checkout.ring { shopId: s, target: i, lines: CartLine[1..50] } -> { sent: true } staff only; busy while the customer has an open request
checkout.ringAnswer { accept: b } -> { opened: boolean } not_found (no open request) too_far not_on_duty
fuel.quote { shopId: s, pump: i, grade: s, liters?: n, target?: n, netId: i, level?: n } -> { liters, total, level, token, duration }
fuel.pay { shopId: s, pump: i, grade: s, liters: n, method: s, netId: i, token: s, extras? } -> { liters, total, level, delta, receipt }
fuel.bill.pay { shopId: s, id: s } -> { bills: FuelBill[], paid: { dollars, method? } } not_available (not linked, np_fuel down) too_far unknown_bill + payment codes
luxury.finance { shopId: s, lines: CartLine[1..10], plan: s } -> { receipt, invoice } not_available cant_afford no_space forbidden
pawn.sell { shopId: s, name: s, count: i[1..100] } -> { paid, method, left } insufficient_funds (owned shop) forbidden price_changed …
robbery.start { shopId: s, target: 'register' | 'safe' | 'case', method?: 'lockpick' | 'extort', case?: i } -> { token, duration, radius, unlockAt? }
robbery.finish { token: s } -> { loot, method, items? } too_early: the safe before unlockAt + 90 % of the hold
checkout.pay request ids. The NUI makes one requestId per payment attempt (cart + method + quote hash) and
reuses it after timeout, a network error or busy. The server checks it first: the same id within
Config.Checkout.requestTtl answers the first receipt again, a retry while the first request still runs answers
busy. Client timeouts: checkout.pay waits Config.Checkout.paymentTimeout + 15 s, fuel.pay 180 s,
luxury.finance 60 s, ownership.buy 30 s, everything else 10 s.
fuel.pay delta. delta is the percent points of tank that were paid for. level is the server's target level.
fuel.open, fuel.quote and fuel.pay answer not_available while the pump shops yield to np_fuel
(Config.Fuel.yieldToNpFuel).
Fuel bills. The storefront of a shop linked with an np_fuel station carries
fuelBills, the player's open np_fuel bills of that station ([] when none). fuel.bill.pay pays one through np_fuel
and answers the fresh list. See Checkout → Fuel bills.
type FuelBill = { id: string; station: string; stationName: string; pump: number; fuel: string; fuelLabel: string
litres: number; cents: number; dollars: number; plate?: string; at: number; dueAt: number }
Anything that takes time (robbery holds, the safe time lock, the fuel nozzle) uses a server token: the server sets the duration, checks elapsed time and distance, and validates again in the finish step.
Error codes ​
A handler answers nil, 'code'. A code may carry a detail after a colon (locked:age, out_of_stock:ecola). Every
code has a text error.<code> in English and German.
- Core:
unknown_method rate_limited not_ready invalid_params no_player forbidden downed busy cooldown internal_error timeout invalid_token too_early expired too_far not_found not_available no_space item_missing failed cancelled - Shops:
closed robbed out_of_stock price_changed cant_afford payment_failed payment_cancelled payment_later locked no_license too_young wrong_job no_business_license limit_reached wait_period empty_cart not_sold_out not_owner not_staff not_on_duty owned not_for_sale insufficient_funds taken not_ready nothing_to_pickup stolen not_buying daily_cap not_enough_police no_weapon already_robbing empty not_robbable no_vehicle tank_full wrong_grade invalid_shop not_editable not_courier hook_blocked
Net events ​
| Event | Payload |
|---|---|
np_shops:rpcResult |
reqId, ok, dataOrError |
np_shops:init |
The init payload without strings |
np_shops:sync |
key, value |
np_shops:nui |
action, data |
np_shops:notify |
{ type, title, message, icon?, tint?, duration? } (only without np_hud) |
np_shops:shops / np_shops:shop |
The full shop list / id, ShopPublic | nil for one shop |
np_shops:state |
id, ShopState |
np_shops:open |
shopId, location?: the server asks the client to open a shop |
np_shops:fuel:apply |
netId, level, delta?: after a paid refuel, to the payer. A state-bag fuel bridge (ox_fuel, statebag) sets level, every other bridge adds delta to the level it reads now |
np_shops:checkout:ring |
{ shopId, from, count, seconds }: a clerk rang up a cart. Toast plus key prompt; the key answers checkout.ringAnswer within seconds |
np_shops:robbery:alert |
{ id, coords, title, code }: built-in dispatch, police only |
np_shops:clerk:react |
shopId, reaction ('hands_up' | 'alarm' | 'fight' | 'calm'), robber? |
np_shops:clerk:state |
{ enabled, hidden }: clerks on, which are hidden (staff on duty) |
np_shops:robbery:targets |
Robbery targets per shop after shop changes |
np_shops:waypoint |
{ x, y, label? } |
Sync keys: robbery (RobberyHud or null), orders (open food orders), duty ({ shopId, role } or null), pickup
({ [shopId]: count }), delivery (the courier job in transit).