> 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-advanced-gang/configuration/ranks.md).

# Ranks and permissions

Configure the default ranks of CAS Advanced Gang System: rank fields, permission keys, daily allowances and changing or renaming ranks later.

`Config.Ranks` is the **default** ladder. Each new gang gets its own copy, and its leaders change permissions and limits in the ledger.

{% code title="config.lua" %}

```lua
Config.Ranks = {
  { id = 'leader', name = 'Leader', order = 1, stashDaily = 0, treasuryCeiling = 0,
    permissions = { invite = true, kick = true, promote = true, stashDeposit = true, stashWithdraw = true,
                    treasuryView = true, treasuryWithdraw = true, upgradeBuy = true, place = true, disband = true } },
  -- right_hand, enforcer, rider, recruit
}
```

{% endcode %}

## Rank fields

| Field             | Meaning                                                                        |
| ----------------- | ------------------------------------------------------------------------------ |
| `id`              | Stored with every member. Keep it stable on a live server (see below).         |
| `name`            | Shown in the ledger and in messages. Write it in your server's language.       |
| `order`           | `1` is the top. Members only manage ranks with a higher number than their own. |
| `stashDaily`      | Items a member may **take** from the stash per day. `0` = no limit.            |
| `treasuryCeiling` | Money a member may **draw** from the treasury per day. `0` = no limit.         |
| `permissions`     | The switches below.                                                            |

## Permission keys

| Key                | Allows                                                                                                     |
| ------------------ | ---------------------------------------------------------------------------------------------------------- |
| `invite`           | Sending and revoking invitations                                                                           |
| `kick`             | Removing riders of a lower rank                                                                            |
| `promote`          | Changing riders' ranks, and editing lower ranks' permissions and limits                                    |
| `stashDeposit`     | Laying goods into the wagon                                                                                |
| `stashWithdraw`    | Taking goods out of the wagon                                                                              |
| `treasuryView`     | Opening the Ledger tab                                                                                     |
| `treasuryWithdraw` | Drawing money out                                                                                          |
| `upgradeBuy`       | Buying the next tier                                                                                       |
| `place`            | Placing, moving and taking down structures                                                                 |
| `disband`          | Disbanding the gang and answering treasury requests. Stays with the top rank and can't be granted in game. |

The top rank's `permissions` define which keys exist. A key it doesn't list can't be granted.

## Allowances are capped

A rank can't give a lower rank a wider allowance than its own. If a Right Hand with a $500 ceiling sets Recruits to "no limit", the server stores $500. Permissions work the same way: you can't grant one your own rank lacks.

## Changing the defaults later

* **New gangs** get the new defaults.
* A rank you **add** is given to existing gangs on the next start.
* Existing gangs **keep** their copy of a rank's name, order, permissions and limits.

## Removing or renaming a rank

Members store the rank's `id`. If you remove a rank or change its `id`, members on the old id move to the **nearest remaining rank by order** when the server starts. One console line is printed per member moved, and the move is saved.

To rename a rank safely, change its `name` and keep its `id`.

## Other settings

```lua
Config.DefaultRank   = 'recruit'  -- the rank new members join on; must be an id above
Config.InviteHours   = 48         -- hours an invitation stays open; 0 = until answered or revoked
Config.ApprovalQueue = true       -- draws past the ceiling become requests; false = refused
Config.OnKick        = 'forfeit'  -- 'forfeit' or 'refund'
```

A `'refund'` only reaches a rider who is on the server, and only while the camp owes no upkeep. See [Members and ranks](/script-documentation/cas-advanced-gang/playing/members.md#kicking).
