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

# Gameplay

Starting a game, controls, the referee, wagers and rankings.

## Starting a game

Walk to the middle of a court and open the squash panel: the "Play squash" target option, or E where the marker is.

* **Match**: start a match and wait for an opponent, with or without a stake.
* **Practice**: play alone, feed yourself and keep the rally going. The longest rally is saved.
* **Accept**: if somebody is already waiting on that court, the panel shows their challenge instead: who it is, their rating and the stake. Accept takes exactly the challenge on screen.

While you wait you can stand next to the court, but a challenge is only accepted while you stand on it. If somebody tries while you are off it, you are told to come back and they are asked to try again. Walking more than 15 m away cancels your lobby.

A match is played point-a-rally to 11, win by two, as a single game or best of three or five (`Config.Match`). The winner of a rally serves next.

## Controls

| Control                | Default                 | Notes                                                |
| ---------------------- | ----------------------- | ---------------------------------------------------- |
| Hard shot              | Left mouse              | Aim with the camera.                                 |
| Touch shot (drop, lob) | Right mouse             | The aim height sets the length.                      |
| Appeal for a let       | E                       | In matches, on your own ball.                        |
| Leave the court        | Backspace, held for 1 s | Cancels your lobby, ends practice, forfeits a match. |

Players can rebind all of them in the GTA settings (Key Bindings, FiveM). The buttons in the bottom right corner always show the keys a player has bound.

{% hint style="warning" %}
Known issue in 1.0.0: holding the touch-shot key (right mouse by default) can switch the camera to the game's aim view. A short press plays the shot normally. See the [Changelog](/docs/scripts/squash/changelog.md).
{% endhint %}

**Serving**: stand in a service box, press a shot key to start the power meter and press again to stop it. The sweet spot gives the best serve, and the key you pressed first decides hard or touch. In a match you change boxes while you keep the serve.

**Returning**: press as the ball comes into reach. The closer it is to the middle of your racket and the better the timing, the harder and straighter it goes.

**Leaving**: the leave key has to be held. A bar on the HUD fills meanwhile, and letting go before it is full changes nothing. The button in the corner says what it does at that moment: cancel, end practice or forfeit.

## Forfeits

In a match, each of these gives the win to the opponent:

* holding the leave key, or `/squashleave`
* disconnecting, or going back to the character list
* staying off the court for longer than `Config.Match.outsideGrace` (5 s, with a warning as soon as you step off)

## The referee

Every rally is decided by the server. It follows the same ball as every player and knows where both players stand, so it also rules on interference, by the World Squash rules:

| Situation                                                                                                    | Ruling                                                                            |
| ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| You appeal, and the opponent is in your swing or between the ball and the front wall                         | **Stroke**: your point.                                                           |
| You appeal, and the opponent is in your way to the ball                                                      | **Let**: the rally is replayed.                                                   |
| You appeal, and nobody is in the way or the ball is out of reach                                             | **No let**: the opponent's point.                                                 |
| You appeal after taking a detour, and meet the opponent only on it                                           | **No let**: you caused the interference yourself.                                 |
| Your shot hits the opponent on its way straight to the front wall                                            | **Stroke**: your point.                                                           |
| Your shot hits the opponent on its way to the front wall via another wall                                    | **Let**.                                                                          |
| The ball hits a player in any other case                                                                     | The player who was hit loses the rally.                                           |
| You turn (play the ball on the other side of your body from where it passed behind you) and hit the opponent | The opponent's point. An opponent in front of the ball then only earns you a let. |

How strict the referee is can be tuned with `Config.Interference`, see [Configuration](/docs/scripts/squash/configuration.md).

{% hint style="warning" %}
Known issue in 1.0.0: the referee is strict on appeals. In our own two-player games most appeals were answered "no let", and a stroke was hardly ever given. A tuning pass is planned, see the [Changelog](/docs/scripts/squash/changelog.md).
{% endhint %}

## Spectators

Everybody near a court sees the same ball and the rackets.

* **At a court with a scoreboard in the world**, bystanders read the score there and get nothing on their screen.
* **At a court without one**, bystanders within `Config.Ui.spectateDistance` get its scoreboard and results on their screen while it is in play.

`Config.Ui.spectateWithBoard = true` puts the scoreboard on the screen of bystanders at every court, for example when a board hangs where the people watching cannot see it.

## Player commands

| Command        | What it does                                                                                                                  |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `/squashleave` | Leaves the court at once, like the leave key without the hold.                                                                |
| `/squashhud`   | Opens the HUD editor: drag the scoreboard, results, shot readout, serve meter and the bar of the leave key. Saved per player. |
| `/squashstats` | Opens the stats and ranking tabs anywhere.                                                                                    |

The admin commands are in [Courts & Scoreboards](/docs/scripts/squash/courts-and-scoreboards.md).

## Wagers

With a framework that keeps money, the player who starts a match may set a stake between `min` and `max` of `Config.Wager`.

* Nothing is taken while the lobby waits.
* When the challenge is accepted, both players pay the stake at once. If either cannot cover it, nobody pays and the player is told.
* The winner takes the pot less `fee`, also when the opponent forfeits, leaves or disconnects.
* A match that ends without a winner, and a restart of the resource, give the stakes back.

## Stats and rankings

Every match with a winner is rated, forfeits too. Each player has an Elo rating that starts at 1000. New players move faster: one match can change a rating by up to 48 points for the first 10 matches, 32 up to 50 matches and 16 after that (`Config.Stats.elo`).

Practice does not change the rating. It only records your longest rally.

The panel has a stats tab (rating, rank, matches, wins, win rate, longest rally) and a ranking tab with the top players by rating and by longest rally.

Rows are kept per character: under the ESX identifier, the QBCore or QBX citizenid, or the license when running standalone. A player without one (no character loaded) is not rated, and neither is a match between two connections of the same character.
