Hooks and exports
Run your own code before a player sits or plays, after each round and at the bar, call Casino Creator from your own scripts, and follow its actions in gg_lib.
Casino Creator has three server hooks in gg_casino/core/open/server/main.lua and two client hooks in gg_casino/core/open/client/main.lua. Those files are never encrypted, so you can edit them. Return nil from a hook to keep the script's own behavior. An update replaces them, so keep a copy of your changes.
Server hooks
Before a player plays
function open.canPlay(source, game)
return true
end
Runs before a player sits down or puts a bet on a game: the tables, the machines, the prize wheels and the casino app. Return false to stop them. A key from locales/en.json as a second value picks the message they see.
function open.canPlay(source, game)
-- only players with the casino.vip ace may sit at Texas Hold'em
if game == "holdem" then
return IsPlayerAceAllowed(source, "casino.vip")
end
return true
end
After a round
function open.onSettle(source, entry)
end
Runs each time a round is settled for one player, after they are paid.
| Field | Meaning |
|---|---|
entry.game | The game's id |
entry.place | The id of the table, machine or wheel it was played at |
entry.round | The round's id |
entry.stake | What the player put in, in chips (credits at a machine) |
entry.payout | What the round paid, in chips (credits at a machine) |
At the bar
function open.feed(source, food, water)
return nil
end
Runs when a player has something from a casino bar. food and water are 0 to 100. Return true when your server filled hunger and thirst itself, false to do nothing, or nil to let the script do it on Qbox, QBCore or esx_status.
Client hooks
Before a player sits
function open.canSit(game)
return true
end
Runs on the player's own game before they take a seat at a table, machine or wheel. Return false to keep them standing.
function open.canSit(game)
-- no sitting down in cuffs
return not IsPedCuffed(PlayerPedId())
end
Dead or down
function open.isDown()
return nil
end
Whether the player is dead or in last stand. Return nil to keep the script's own check, which reads the game and the common frameworks. Return true or false to answer for your own death script. A player who is down cannot sit. A player found down at a game loses the round in play and is moved off the seat.
Exports
All exports are server side: exports.gg_casino:Name(...).
| Export | What it does |
|---|---|
IsCasinoOpen(id) | Whether a casino can be played now: Enabled and inside its hours |
SetCasinoOpen(id, on) | Turns a casino's Enabled on or off |
IsCasinoPresent(id) | Whether a casino is in the world now |
GetCasinoBuilding(id) | The resource name of the map a casino stands in, or nil |
swapMachine(id, game, look, opts) | Swaps the machine at place id for another game. opts.force puts it down even into a neighbor. Nobody may be playing it. Gives true and the place, or false and why |
mayOwnGames(source) | Whether a player may own machines, tables and wheels under Only Listed Players Can Own Games |
BanFromCasino(player, casino, minutes, reason) | Bars a player from one casino. minutes 0 is for good. Gives true, or false and why |
UnbanFromCasino(player, casino) | Lets a player back in. Gives true when they were barred |
IsBannedFromCasino(player, casino) | Whether they are barred, and until when (os.time(), 0 for good) |
LockOutOfGambling(player, days, reason) | Locks a player out of gambling everywhere. days is 1, 7, 30, 180, or 0 for good. Gives true, or false and why |
LiftGamblingLockout(player) | Lets a player gamble again. Gives true when they were locked out |
IsLockedOutOfGambling(player) | Whether a player is locked out now |
playeris a server id for someone on now, or a character's identifier.casinois a casino's id or its name under Casinos.idin the first four is a casino's id. The ready-made casinos arebelladonna,baylight,pricklypair,fourdragons,gabzdiamond,pearls,molocasino,jurassicjackpotandpatoche.
-- close the Belladonna for an event
exports.gg_casino:SetCasinoOpen('belladonna', false)
-- bar a player from the Baylight for a day
local ok, why = exports.gg_casino:BanFromCasino(source, 'baylight', 1440, 'Card counting')
Game ids
game and entry.game are these ids. The casino app's games use their own, which start with phone_.
| Kind | Games |
|---|---|
| Tables | Blackjack blackjack, Roulette roulette, Baccarat baccarat, Texas Hold'em holdem |
| Machines | Ember Crown Link ember_crown, Prism Falls prism_falls, Vault Row vault_row, Drop Zone drop_zone, Furnace 7s furnace7, Fuego 7s fuego7s, Ice Carat ice_carat, Titan Isle titan_isle, Solar Scarab solar_scarab, Neon Overdrive neon_overdrive, Leviathan Deep leviathan_deep, Aurora Howl aurora_howl, Event Horizon event_horizon, Starfall starfall, Chiliad Storm chiliad_storm, Pier Pressure pier_pressure, Jade Lantern Wheel jade_lantern, Video Poker video_poker, Vinewood Sevens vinewood_sevens, Stacked Poker multi_poker, Comet Keno video_keno, Dead Draw dead_draw, Hop City hop_city, Penthouse Express penthouse_express, Vespucci Fireworks vespucci_fireworks, La Mesa Murals la_mesa_murals, Four Corners four_corners, Blaine County Legends blaine_legends, Mirror Park mirror_park, Twelve Moons twelve_moons, Hot Plate 68 hot_plate, Dock Stack dock_stack, Rockford Flip rockford_flip, Chumash Swell chumash_swell, Sandy Saucers sandy_saucers |
| Wheels | Prize Wheel prize_wheel |
Actions in gg_lib
Casino Creator reports these actions to gg_lib. They show in /ggsettings under Logs > Activity. Under Activity Types you can send them to a Discord webhook with an Alert (casino.* for all of them), or press Code for a hook to paste into gg_lib/hooks/server.lua. See gg_lib hooks.
| Action | Name | When |
|---|---|---|
casino.buyin | Money In | A player put money in: chips or a slip at the cage, or money into a machine or the app |
casino.cashout | Money Out | A player took money out: chips or a slip cashed, Held Winnings collected, a machine or the app cashed out |
casino.bigwin | Big Win | One round paid at least the Big Win Amount |
casino.jackpot | Jackpot | A machine hit one of its jackpots |
casino.wheel | Wheel Made | A prize wheel was made or changed |
casino.prize | Wheel Prize | A prize wheel gave a car, or a prize worth at least the Big Win Amount |
casino.receipt | Gift Receipt Redeemed | A gift receipt was redeemed |
casino.iou | IOU | A casino owed a player money it could not pay at once, or paid it |
casino.dirty | Dirty Money | Dirty money handed in, given back or paid out washed |
casino.owner | Casino Money | Money in or out of a casino's float or account |
casino.floor | Casino Floor Changed | Something placed, changed or removed in the builder, or set down, picked up, seized or removed in a player casino |
casino.staff | Barred Or Locked Out | A player barred or let back in, or locked out of gambling or let back |
casino.admin | Admin Money | An admin gave or took chips, or paid or cleared a player's Held Winnings |
casino.flag | Flagged | Something that looks like an exploit, such as a burst of payouts |
Every action carries source, name and identifier. Money is in dollars. In a hook, put gg_casino: in front of the action:
GGHook('gg_casino:casino.bigwin', function(data)
print(("%s won %s on %s"):format(data.name, data.payout, data.game))
end)
Money In and Money Out are the busiest. To send them to a channel of their own, give each its own Alert.
