> For the complete documentation index, see [llms.txt](https://code-after-sex.gitbook.io/script-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code-after-sex.gitbook.io/script-documentation/cas-shooting-range/tournaments.md).

# Tournaments

Run shooting tournaments in RedM: sign ups, entry fees, rating seeding, byes, check ins, walkovers, prize payouts and every tournament setting.

The range always has one tournament open. Players sign up from the menu, a bracket is drawn, the matches are played at the tournament range, and the prizes are paid out automatically. When a champion is crowned, a new tournament opens by itself.

## For players

1. **Sign up.** Open **Play > Tournament**, or type `/shootingrange tournament`, and press **Enter** (the button shows the fee). The entry fee is taken and held.
2. **Wait for the draw.** The board shows how many have entered, the prize pool and how long until the draw.
3. **Play your match.** When your match is ready you get a notification. Ride to the tournament range and press **Play My Match** (or **Check In**) on the tournament screen. When both shooters have checked in and are at the range, the match starts on its own.
4. **Advance.** Win and you move to the next round. The bracket updates for everyone in real time.

A player can withdraw during sign ups and gets the entry fee back. After the draw, withdrawing gives the opponent a walkover and there is no refund.

## The bracket

* Up to **8 shooters**, single elimination: quarterfinals, semifinals, final.
* Seeded by rating: 1 plays 8, 4 plays 5, 3 plays 6, 2 plays 7. Equal ratings go by sign up order.
* With fewer than 8 entrants, the top seeds get **byes** straight into the next round.
* Every tournament match uses the same format, set in `Config.Tournament`. It is never ranked, the weapon is supplied, false starts use the standard rule and sudden death is on.

## When the draw happens

| Situation                                                       | What happens                                                                |
| --------------------------------------------------------------- | --------------------------------------------------------------------------- |
| The last slot is filled                                         | The bracket is drawn at once.                                               |
| The sign up time runs out with at least `MinPlayers` entrants   | The bracket is drawn.                                                       |
| The sign up time runs out with fewer                            | Sign ups are extended by another `SignupSeconds` and every entrant is told. |
| An admin runs `/shootingadmin draw` or presses **Draw Bracket** | The bracket is drawn now, with at least 2 entrants.                         |

## Check ins and walkovers

A match is ready as soon as both of its shooters are known. From that moment the shooters have `NoShowSeconds` (3 minutes by default) to check in. Halfway through, anyone who has not checked in gets a reminder.

When the time is up:

| Situation                                    | Result                                           |
| -------------------------------------------- | ------------------------------------------------ |
| Only one shooter checked in                  | That shooter wins by walkover.                   |
| Neither checked in                           | The shooter listed first in that match advances. |
| Both checked in, but one has left the server | The one still online advances.                   |

A checked in shooter who is further than 120 metres from the range is told to ride there. The match waits for the range to have two free lanes.

If a tournament match is cancelled (for example after a disconnect), it is voided and both shooters check in again.

## Prizes

The prize pool is every entry fee minus the tournament commission. It is paid out when the final ends:

| Place                    | Default share |
| ------------------------ | ------------- |
| Champion                 | 60%           |
| Runner up                | 25%           |
| Each losing semifinalist | 7.5%          |

Prizes go straight to online players. Offline players are paid the next time they load a character.

## Settings

```lua
Config.Tournament = {
    Enabled = true,
    Arena = 'blackwater',         -- a range id from Config.Arenas
    Weapon = 'schofield',         -- a weapon id from Config.Weapons
    Mode = 'bo3',
    Settings = { rounds = 3, targetType = 'bottles', targetCount = 10, distance = 15 },
    Currency = 'money',
    EntryFee = 20,
    Commission = 5,               -- %
    Slots = 8,                    -- at most 8
    Payouts = { 0.6, 0.25, 0.075, 0.075 }, -- 1st, 2nd, losing semifinalists
    SignupSeconds = 1800,
    MinPlayers = 4,
    NoShowSeconds = 180,
    RestartSeconds = 120,
}
```

| Setting                | What it does                                                                                     |
| ---------------------- | ------------------------------------------------------------------------------------------------ |
| `Enabled`              | `false` closes sign ups.                                                                         |
| `Arena`                | The range every tournament match is played at.                                                   |
| `Weapon`               | The supplied weapon for every match.                                                             |
| `Mode`, `Settings`     | The match format: mode, rounds, target type, target count and distance in yards.                 |
| `Currency`, `EntryFee` | What it costs to enter.                                                                          |
| `Commission`           | The percentage the range keeps from the pool.                                                    |
| `Slots`                | Maximum entrants, up to 8.                                                                       |
| `Payouts`              | Share of the pool for 1st, 2nd and the two losing semifinalists. Keep the total at 1.0 or below. |
| `SignupSeconds`        | How long sign ups stay open.                                                                     |
| `MinPlayers`           | Entrants needed for the draw when the time runs out.                                             |
| `NoShowSeconds`        | Time to check in before a walkover.                                                              |
| `RestartSeconds`       | How long after the final a new tournament opens.                                                 |

The tournament's name is in the language file as `data.tournament.name` (default "Blackwater Autumn Shootout").

## Admin controls

| Command                | What it does                                                                                                               |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `/shootingadmin draw`  | Draw the bracket now.                                                                                                      |
| `/shootingadmin reset` | Cancel the tournament, stop any match in progress, refund every entry fee if there is no champion yet, and open a new one. |

{% hint style="warning" %}
The bracket lives in server memory. Restarting the resource ends the current tournament. Every entry fee still held is refunded automatically the next time each player loads a character.
{% endhint %}
