For the complete documentation index, see llms.txt. This page is also available as Markdown.

📡Integration example

A small server script that blocks a teleport command while a player is in a wagered game, and logs every finished match.

server.lua
-- Block an action while the player is mid-game.
RegisterCommand('tp', function(source)
    if exports['var_chess']:IsPlayerInGame(source) then
        TriggerClientEvent('chat:addMessage', source, {
            args = { 'Chess', 'You cannot teleport during a chess match.' },
        })
        return
    end
    -- ... your teleport logic here
end)

-- React when any match ends (stats, logging, payouts, ...).
AddEventHandler('var_chess:server:matchEnded', function(data)
    print(('[chess] table %s ended, winner=%s pot=%s'):format(
        data.id, tostring(data.winner), data.pot))
end)

IsPlayerInGame is true only while the match is actually playing, so players sitting in the lobby (waiting for an opponent) are not blocked.

Last updated