Exports ​
What other resources may rely on, called as exports.np_darts:<name>(...). np_darts depends on none of the callers
(only oxmysql, np_prophandler and np_npchandler). Every table returned is a plain copy.
Where an export takes src | cid, pass a server id (number) or a character id (string, the framework's identifier or
citizenid).
Server ​
server
| Export | Returns |
|---|---|
GetPlayerDartsRating(src | cid, mode?) |
rating, rank for mode (default 'x01'); rank 'newcomer', 'regular', 'shark' or 'legend'. nil without a profile |
GetPlayerStats(src | cid) |
{ cid, name, nickname, level, levelPct, xp, rating, rank, avg, first9, checkoutPct, checkouts, checkoutAttempts, matches, wins, s180, ton, highOut, highOutRoute, bestLeg, stakeProfit } or nil |
AddDartsXP(src | cid, amount, reason?) |
boolean. Logged with the reason (default: the calling resource) |
StartMatch(boardId, opts) |
matchId or nil, err. See below |
EndMatch(matchId, reason?) |
boolean. Ends the match, every stake is refunded |
GetMatch(matchId) |
The public match, or nil |
GetPlayerMatch(src) |
match, playerIndex of the match the player is in, or nil |
IsPlaying(src) |
boolean |
GetBoardState(boardId) |
The board snapshot, or nil |
GetBoards(pubId?) |
{ { id, pub, label, coords, heading, status } }, all boards or one pub's |
GetPubs() |
{ { id, label, sub, boards = { boardId, … } } } |
GetIntoxication(src) |
0..1: the highest of every intoxication source |
GiveDartSet(src, setId) |
ok, err ('invalid', 'no_space', 'no_character'). An item with metadata, a per-set item, or a profile entry, by inventory |
AddPubRevenue(pubId, amount) |
boolean. Bar scripts: report drinks sold during darts for the owner's revenue statistic (no money moves) |
useFlights is the item export of dart_flights for np_inventory and ox_inventory (server.export = 'np_darts.useFlights'); don't call it yourself.
StartMatch ​
local matchId, err = exports.np_darts:StartMatch('tequilala:1', {
mode = 'x01', start = 501, legs = 3, doubleIn = false, doubleOut = true,
handicap = 'off', -- or 'average'
stake = 0, -- > 0: every human player gets a checkout sheet first
lives = 3, -- killer
players = { src1, src2 }, -- server ids, or { ai = 'easy' | 'pub' | 'shark', name? } for the house regular
})
Starts a match from code (events, tournaments run by another resource). The options are checked like the lobby's
(Config.Modes, the pub's stake cap, a forced handicap), the players must be online with a character, near the board
or in the pub, and not busy. With a stake it yields while the stakes are collected. Errors: 'invalid',
'mode', 'stake_range', 'no_stakes', 'killer_players', 'no_target', 'board_busy', 'in_match', 'busy',
'too_far', 'stake_failed'.
Public match ​
{ id, board, pub, mode, opts, leg, legsToWin, turn, phase = 'aim' | 'pull' | 'done', finished, winner, stake,
practice, league, cup, thrower, suggestion = { bed, route? }, routes,
players = { { key, name, legs, ai, src, out, score, opened, marks, points, target, number, lives, killer, total,
avg, first9, checkout, checkouts, checkoutAttempts, s180, ton, darts } },
visit = { player, darts = { { bed, label, score, x, y, bounce, robin } }, scored, start, done, bust },
visits } -- the last 40 visits
Which player fields are set depends on the mode: score / opened (x01), marks / points (Cricket), target
(Around the Clock), number / lives / killer (Killer), total (practice).
Board snapshot ​
{ id, pub, pubLabel, label, status = 'free' | 'setup' | 'starting' | 'match' | 'maintenance',
queue = { { name, note } }, price, rental = { name, untilTs } | nil, spectators, sisal,
open = { host, mode, start, stake, legs } | nil, -- an open challenge
match = <public match> | nil }
The same table is replicated as GlobalState['npdarts:board:<id>'] (see State bags).
Client ​
client
| Export | Returns |
|---|---|
IsPlaying() |
boolean: in a match |
IsAiming() |
boolean: aiming a dart right now |
IsSpectating() |
boolean |
GetBoard() |
The board id you play at or watch, or nil |
OpenProfile() |
Opens the profile |
OpenLoadout() |
Opens the dart case |
OpenOwnerPanel(pub?) |
Opens the owner panel of pub (default: your first pub) when you own one |
-- client: hide your own HUD while you aim
CreateThread(function()
while true do
Wait(250)
if exports.np_darts:IsAiming() then HideMyHud() end
end
end)