> 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-roulette/money.md).

# Money and safety

How CAS Advanced Roulette System keeps every bet safe on VORP and RSG: server-run rounds, chips on record per character, disconnects, crashes, restarts, limits and logs.

[Back to the guide](/script-documentation/cas-roulette/cas-advanced-roulette-system.md)

The server runs every round. It draws the number, checks every bet against the limits, takes the money and pays it out. A player's game only shows what the server decided.

## When money moves

* A chip is taken from your cash at the moment it lands on the felt (VORP `removeCurrency`, RSG `RemoveMoney`). The bridge checks that the cash really went down by that amount. If the bank refuses, nothing is placed.
* A stack you take back during betting is paid back at once.
* Winnings are paid at the end of the round: your stake plus the payout.

## Nothing is lost

* Everything on the felt is on record per character in the resource's own storage (`roulette:acct:<character>`). Winnings, stacks you take back and refunds go through "owed" and are paid at once while you are online.
* **Disconnect or crash before "No more bets":** your stacks come back to you as money owed.
* **Disconnect or crash after "No more bets":** the round is played out without you and the result is owed to you.
* Owed money is paid the next time your character is selected, or when you come to a table.
* **Resource restart or stop during a round:** the round is called off and every bet is refunded.
* **Server crash:** on the next start every stake still on record is called off and owed.
* A payment cut off by a crash is never paid twice. It is listed as "unconfirmed" for an admin to check and resolve (`/roulette_owed`, see [Commands](/script-documentation/cas-roulette/commands.md)).
* The server draws the winning number when bets close, from a random pool that only the server can see. Nothing players receive gives the next number away.
* Every money movement is written to the server console as a `[money]` line. With `Config.Webhook` on, the same lines also go to a Discord channel (see [Configuration](/script-documentation/cas-roulette/configuration.md#discord-webhook-log)).

## Limits and abuse

* Every table has four limits: the smallest chip, the most on one inside spot, the most on one outside spot and the most per player per round. A table in `config/tables.lua` can set its own.
* A player may cover at most `Config.MaxSpotsPerPlayer` spots in a round (30 by default).
* The server ignores a player who sends more than `Config.ActionsPerSecond` chip actions a second (8 by default).
* With OneSync the server refuses a join from farther than `Config.JoinCheckDistance` (4 m) from the table.
* A player who stands up after "No more bets" can join another table only once that round is paid ("Your chips are still in play at another table").
