> For the complete documentation index, see [llms.txt](https://organized-chaos.gitbook.io/organized-chaos-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://organized-chaos.gitbook.io/organized-chaos-docs/chess/configuration.md).

# Configuration

Every option in the Chess config.lua, with its default.

All options are in `config.lua`. Restart the resource after a change: `restart chess`.

The Discord logging has a file of its own, `config_server.lua`, because `config.lua` is sent to every player. See [Discord logging](/organized-chaos-docs/chess/discord-logging.md).

## Language

| Option          | Default | Meaning                                                    |
| --------------- | ------- | ---------------------------------------------------------- |
| `Config.Locale` | `'en'`  | Language, `'en'` or `'de'`. The texts are in `locales.lua` |

## Tables

| Option                  | Default                                           | Meaning                                                                                                                         |
| ----------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `Config.Tables`         | one table on Legion Square                        | Fixed tables. `coords` is the centre on the ground, `heading` the way White faces, `skin` one of `Config.TableSkins` (optional) |
| `Config.TableSkins`     | `{ 'marble', 'ebony', 'metal', 'glass', 'neon' }` | The table looks besides the plain wood. See [Table looks](/organized-chaos-docs/chess/table-looks.md)                           |
| `Config.SnapToGround`   | `true`                                            | Put the table on the ground under `coords` instead of exactly at its height                                                     |
| `Config.RenderDistance` | `45.0`                                            | Metres from which a table, its chairs, the pieces and the demo board are drawn                                                  |
| `Config.Label`          | `false`                                           | Yellow text over the table for players standing close. Off by default because it is drawn every frame                           |
| `Config.SeatDistance`   | `1.2`                                             | Metres from a free chair at which sitting down is offered                                                                       |
| `Config.SitScenario`    | `'PROP_HUMAN_SEAT_CHAIR_MP_PLAYER'`               | How a seated player sits                                                                                                        |
| `Config.SitOffsetZ`     | `0.5`                                             | How far above the ground a seated player's hips are. Change it if the ped sits too high or too low                              |
| `Config.WatchDistance`  | `3.5`                                             | Metres from the table's centre within which a game can be watched                                                               |
| `Config.ClockProp`      | `true`                                            | Put a chess clock beside the board                                                                                              |

## Clocks

| Option                | Default     | Meaning                                                                                                                                       |
| --------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `Config.TimeControls` | six entries | The clocks on offer in the lobby. `minutes` is for the whole game, `increment` is seconds added per move. `minutes = 0` plays without a clock |
| `Config.TimeControl`  | `4`         | Which of them a table starts out with, by its place in the list                                                                               |
| `Config.ClockWarning` | `20`        | Seconds left from which a clock turns red, and a player's own clock ticks a warning                                                           |

The default list:

```lua
Config.TimeControls = {
    { minutes = 0, increment = 0 },
    { minutes = 3, increment = 2 },
    { minutes = 5, increment = 0 },
    { minutes = 10, increment = 0 },
    { minutes = 15, increment = 10 },
    { minutes = 30, increment = 0 },
}
```

## Board, pieces and sounds

| Option                  | Default                                                                        | Meaning                                                                                                     |
| ----------------------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------- |
| `Config.Look`           | `{ Board = 'green', Pieces = 'neo', Sounds = 'wood', Coordinates = 'inside' }` | What a player sees and hears until they choose for themselves                                               |
| `Config.PlayerSettings` | `true`                                                                         | Let every player choose their own board, pieces and sounds (the gear). `false`: everyone sees `Config.Look` |
| `Config.Unlocks`        | nothing locked                                                                 | Boards, pieces and sound themes kept for some players: VIPs, a job, the owners of an item                   |

The choices and the rules for `Config.Unlocks` are on [Board, pieces and sounds](/organized-chaos-docs/chess/board-pieces-and-sounds.md).

## Moving

| Option             | Default                                        | Meaning                                                                              |
| ------------------ | ---------------------------------------------- | ------------------------------------------------------------------------------------ |
| `Config.ShowMoves` | `true`                                         | Mark the squares the piece in hand may go to. `false` for a bare board, for everyone |
| `Config.Premoves`  | `true`                                         | Allow entering moves while the opponent is to move                                   |
| `Config.SlideTime` | `350`                                          | Milliseconds a piece on the table takes to reach its new square. `0` makes it jump   |
| `Config.ReachAnim` | `{ dict = 'mp_common', name = 'givetake1_a' }` | The gesture made when moving a piece. `false` for none                               |

## Computer opponent

| Option                    | Default                           | Meaning                                                                                                                                                        |
| ------------------------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Config.Bots`             | `true`                            | Allow the computer opponent                                                                                                                                    |
| `Config.BotDelay`         | `{ 1200, 3000 }`                  | The computer's minimum thinking time in milliseconds, from and to                                                                                              |
| `Config.BotRating`        | `1200`                            | Strength of a newly added computer, from 400 to 2000. The host changes it with a slider in the lobby. `Config.BotLevel` of older versions (1 to 3) still works |
| `Config.BotPersonalities` | Pip, Rosa, Marco, Ingrid, Viktor  | Who the computer is from which rating on: `{ rating, name }`. The short descriptions are `bot_<rating>` in `locales.lua`                                       |
| `Config.BotNodes`         | `80000`                           | How many positions the strongest computer looks at per move. More plays better and takes longer; the weaker ones look at fewer                                 |
| `Config.BotSlice`         | `6`                               | Milliseconds of every server tick the computer may spend thinking                                                                                              |
| `Config.BotPeds`          | two business peds                 | The peds that sit in for the computer, by seat. `{}` leaves the chair empty                                                                                    |
| `Config.BotScenario`      | `'PROP_HUMAN_SEAT_CHAIR_UPRIGHT'` | How those peds sit                                                                                                                                             |
| `Config.Takebacks`        | `true`                            | Offer "Take back" against the computer                                                                                                                         |
| `Config.Hints`            | `true`                            | Offer "Hint" against the computer                                                                                                                              |

```lua
Config.BotPersonalities = {
    { rating = 400, name = 'Pip' },
    { rating = 800, name = 'Rosa' },
    { rating = 1200, name = 'Marco' },
    { rating = 1600, name = 'Ingrid' },
    { rating = 2000, name = 'Viktor' },
}
```

{% hint style="info" %}
The computer's search, and the game review's, is spread over as many server ticks as it takes, `Config.BotSlice` milliseconds at a time, so the server does not stutter. If your server is already under load, lower `Config.BotNodes` and `Config.ReviewNodes` before you lower `Config.BotSlice`.
{% endhint %}

## Ratings and saved games

| Option               | Default | Meaning                                                     |
| -------------------- | ------- | ----------------------------------------------------------- |
| `Config.Ratings`     | `true`  | Keep a rating (Elo) for every player. `false` for none      |
| `Config.RatingStart` | `1200`  | The rating a new player starts with                         |
| `Config.RatingK`     | `32`    | The most one game can move a rating                         |
| `Config.GameLog`     | `100`   | How many finished games stay in `games.pgn`. `0` keeps none |

## Review, puzzles, leaderboard and demo board

| Option                       | Default                    | Meaning                                                                                                                                         |
| ---------------------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `Config.Review`              | `true`                     | Offer the review after a game. See [Game review](/organized-chaos-docs/chess/game-review.md)                                                    |
| `Config.ReviewNodes`         | `6000`                     | How many positions the review looks at per move                                                                                                 |
| `Config.Puzzles`             | `true`                     | Offer puzzles. See [Puzzles](/organized-chaos-docs/chess/puzzles.md)                                                                            |
| `Config.PuzzleRatingStart`   | `1200`                     | The puzzle rating a player starts with                                                                                                          |
| `Config.PuzzleK`             | `20`                       | The most one puzzle can move it                                                                                                                 |
| `Config.Leaderboard`         | `true`                     | The leaderboard, its command and the panels. See [Leaderboard and demo board](/organized-chaos-docs/chess/leaderboard.md)                       |
| `Config.LeaderboardMinGames` | `1`                        | Rated games a player needs to be on it                                                                                                          |
| `Config.BoardStyle`          | `'easel'`                  | How the boards in the world look: `'easel'` (a demo board showing the game, the leaderboard between games) or `'panel'` (the leaderboard alone) |
| `Config.LeaderboardBoards`   | one beside the first table | Boards in the world: `{ table = 'c1', side = 1 }` or `{ coords, heading }`, each with an optional `style`                                       |

## Reactions

| Option                    | Default                                  | Meaning                                                                                  |
| ------------------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------- |
| `Config.Reactions`        | `{ '👏', '😂', '😱', '🤔', '👑', 'GG' }` | The reactions a seated player can send: emoji or short words, up to eight. `{}` for none |
| `Config.ReactionCooldown` | `2000`                                   | Milliseconds a player has to wait before the next reaction                               |

## Connection and sound

| Option                 | Default | Meaning                                                                      |
| ---------------------- | ------- | ---------------------------------------------------------------------------- |
| `Config.ReconnectTime` | `120`   | Seconds a seat is kept after a lost connection. `0` loses the game at once   |
| `Config.Sounds`        | `true`  | Sounds of the pieces for players near a table, in each one's own sound theme |
| `Config.SoundDistance` | `10.0`  | How far those sounds carry, in metres                                        |
| `Config.DefaultVolume` | `0.7`   | Volume from 0 to 1 for players who have not set their own yet                |

## Framework and stake

| Option                | Default   | Meaning                                                                                                                                                                                                                                                      |
| --------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Config.Framework`    | `'auto'`  | Where names and money come from. `'auto'` takes what is running: Qbox, QBCore, ESX, or failing those the cash of `ox_inventory`. Or name one: `'qbx'`, `'qb'`, `'esx'`, `'ox_inventory'`, `'none'`. For anything else, give functions of your own, see below |
| `Config.BuyIn`        | `0`       | Stake per player and game. The winner takes the pot, a draw returns each stake. `0` plays for nothing. Needs a framework                                                                                                                                     |
| `Config.BuyInAccount` | `'money'` | The account the stake comes from, `'money'` (cash) or `'bank'`                                                                                                                                                                                               |

Functions of your own, each taking the player's server id:

```lua
Config.Framework = {
    name = function(src) return ... end,              -- optional
    ident = function(src) return ... end,             -- optional: the character, for ratings and winnings
    job = function(src) return name, grade end,       -- optional: for looks kept for a job
    hasItem = function(src, item) return true end,    -- optional: for looks kept for an item
    balance = function(src) return ... end,
    remove = function(src, amount) ... return true end,
    add = function(src, amount) ... return true end,
}
```

## Keys and messages

| Option               | Default  | Meaning                                                                                                                                                                                                                   |
| -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Config.KeyInteract` | `38` (E) | Sit down, open the board                                                                                                                                                                                                  |
| `Config.KeyStandUp`  | `73` (X) | Stand up                                                                                                                                                                                                                  |
| `Config.KeyWatch`    | `47` (G) | Watch a game from beside the table                                                                                                                                                                                        |
| `Config.Notify`      | `'gta'`  | Where messages go while the board is closed. `'gta'` is the feed above the minimap, `'esx'` uses `esx:showNotification`, `'qb'` uses `QBCore:Notify`, `'ox'` uses `ox_lib:notify`, or give a `function(text)` of your own |
| `Config.Target`      | `true`   | Offer sitting down and watching through `ox_target` if it is running                                                                                                                                                      |

Key numbers are FiveM control ids, listed in the [FiveM controls reference](https://docs.fivem.net/docs/game-references/controls/).

A notification function of your own:

```lua
Config.Notify = function(text)
    exports['my_notify']:Send(text)
end
```

## Commands

| Option                 | Default          | Meaning                                                        |
| ---------------------- | ---------------- | -------------------------------------------------------------- |
| `Config.CommandPlace`  | `'chess_place'`  | The admin command that puts up a table                         |
| `Config.CommandRemove` | `'chess_remove'` | The admin command that takes the nearest placed table away     |
| `Config.CommandStats`  | `'chess_stats'`  | The command that tells a player their rating and record        |
| `Config.CommandTop`    | `'chess_top'`    | The command that lists the best five players. `false` for none |

## Table item

`Config.Item`: players put up tables themselves from an inventory item. What it does, and how to add the item to your inventory, is on the [Table item](/organized-chaos-docs/chess/table-item.md) page.

| Option                            | Default                     | Meaning                                                                                                                                                           |
| --------------------------------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Enabled`                         | `true`                      | `false`: no item                                                                                                                                                  |
| `Name`                            | `'chess_table'`             | The item's name                                                                                                                                                   |
| `Framework`                       | `'auto'`                    | `'auto'` (Qbox, QBCore, ESX, else ox\_inventory), `'esx'`, `'qb'`, `'qbx'`, `'ox'`, or `false` for an inventory of your own that calls `exports.chess:placeTable` |
| `Remove`                          | `true`                      | The item leaves the inventory while the table stands, and comes back when it is picked up. `false`: it stays, as a licence to put up tables                       |
| `MaxPerPlayer`                    | `1`                         | Tables a player may have up at once. `0` for any number                                                                                                           |
| `Place.Distance`                  | `4.0`                       | Metres from the player the table may stand                                                                                                                        |
| `Place.Spacing`                   | `3.5`                       | Metres it has to keep from the middle of any other table                                                                                                          |
| `Place.Radius`, `Place.Slope`     | `1.1`, `0.3`                | The ground this far around has to be free, and may rise or fall this much                                                                                         |
| `Place.Turn`                      | `7.5`                       | Degrees one click of the mouse wheel turns the table                                                                                                              |
| `Place.Animation`, `Place.Time`   | `mini@repair`, `2500`       | What the player does while putting it up, and for how many milliseconds. `Animation = false` puts it up at once                                                   |
| `PickUp.Enabled`                  | `true`                      | `false`: tables cannot be picked up                                                                                                                               |
| `PickUp.Target`                   | `'ox_target'`               | "Pick up the table" on the table. `false`: only the command                                                                                                       |
| `PickUp.Command`                  | `'chess_pickup'`            | Takes down the nearest such table in reach. `false` for none                                                                                                      |
| `PickUp.Icon`, `PickUp.Distance`  | `'fa-solid fa-hand'`, `2.5` | The option's icon, and the metres from the table it shows                                                                                                         |
| `PickUp.OwnOnly`                  | `true`                      | Only the player who put a table up can pick it up                                                                                                                 |
| `PickUp.Animation`, `PickUp.Time` | `mini@repair`, `1500`       | What the player does while taking it down, and for how long                                                                                                       |
