> 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/vip-shop/configuration/redeem-codes.md).

# Redeem Codes

Players enter codes through the Redeem Code button at the bottom of the sidebar. Codes grant coins.

## Rules enforced

* Codes are case insensitive and stored uppercase.
* Usage cap: `max_uses = 0` means unlimited; otherwise the counter is enforced safely under concurrency.
* Expiry: an optional datetime; expired codes are rejected.
* One per player: a wallet can redeem a given code exactly once, enforced by the database.

## Seeding from config

```lua
Config.SeedCodes = {
    { code = 'OUTLAW',  coins = 250, maxUses = 100, expiresAt = nil },
    { code = 'WELCOME', coins = 100, maxUses = 0,   expiresAt = '2026-12-31 23:59:59' },
}
```

Seeds are inserted with `INSERT IGNORE` on every boot. Existing codes, and their live usage counters, are never touched.

## Creating codes at runtime

```
vipshop_createcode <CODE> <coins> <maxUses>
```

Console or the `vipshop.admin` ace. `maxUses = 0` means unlimited. Codes created this way have no expiry; add one directly in the `vipshop_codes` table if needed.

## Player feedback

Every outcome has a localized toast: success (with coins and a live balance update), invalid code, expired, usage cap reached, and already redeemed.
