Create and delete tables, find out where a player is seated and react to rounds, matches and bets from your own resources. The whole API is server side.
Server exports
GetTables
Returns every table.
local tables = exports.cuxial_domino:GetTables()Returns: table[], sorted by id. Each entry is a table summary:
| Field | Type | Description |
|---|---|---|
id | number | Table id. |
name | string | nil | Name given to the table. |
pos | table | { x, y, z }. |
heading | number | Heading of the table. |
maxPlayers | number | 1 to 4. |
teamMode | boolean | true on 4 player team tables. |
tableModel | string | Model of the table. |
scoreMode | string | 'classic' or 'fives'. |
betMin, betMax | number | nil | Bet limits of the table. nil uses the global limits. |
seated | number | Players seated right now. |
inGame | boolean | true while a round is being played. |
for _, t in ipairs(exports.cuxial_domino:GetTables()) do
print(t.id, t.name, t.seated, t.inGame)
endGetTable
Returns the summary of one table.
local tbl = exports.cuxial_domino:GetTable(id)| Parameter | Type | Description |
|---|---|---|
id | number | Table id. |
Returns: a table summary, or nil when the table does not exist.
local tbl = exports.cuxial_domino:GetTable(3)
if tbl and not tbl.inGame then print('Table 3 is free') endCreateTable
Creates a table and saves it in the database.
local id, err = exports.cuxial_domino:CreateTable(data)| Parameter | Type | Description |
|---|---|---|
data.pos | table | { x, y, z }. Required. Use the coordinates of a player standing on the spot: the table is placed one metre below z. |
data.heading | number | Heading. 0.0 by default. |
data.maxPlayers | number | 1 to 4. 4 by default. |
data.teamMode | boolean | Teams. Only applies with maxPlayers = 4. |
data.style | string | 'luxury', 'wood' or 'classic'. 'luxury' by default. |
data.tableModel | string | A model name. When given, it replaces style. |
data.scoreMode | string | 'classic' or 'fives'. 'classic' by default. |
data.name | string | Name of the table. Cut at 60 characters. |
data.betMin, data.betMax | number | Bet limits. Both are needed; with only one, the table uses the global limits. |
Returns: the id of the new table, or nil and a reason. The reason is 'err_too_close' when another table is closer than table.minDistanceBetween, and 'err_table_not_found' when data or data.pos is missing.
local id, err = exports.cuxial_domino:CreateTable({
pos = { x = 195.0, y = -934.0, z = 30.7 },
heading = 90.0,
maxPlayers = 4,
teamMode = true,
style = 'wood',
scoreMode = 'classic',
name = 'Main square',
betMin = 100,
betMax = 5000,
})
if not id then print('Could not create the table: ' .. tostring(err)) endDeleteTable
Deletes a table. Seated players are stood up and any bet already charged is returned.
local ok = exports.cuxial_domino:DeleteTable(id)| Parameter | Type | Description |
|---|---|---|
id | number | Table id. |
Returns: boolean. false when the table does not exist.
exports.cuxial_domino:DeleteTable(3)GetPlayerTable
Returns where a player is seated.
local tableId, seat = exports.cuxial_domino:GetPlayerTable(source)| Parameter | Type | Description |
|---|---|---|
source | number | Server id of the player. |
Returns: the table id and the seat number (1 to 4), or nil when the player is not seated.
local tableId, seat = exports.cuxial_domino:GetPlayerTable(source)
if tableId then print(('Seated at table %d, seat %d'):format(tableId, seat)) endIsSeated
Tells whether a player is seated at a table.
local seated = exports.cuxial_domino:IsSeated(source)Returns: boolean.
if exports.cuxial_domino:IsSeated(source) then return endon
Registers a function for one of the events listed below.
local handle = exports.cuxial_domino:on(event, fn)| Parameter | Type | Description |
|---|---|---|
event | string | Event name without prefix, for example 'matchFinished'. |
fn | function | Receives the payload of the event. |
Returns: a numeric handle, or nil when the arguments are not valid.
local handle = exports.cuxial_domino:on('matchFinished', function(payload)
print(('Table %d: seat %s won'):format(payload.tableId, tostring(payload.winnerSeat)))
end)off
Removes a function registered with on.
local removed = exports.cuxial_domino:off(handle)Returns: boolean.
exports.cuxial_domino:off(handle)Server events
Every event is also triggered as a local server event named cuxial_domino:<event>. This is the simplest way to listen:
AddEventHandler('cuxial_domino:betPaid', function(payload)
print(('Table %d paid a pot of $%d'):format(payload.tableId, payload.total))
end)| Event | Payload | When |
|---|---|---|
tableCreated | { id, table, by } | A table is created. table is its summary. by is the server id of the staff member, or nil when created by export. |
tableRemoved | { id, by } | A table is deleted. |
playerSeated | { tableId, seat, source } | A player sits down. |
playerLeft | { tableId, seat, source, reason } | A player leaves the table. |
roundStarted | { tableId, seats, scoreMode } | A round starts. seats is the list of seats playing, AI included. |
tilePlayed | { tableId, seat, tile, side } | A tile is placed, by a player or by the AI. tile is { a, b }. |
bonus | { tableId, seat, points, kind } | A classic match bonus is scored. |
roundEnded | { tableId, winnerSeat, reason } | A round ends. winnerSeat can be nil. |
matchFinished | { tableId, winnerSeat, scores } | A match ends. scores maps each seat to its points. |
betPaid | { tableId, winnerSeat, total } | The pot is paid to the winner. total is the whole pot. |
Values
| Field | Values |
|---|---|
playerLeft.reason | 'left' (by choice), 'disconnected', 'inactive' (turns ran out) |
tilePlayed.side | 'start', 'left', 'right'; in All Fives also 'top' and 'bottom' |
bonus.kind | 'round_pass', 'opening_pass', 'capicua' |
roundEnded.reason | 'domino' (a player went out), 'blocked', 'fives_target' and 'bonus_target' (target reached during the round), 'player_left' (round cancelled), 'last_standing', 'solo_left', 'no_players' |
Seats are numbered 1 to 4. 2 player tables use seats 1 and 3. On 1 player tables the player is seat 1 and the AI is seat 2. In team tables, seats 1 and 3 play against 2 and 4.
Client
Cuxial Domino has no client exports or public client events.
