# Character Slotes

### 📊 Slot Calculation

A player's total slots are calculated as:

```
Total Slots = Default + Database + Discord + Custom License
```

| Source         | Description                                 |
| -------------- | ------------------------------------------- |
| Default        | `Config.DefaultCharacterSlots` value        |
| Database       | Slots stored in `0r_multicharacterv3` table |
| Discord        | Bonus slots from Discord roles              |
| Custom License | Bonus slots from specific license IDs       |

***

### 🔢 Default Slots

Set the base slot count for all players:

```lua
Config.DefaultCharacterSlots = 1  -- Everyone starts with 1 slot
```

***

### 🎮 Discord Role Slots

Grant bonus slots based on Discord roles:

```lua
Config.CharacterSlots = {
    Discord = {
        status = false,  -- Enable Discord slot system
        roles = {
            {
                id = 1234567890123456,  -- Discord Role ID
                slot = 1,               -- Bonus slots
            },
            {
                id = 9876543210987654,  -- VIP Role
                slot = 3,               -- +3 bonus slots
            },
        }
    },
    -- ...
}
```

#### Setup Requirements

1. Install a Discord bot/integration that provides role checking
2. Configure your Discord guild ID
3. Add role IDs and corresponding slot bonuses

#### How to Get Role IDs

1. Enable Developer Mode in Discord (Settings → Advanced)
2. Right-click the role → Copy ID

{% hint style="info" %}
Players receive slots from their **highest** applicable role, not cumulative.
{% endhint %}

***

### 💳 Tebex Integration

Sell character slots through your Tebex store:

```lua
Config.CharacterSlots = {
    Tebex = {
        status = false,  -- Enable Tebex integration
        packages = {
            {
                id = 1,      -- Tebex package ID
                slot = 1,    -- Slots to grant
            },
            {
                id = 2,      -- Premium package
                slot = 5,    -- +5 slots
            },
        }
    },
    -- ...
}
```

#### Tebex Setup

1. Create a package in your Tebex store
2. Note the package ID
3. Add it to the packages list
4. Configure Tebex API in `server/tebex.lua`

#### How Players Redeem

1. Player purchases package on Tebex
2. Tebex provides a redemption code
3. Player enters code in the character selection UI
4. Slots are added to their account

***

### 🔑 Custom License Slots

Grant slots to specific license identifiers (useful for staff/VIPs):

```lua
Config.CharacterSlots = {
    Custom = {
        status = false,  -- Enable custom license system
        licenses = {
            {
                id = 'license:abc123def456',  -- Full license identifier
                slot = 5,                      -- Bonus slots
            },
            {
                id = 'license:xyz789ghi012',  -- Another player
                slot = 10,                     -- Staff gets 10 extra
            },
        }
    },
}
```

#### How to Get License IDs

In-game, run:

```lua
print(GetPlayerIdentifierByType(source, 'license'))
```

Or check your database `players` table.

***

### 🎟️ Redeemable Codes

Create one-time use codes that grant slots:

#### Adding Codes via Database

```sql
INSERT INTO 0r_multicharacterv3_code (code, slot) VALUES 
('WELCOME2024', 1),
('VIPBONUS', 3),
('STREAMER5', 5);
```

#### Adding Codes via Command

Create a command in `server/commands.lua`:

```lua
lib.addCommand('addslotcode', {
    help = 'Add a slot redemption code',
    params = {
        { name = 'code', help = 'The code', type = 'string' },
        { name = 'slots', help = 'Number of slots', type = 'number' },
    },
    restricted = 'group.admin',
}, function(source, args)
    MySQL.insert('INSERT INTO 0r_multicharacterv3_code (code, slot) VALUES (?, ?)', {
        args.code, args.slots
    })
    print('Code created: ' .. args.code .. ' (' .. args.slots .. ' slots)')
end)
```

***

### 📋 Complete Configuration Example

```lua
Config.DefaultCharacterSlots = 2

Config.CharacterSlots = {
    -- Tebex Store Integration
    Tebex = {
        status = true,
        packages = {
            { id = 12345, slot = 1 },  -- Basic slot package
            { id = 12346, slot = 3 },  -- Premium package
            { id = 12347, slot = 5 },  -- Ultimate package
        }
    },
    
    -- Discord Role Rewards
    Discord = {
        status = true,
        roles = {
            { id = 1111111111111111, slot = 1 },  -- Supporter
            { id = 2222222222222222, slot = 2 },  -- VIP
            { id = 3333333333333333, slot = 5 },  -- MVP
            { id = 4444444444444444, slot = 10 }, -- Staff
        }
    },
    
    -- Manual License Assignments
    Custom = {
        status = true,
        licenses = {
            { id = 'license:owner123', slot = 99 },  -- Server owner
        }
    }
}
```

***

### ⚡ Admin Commands

Add slots directly to players via commands:

```lua
-- In server/commands.lua
lib.addCommand('addslots', {
    help = 'Add slots to a player',
    params = {
        { name = 'id', help = 'Player ID', type = 'playerId' },
        { name = 'amount', help = 'Slots to add', type = 'number' },
    },
    restricted = 'group.admin',
}, function(source, args)
    local identifier = GetPlayerIdentifierByType(args.id, 'license2')
    MySQL.update('UPDATE 0r_multicharacterv3 SET character_slot = character_slot + ? WHERE identifier = ?', {
        args.amount, identifier
    })
end)
```

***

### ❓ FAQ

**Q: Do Discord slots stack with Tebex slots?** A: Yes! All sources are additive.

**Q: What happens if a player has multiple Discord roles?** A: They receive slots from the role with the highest slot value.

**Q: Can slots be removed?** A: Yes, modify the database directly or create a remove command.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.0resmon.org/0resmon/0r-resources/0r-multicharacter-v3/configuration/character-slotes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
