Skip to content

NUI contract ​

The contract between the Lua client, the web UI (web/) and the server RPCs behind it. The wire types are mirrored in web/src/lib/types.ts. You only need this page to change the UI or write your own front end; resources that work with darts use the exports and events.

The NUI is server-authoritative: it only sends intents. The throw model, where a dart lands, the score and the money come from the server. The client never sends an outcome or a price.

There are three pages, one Vite build:

Page Where What
web/dist/index.html ui_page HUD while throwing, scoreboard, lobby, invite, end card, dart case, profile, owner panel, toasts
web/dist/phone.html np_phone iframe The Oche app
web/dist/chalk.html DUI on the pub wall The chalkboard

Messages ​

Lua → NUI: SendNUIMessage({ action, data }). Messages sent before the page reported ready are queued.

Action Data
boot { locale, strings, currency, scale, keys, theme, modes, stakes, gear = { parts, designs }, perks, reducedMotion } (answer to ready)
theme { brand?, strength?, material = 'frosted' | 'liquid' }: np_admin's server theme, unless Config.Material / Config.Theme override it; sent as { action = 'theme', type = 'theme', data }
open / close { screen, data } / { screen }
play { on = true, state, you, board, pub } when a match starts, { on = false, reason } when it stops
turn { you, state }
aim { dart, model, suggestion, state, mapping, you, holdToThrow, reducedMotion }: the sway model of this dart
reticle { x, y, aimX, aimY, ring, breath, holdingBreath, overBreath, holding, phase, breathMs }, about 30 times a second
thrown {}
mapping { mapping? }: board-to-screen projection for the reaction camera
phase { phase = 'pull' | 'pulling' | 'wait' }
dart The resolved dart: { id, player, dart, seq, hit, scored, remaining, bust, bustText, checkout, legWon, matchWon, visitDone, visitScore, max, stage, state, … }
leg { id, leg, state }
end { summary, you, won, board } (then open of the end screen)
ended The match summary, when you weren't playing it
board The board snapshot of the board you play at or watch
spectate { board?, state? }
react { board, kind = 'cheer' | 'boo', name }
rematch { board, from }
invite:gone / invite:declined { board }
toast { type, title, message, icon, tint, app, duration }: only while np_hud isn't running

The chalkboard page gets { action = 'chalk', data = { pub, boards, strings, now } } through SendDuiMessage about every 1.5 s while someone is near.

Screens ​

Screen Focus Opened by
lobby full E at a free board
scoreboard full TAB
invite full A challenge (invite push)
end full The end of your match
loadout full /darts loadout, np_menu, OpenLoadout()
profile full /darts, np_menu, OpenProfile()
pub full /darts owner, OpenOwnerPanel()

The throwing HUD has no focus: the game keeps the mouse for aiming. While a screen or the HUD is up np_darts claims np_hud's zones (ClaimZones).

Callbacks ​

NUI → Lua, https://np_darts/<name>:

Callback Body What
ready {} The page loaded: Lua answers with boot and theme and flushes the queue
close { screen? } Close the screen, release focus
rpc { name, payload } Forwarded to the server RPC, only for allow-listed names (below). Answers the result table
action { kind, … } Client actions: practice { board }, waypoint { x, y }, placeBoard { pub }, leave, screen { screen, data }
waypoint { x, y } From the Oche app (phone.nui('waypoint', …))

RPC methods ​

Client → server: TriggerServerEvent('np_darts:rpc', id, name, payload), answered with TriggerClientEvent('np_darts:rpc', src, id, result). A result is { ok = true, … } or { ok = false, code, error } with a localised error text (English and German).

Checks, in order: the global token bucket (Config.RateLimit), the payload sanity check (depth 8, 512 keys, strings up to 4096 bytes, maxPayload bytes), a loaded character, the permission node, a per-RPC rate limit, one call in flight per player and RPC, the schema (unknown keys are dropped), then the handler.

board:state      { board }                                   -> lobby data (board, pub, rules, players, stakes, rental, ai, sets, …)
lobby:open       { board }                                   reserve the board for setup
lobby:close      { board }
lobby:challenge  { board, opts, target? | open? | ai? | practice? }   opts = { mode, start, legs, doubleIn, doubleOut,
                                                             handicap, stake, lives, clockMultiples, cutThroat }
lobby:respond    { accept }                                  answer a challenge
lobby:accept     { board }                                   accept an open challenge
queue:join       { board, note? } | queue:leave { board }
board:spectate   { board, on } | board:react { board, kind = 'cheer' | 'boo' }
match:rematch    { board } | match:concede {} | match:state {}
throw:begin      {}                                          -> { token, seed, dart, model, board, suggestion, state }   (client-local flow)
throw:release    { token, aim = { x, y }, t, hold, breath? } -> { result }                                (client-local flow)
visit:pull       {}                                                                                      (client-local flow)
intox:native     { level }                                                                               (client-local flow)
profile:get      { filter? = 'all' | 't20' | 'doubles' }
profile:settings { assisted?, reducedMotion?, holdToThrow? }
profile:flair    { nickname?, walkon?, celebrate? }
perks:spend      { id }
loadout:get {} | loadout:save { key, build } | loadout:main { key } | shop:buy { set }
pub:get { pub } | pub:mine {} | pub:rules { pub, rules } | pub:rotate { board } | pub:sisal { board }
pub:event { pub, event } | pub:eventRemove { pub, id } | pub:eventPost { pub, id } | pub:withdraw { pub, amount }
board:place      { pub, coords, heading, label? }                                                        (client-local flow)
board:remove     { board }
league:create    { pub, name, weeks?, wday, hour, division?, entry? } | league:start { id }
league:join { id } | league:leave { id }
cup:create       { pub, name, size, entry?, houseCut? } | cup:start { id } | cup:cancel { id } | cup:join { id }

Methods marked client-local flow are called by the Lua client itself and are not in the NUI rpc allow-list.

The Oche app uses np_phone's app RPCs instead: home, league { id }, cup { id }, pubs, challenges, league:join, league:leave, cup:join (the joins run the server RPCs above).