Texas Holdem Poker

Informations

​Forum post​
​Showcase video​
​Tebex (buy)​

READ FIRST

This resource is standalone, so it is not linked to any framework, comes from that you will need to adjust some functions to fit your server, explanations below.
The script is written in Javascript (server,client), but you will do not need to edit any of them. Everything which is important is in the config file which is lua language.
I used Vue (not webpacked) for the frontend.
Our resource does not includes buying chips, this is the one function that you will need to setup with your server, how you want to give the chips to players or buy them etc.
More explanation about the exported function below.
If you do not have chips, then players will not be able to play the game.

Features

  • Custom deck design, with all of the 52 cards.
  • Custom table model prop.
  • Easily creatable tables with adjustable blinds. (We are spawning the models)
  • Player sit animations are synced, unless you have oneSync turned on. (This will mess up the syncing sometimes)
  • Statistics system, it will save: amount of chips betted(all),played games, calculate the winrate and other things.
  • Openable statistics on players, who are playing.
  • Game event log
  • Settable avatar images.
  • Responsive design. (Vue, not webpacked)
  • Players are able to watch the game without sit down at the table, if five players playing the game, and thats a community event then the whole server can watch the poker game hows it playing out. (Simply pressing E)
  • ... And almost everything is done which is came to my mind, all-in, throwing, passing. When the player passes, then the round starts over, etc. etc. Reactive buttons, and many other.
  • One thing which is missing from the script is the sidepots, this was the thing I missed when I wrote the script, at the end I could not figure out how could I implement it, so there is no sidepots, and there wont.

Dependency files

  • mysql (npm will automatically install it for you, when typing npm install in the folder)

Installation

  1. 1.
    Unzip the rar file, and copy the folder in your fivem resources folder. You will own two folders after the purchase, one for the table modelling prop and one for the script.
  2. 2.
    After you put the folders in the resources, we need some terminal(cmd) actions, to install the required dependencies(mysql), we could not use the default lua mysql, thats why we need this things. (More info below, how to install)
  3. 3.
    Import the .sql file into your database, do not forget to modify the .sql selected database. (currently USE 'testserver';)
  4. 4.
    You need to connect your database. (open: ./server/mysql.js file)
  5. 5.
    Create or modify the locale files, if you do not want the script to be english, we have two locale files, because we needed one also for the html. (./config/sv_locales.js, ./html/js/locale.js)
  6. 6.
    start PokerJS
  7. 7.
    start pokerasztal
1
const pool = mysql.createPool({
2
host: "localhost", // mysql host ('ip')
3
user: "root", // your mysql user name
4
database: "testserver", // your mysql database name
5
port: 3306, // mysql host port
6
// password: YOURPASSWORD,
7
waitForConnections: true,
8
connectionLimit: 500,
9
queueLimit: 0,
10
timeout: 600000
11
})
Copied!

Dependency (mysql) installation

Open up a terminal(cmd), and type.
cd -resource folder-
After just type npm i or npm install

Config files

config.lua

1
Config = {}
2
​
3
-- ALWAYS GIVE THEM SEPARATE 'ID'!
4
Config.PokerTables = {
5
{ id = 1, pos = vector3(1111.128, 217.078, -50.440), heading = 165.9, blind = 20 },
6
{ id = 2, pos = vector3(1104.686, 208.9376, -50.440), heading = 56.8, blind = 100 }
7
}
8
​
9
-- CREATING TEST TABLES, COMMENT OR DELETE THIS FUNCTION, IF YOU DO NOT WANT
10
-- TO ADD MORE POKER TABLES, BECAUSE PLAYERS CAN SPAWN TABLES WITH THE COMMAND
11
-- After you entered the command, the table coords will show up in your client console. (F8)
12
-- Then just write the coords and the neccessary variables in the Config.PokerTables
13
local testTable = nil
14
RegisterCommand('createpokertable', function()
15
if DoesEntityExist(testTable) then
16
return
17
end
18
​
19
local pokermodel = 'pokerasztal'
20
RequestModel(pokermodel)
21
while not HasModelLoaded(pokermodel) do
22
print('not exist')
23
Citizen.Wait(100)
24
end
25
​
26
testTable = CreateObject(pokermodel, GetEntityCoords(PlayerPedId()), false, false, false)
27
SetEntityHeading(testTable, GetEntityHeading(PlayerPedId()))
28
PlaceObjectOnGroundProperly(testTable)
29
​
30
Citizen.Wait(1000)
31
local pos = GetEntityCoords(testTable)
32
local _, groundZ, offsets = GetGroundZCoordWithOffsets(pos.x, pos.y, pos.z)
33
print(vector3(pos.x, pos.y, groundZ))
34
print(GetEntityHeading(testTable))
35
​
36
Citizen.Wait(2500)
37
if DoesEntityExist(testTable) then
38
DeleteObject(testTable)
39
end
40
end)
41
​
42
-- THESE ARE NOT FOR YOU! --
43
44
Config.PlayerAnimDictShared = '[email protected]@[email protected]@[email protected]@'u
Copied!

sv_config.lua

1
​
2
-- use this giveChips export function to give chips to a player.
3
exports('poker_giveChips', function(source, amount)
4
exports[GetCurrentResourceName()]:js_poker_giveChips(source, amount)
5
end)
6
-- use this removeChips export function to remove chips from a player.
7
exports('poker_removeChips', function(source, amount)
8
exports[GetCurrentResourceName()]:js_poker_removeChips(source, amount)
9
end)
10
-- use this setChips export function to set the target player's chips amount. (good for admin cmd.)
11
exports('poker_setChips', function(source, amount)
12
exports[GetCurrentResourceName()]:js_poker_setChips(source, amount)
13
end)
14
​
15
​
16
-- THESE ARE NOT FOR YOU!
17
-- THESE ARE NOT FOR YOU!
18
exports('serverLog', function(log)
19
print(json.encode(log))
20
end)
21
exports('getConfigVal', function(key, cb)
22
if Config[key] then
23
if cb then cb(Config[key]) end
24
return Config[key]
25
else
26
if cb then cb() end
27
return
28
end
29
end)
30
exports('getPlayers', function()
31
return GetPlayers()
32
end)
Copied!

sv_locales.js

1
const lang = 'en';
2
const Translations = {}
3
​
4
Translations['en'] = {
5
"reveal_cards": "Revealing player cards.",
6
"deal_flop": "Dealing flop cards.",
7
"deal_turn": "Dealing turn card.",
8
"deal_river": "Dealing river card.",
9
"everyone_throwed": "The game ended, everyone throwed in.",
10
"new_game_begins": "New game starting.",
11
"not_valid_bet": "Not valid bet amount",
12
"error_not_sitting": "You are not sitting at the chair.Some error happened ?",
13
"not_enough_chips": "You do not have enough chips.",
14
"error_some": "Some error happened during the calling, try to bet.",
15
"can_not_join_yet": "You can not join to the game yet, wait for the current party to end.",
16
"not_enough_chips_toplay": "You do not have enough chips to play!",
17
"smallblind_not_enough_chips": "Small blind player did not have enough chips to bet in the round, the game did not start.",
18
"bigblind_not_enough_chips": "Big blind player did not have enough chips to bet in the round, the game did not start.",
19
​
20
// STAT NAMES
21
"stat_wonchips": "Won chips",
22
"stat_played": "Played games",
23
"stat_wongames": "Won games",
24
"stat_betchips": "Chips betted",
25
"stat_winrate": "Winrate",
26
​
27
// FORMATTED
28
"dealer_is": "Dealer is: {REPLACE}.",
29
"bet_smallblind": "{REPLACE} put in the small blind {REPLACE} chips.",
30
"bet_bigblind": "{REPLACE} put in the big blind {REPLACE} chips.",
31
"bet_raised": "{REPLACE} raised the bet with {REPLACE} chips.",
32
"simple_bet": "{REPLACE} bet {REPLACE} chips.",
33
"throwed": "{REPLACE} throwed his cards.",
34
"player_joined": "{REPLACE} joined to the party.",
35
"player_leaved": "{REPLACE} leaved the party.",
36
"minimum_bet_is": "Minimum bet is {REPLACE} chips.",
37
"raise_should_be": "Raise should be double of the highest bet {REPLACE} chips.",
38
"winner_is": "{REPLACE} won {REPLACE} chips."
39
}
40
​
41
function _U(a) {
42
try {
43
return Translations[lang][a] || 'UNKNOWN_TRANSLATION';
44
}
45
catch {
46
return 'UNKOWN_TRANSLATION';
47
}
48
}
49
​
50
function _(a, ...args) {
51
try {
52
let tr = Translations[lang][a];
53
args.forEach(text => {
54
tr = tr.replace('{REPLACE}', text);
55
});
56
return tr;
57
}
58
catch {
59
return 'UNKNOWN_TRANSLATION';
60
}
61
}
62
​
Copied!

Export functions

You will need to setup the giveChips and removeChips functions, to fit your server.
Our resource is not including buying chips, so add these exported functions where you want to give the players the chips.
1
-- use this giveChips export function to give chips to a player.
2
exports('poker_giveChips', function(source, amount)
3
exports[GetCurrentResourceName()]:js_poker_giveChips(source, amount)
4
end)
5
-- use this removeChips export function to remove chips from a player.
6
exports('poker_removeChips', function(source, amount)
7
exports[GetCurrentResourceName()]:js_poker_removeChips(source, amount)
8
end)
9
-- use this setChips export function to set the target player's chips amount. (good for admin cmd.)
10
exports('poker_setChips', function(source, amount)
11
exports[GetCurrentResourceName()]:js_poker_setChips(source, amount)
12
end)
Copied!
Last modified 2mo ago