> For the complete documentation index, see [llms.txt](https://doc.var-fivem.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.var-fivem.com/chess/configuration/integration-example.md).

# Integration example

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

{% code title="server.lua" %}

```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)
```

{% endcode %}

{% hint style="info" %}
`IsPlayerInGame` is true only while the match is actually `playing`, so players sitting in the lobby (waiting for an opponent) are not blocked.
{% endhint %}
