# QBox Setup

### ✅ Requirements

* qbx\_core (latest version)
* ox\_lib
* oxmysql
* A compatible inventory (ox\_inventory recommended)
* A compatible clothing script

***

### 🚀 Quick Setup

QBox is designed to work seamlessly with modern resources. Setup is minimal.

#### Step 1: Disable Default Multicharacter

```cfg
# server.cfg
# ensure qbx_multicharacter  <-- Comment out or remove
ensure 0r-multicharacterv3
```

#### Step 2: Start Order

```cfg
ensure oxmysql
ensure ox_lib
ensure qbx_core
ensure ox_inventory
ensure bl_appearance
ensure 0r-multicharacterv3
```

***

### 🗄️ Database

QBox uses the same `players` table structure as QBCore:

| Column    | Usage                        |
| --------- | ---------------------------- |
| citizenid | Unique character identifier  |
| cid       | Character slot number        |
| license   | Player identifier (license2) |
| charinfo  | Character information (JSON) |
| job       | Job data (JSON)              |
| money     | Money data (JSON)            |
| position  | Last position (JSON)         |

{% hint style="info" %}
QBox uses `license2` instead of `license` for player identification.
{% endhint %}

***

### 🔧 Framework Functions

The script uses QBox exports:

```lua
-- Login
exports.qbx_core:Login(source, citizenid, newData)

-- Get Player
exports.qbx_core:GetPlayer(source)

-- Logout
exports.qbx_core:Logout(source)
```

***

### 🏠 Spawn Integration

#### qbx\_spawn

If using qbx\_spawn:

```lua
Config.SpawnSelector = 'qbx_spawn'
```

This triggers:

```lua
TriggerClientEvent('qb-spawn:client:setupSpawns', playerId)
```

***

### ⚡ Events

#### Server Events

QBox uses the same events as QBCore:

```lua
-- When player loads character
AddEventHandler('QBCore:Server:PlayerLoaded', function(Player)
    -- Works with QBox
end)

-- When player unloads
AddEventHandler('QBCore:Server:OnPlayerUnload', function(src)
    -- Works with QBox
end)
```

***

### 🔄 Character Deletion

Configure in `config/database.lua`:

```lua
Database.List = {
    ['qbx_core'] = {
        { table = 'players', column = 'citizenid', type = 'citizenid' },
        { table = 'playerskins', column = 'citizenid', type = 'citizenid' },
        { table = 'player_vehicles', column = 'citizenid', type = 'citizenid' },
        -- Add more tables as needed
    }
}
```

***

### 📋 Complete Configuration

```lua
-- config/config.lua for QBox

Config.Debug = false
Config.DeveloperMode = false
Config.Locale = 'en'
Config.HideRadar = true
Config.DefaultCharacterSlots = 2
Config.SkipWarning = false
Config.DisableDeleteCharacter = false

-- Use built-in spawn or qbx_spawn
Config.SkipSpawnSelector = false
Config.SpawnSelector = 'qbx_spawn'  -- or '0r-spawn'
Config.ApartmentStart = false
```

***

### 🆚 QBCore vs QBox Differences

| Feature    | QBCore   | QBox       |
| ---------- | -------- | ---------- |
| Player ID  | license  | license2   |
| Exports    | qb-core  | qbx\_core  |
| Spawn      | qb-spawn | qbx\_spawn |
| Modern Lua | No       | Yes        |

***

### ❓ Troubleshooting

#### "Player not found" error

QBox uses `license2`:

1. Verify player has Steam/license2
2. Check database for correct identifier

#### Commands not refreshing

QBox handles commands differently. The `RefreshCommand` function is empty for QBox as it's not needed.

#### Compatibility with QBCore resources

Many QBCore resources work with QBox. The script triggers the same events:

* `QBCore:Server:OnPlayerLoaded`
* `QBCore:Client:OnPlayerLoaded`
