> For the complete documentation index, see [llms.txt](https://realisticnode.gitbook.io/rnsetups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://realisticnode.gitbook.io/rnsetups/rncasino/guides/money-safety.md).

# Money safety

How money is taken and paid, and what happens to bets when a round is cancelled, the server stops or crashes.

## Taking and paying

* **Money is taken when the chip goes down**, and the bet counts only after the plugin checked that the payment worked. A failed payment changes nothing.
* Amounts must be positive and real numbers. Points tables only take whole points.
* Every click checks the round again: a chip that arrives after "No more bets" is refused, even if the click was late.
* **A round is paid once.** Each winner is paid on their own: a problem with one player's payment never stops the others.

## Cancelled rounds

`/casino cancel <table>` (or removing the table) gives every bet of the round back at once. Chips taken back before the bets close also give the money back.

## Server stops and crashes

Every bet of a round being played is also written to `data/open-bets.yml`.

* If the server **stops or crashes** during a round, the bets are given back when it **starts again**. The console shows one line per player:

```
[rnCasino] Gave back 1500.0 (vault) to Steve: the server stopped during a round at table main.
```

* If a payment fails (for example the economy plugin is not ready), the money is kept as owed and paid when the server starts again.
* A round that was already paid is never given back or paid again.

{% hint style="info" %}
Players don't need to be online to get their money back: it goes to their account.
{% endhint %}

## Records

* Each player's stats (rounds, wins, bet, got back, profit, biggest win, today) are kept per currency in `data/casino.db` (SQLite) or MySQL.
* Each round is kept in `rncasino_rounds` with its number, seed and code, so it can be checked later (`keep-rounds`, 50,000 by default).
* `storage.log-bets: true` also saves every single bet in `rncasino_bets`, for your own statistics.
* If the database can't be read for a player, their stats are not overwritten.
