Skip to content

Events, commands & keys ​

Server events ​

server

Server-local (AddEventHandler), never sent over the network, fired after the server applied the change. src is nil for the house regular, cid is the character id.

Event Payload
np_darts:matchStart { id, board, pub, mode, stake, players = { { src, cid, ai } } }
np_darts:dart { match, board, player, src, cid, bed, score, bust } (player = index in the match)
np_darts:visit { match, board, src, cid, score, bust, darts }
np_darts:180 { match, board, pub, src, cid }
np_darts:checkout { match, board, src, cid, score, darts } (darts = darts in the leg)
np_darts:matchEnd { id, board, pub, mode, reason, stake, money, winner = { src, cid, ai } | nil, players = { { src, cid, ai, name, avg, legs } } }
np_darts:milestone { cid, src, id } (see Milestones)
np_darts:nineDarter { cid, src, board, pub }
np_darts:challenge { cid, src, id } (a weekly challenge was completed)
np_darts:leagueResult { league, fixture, winner } (winner = cid)
np_darts:cupWon { cup, cid, prize }

reason of matchEnd: 'won', 'forfeit', 'conceded', 'ended' (practice or a single player), 'staff', 'aborted', or the reason passed to EndMatch. money is { pot, rake, prize, paid } after a payout, { refunded = true } after a refund, nil without a stake.

lua
AddEventHandler('np_darts:matchEnd', function(e)
  if e.money and e.money.prize then
    print(('%s won $%d at %s (%s)'):format(e.winner and e.winner.cid or '?', e.money.prize, e.pub, e.mode))
  end
end)

np_darts itself listens to np_payments:paid (drinks revenue), np_character:loaded / np_character:unloaded, the framework's load, logout and job events, esx_status:update (drunk status) and np_admin:ready / np_admin:settingsChanged (through the np_admin lib).

State bags ​

Replicated GlobalState, read by every client (players, spectators, late joiners, the chalkboard, the phone):

Key Value
npdarts:boards Board list: { { id, pub, label, coords, heading, spawn, model, anims, bucket, first } }
npdarts:board:<id> The live board snapshot: status, queue, rental, open challenge, the match with the current visit's darts
npdarts:pubs { [pubId] = { id, label, sub, center, radius, blip, rules, events, records, owner } }

Network events ​

Two events carry everything between client and server; they are internal, use the exports instead.

Event Direction What
np_darts:rpc client → server (id, name, payload), server → client (id, result) The RPC channel (see NUI contract)
np_darts:push server → client { action, data } Pushes: match:start, match:turn, match:dart, match:leg, match:end, invite, invite:expired, invite:declined, rematch, react, busy, open, place, toast

Commands ​

Command Who What
/darts (/darts profile, /darts stats) Everyone Your profile
/darts loadout (/darts case) Everyone The dart case
/darts owner [pub] (/darts pub) Pub owners, np_darts.owner The owner panel
/darts place [pub] Pub owners at their pub, np_darts.place anywhere The board placement tool (default pub: the nearest board's)
/darts end np_darts.admin End the match on the nearest board (15 m), stakes refunded
darts (server console) Console Prints the number of boards and running matches

The command name is Config.Admin.command (darts).

Keys ​

All are RegisterKeyMappings: players rebind them in Settings → Key Bindings → FiveM.

Key Command Where Action
E +np_darts_interact At a board Set up a match · accept an open challenge · pull your darts
Q +np_darts_queue Near a board Chalk your name
G +np_darts_watch Near a board Watch / stop watching · after a big moment: celebrate
TAB np_darts_scores Playing or watching Scoreboard
H / J np_darts_cheer / np_darts_boo Watching Cheer / boo
LMB (hold, release) +np_darts_throw Aiming Throw: release in the window
RMB (hold) +np_darts_breath Aiming Hold breath
Backspace ×2 np_darts_leave Playing Concede / end practice
Mouse – Aiming Aim

The defaults are Config.Keys (interact, queue, spectate, scores, cheer, boo, leave). In the placement tool E places, the mouse wheel moves the cabinet off the wall, ← / → turn it and Backspace cancels (see Placing boards). With np_menu the cabinets also get third-eye options.