Background information

internal command and general information about how the script works.

General Information

  • If a player joins a poker table, it creates the table data (state:idle) and places itself on the first seat, waiting for more players and/or placing your bet. Game starts when all seated players are ready to play.

  • If the last player leaves a table, it gets deleted automatically.

  • A new player can only join a table, if the game state is "idle" and the "main" game state is not running.

  • the hidden cards from each player are not shared with the NUI until it gets revealed. You cant tell its value by looking into the NUI developer console of the client.

  • Stopping the script in mid game should remove spawned objects, NPCs and blips on the map.

  • All NPCs and objects are spawned client side and are not networked.

  • A dropped player (connection lost / quit) gets removed from the table as an active player.

Server Command

The script uses 2 server-side commands, which can be defined in the config file. The main command "th"can be used to toggle debug prints and display current running poker tables and their gamestate.

th debug

This command will toggle the debug prints.

th delete <table id>

This command will reset the whole game at the specified table id.

th tables

This command will show all table data.

A table is not always there or active. Only if a minimum of one player is sitting at a poker table, the table data is created internally. If no player is sitting at a table, the table doesn't exist and wont take up resources. The second server-side command is the poker table template mode "pokerTemplate". Using this mode, you can easily create new tables and have the corresponding coordinates and headings outputted for the table and chairs, which can be used for mapping stuff or new config entries.

pokerTemplate <Player Id>

This command will activate the template mode.

External Events

The script provides events which you can use in external scripts. For example to disable the inventory or metabolism function while playing poker. These are the client-side events:

-- client-side
AddEventHandler("d_texasholdem:PlayerJoinTable", function(tableId, playerId, seat, buyIn)
    print("Player "..playerId.." joined poker table "..tableId.." at seat "..seat.." and payed "..buyIn.."$")
    --do your stuff here | for example disable metabolism system
end)

-- client-side
AddEventHandler("d_texasholdem:PlayerLeaveTable", function()
    print("player left the poker table")
    --do your stuff here | for example enable metabolism system
end)

These are the server-side external events.

-- server-side
AddEventHandler("d_texasholdem:PlayerJoinTable", function(tableId, playerId, seat, buyIn)
    print("Player "..playerId.." joined poker table "..tableId.." at seat "..seat.." and payed "..buyIn.."$")
    --do your stuff here | for example disable metabolism system
end)

-- server-side
AddEventHandler("d_texasholdem:PlayerDisconnectsFromTable", function(data)
    print(data.serverId, data.name, data.seat, data.money)
    --do your stuff here
    --like saving money in database or something else
end)

-- server-side
AddEventHandler("d_texasholdem:HandleTableWinning", function(id, debugTbl)
    print("Table: "..id,"Table Cards: "..debugTbl.tableCards)
    for k,v in pairs(debugTbl.players) do
        if #v > 4 then
            print("Player: "..v[1],"Last move: "..v[2],"Money: "..v[3],"Cards: "..v[4],"Pot: "..v[5],"Pot value: "..v[6],"New money: "..v[7])
        else
            print("Player: "..v[1],"Last move: "..v[2],"Money: "..v[3],"Cards: "..v[4])
        end
    end
end)

Add/Remove Table Entries through Events

You can dynamically add table entries through the following event

local data = {
    tblCoords = {x = -352.986328125, y = 796.65539550781, z = 115.24724578857422, h = 38.710117340088},
    buyIn = 2.5,
    smallBlind = 0.02,
    Name = "Poker Test"
}
TriggerEvent("d_texasholdem:AddTableEntry", "TempPokerTest", data)

and here how to remove

TriggerEvent("d_texasholdem:RemoveTableEntry", "TempPokerTest")

Table Debug Mode

With this feature, it's very easy to create new Config.Location entries and also get the exact coordinations for new mapping stuff. This debug mode can be activated and deactivated for a player using the Config.Commands.template_cmd command. Once the player approaches a poker table, debug lines and prompts will be displayed to them. The debug lines visualize the current orientation of the table and chairs. This can be modified using the prompt and even copied to the clipboard! With a simple button press, you get all the necessary coordinates for the table and chairs, which you can then use for mapping, among other things. The output of the clipboard looks like the following:

pokerTemplate <player id>

tblCoords = {x = -306.18362426758, y = 804.88696289062, z = 118.7779006958, h = 103.98477172852},
seats = {
	[1] = {x = -304.99856567383, y = 804.59704589844, z = 118.7779006958, h = 256.25296020508},
	[2] = {x = -305.84704589844, y = 803.71429443359, z = 118.7779006958, h = 196.01449584961},
	[3] = {x = -307.03088378906, y = 804.00915527344, z = 118.7779006958, h = 136.0145111084},
	[4] = {x = -307.3674621582, y = 805.18176269531, z = 118.7779006958, h = 76.016586303711},
	[5] = {x = -306.52020263672, y = 806.05963134766, z = 118.7779006958, h = 16.014488220215},
	[6] = {x = -305.33636474609, y = 805.76477050781, z = 118.7779006958, h = 316.01449584961}
}

Last updated