> For the complete documentation index, see [llms.txt](https://0bugscripts.gitbook.io/0bugscripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0bugscripts.gitbook.io/0bugscripts/battlepass/configuration.md).

# Configuration

Configure the 0Bug FiveM battlepass: XP, levels, season length, daily reset, admin commands, server exports, missions, daily quiz, lucky spin and rewards.

### Main settings

`0bug_Battlepass/Customize.lua`:

```lua
Customize = {
    Lang = "en", -- en, de, fr, es, pt (Brazilian), it, nl, pl, tr
    ItemImagePath = "nui://qb-inventory/html/images/", -- your inventory's image folder
    Tebex_Credit_Readme_Code_Command = "purchase_credit",
    Tebex_Premium_Readme_Code_Command = "purchase_premium",
    Profile_Avatar = "" -- one picture for every player (empty: their Discord or Steam avatar)
}
```

Set `ItemImagePath` to your inventory, for example `nui://ox_inventory/web/images/`.

### XP and levels

```lua
UI_Settings = {
    Open_Buy_More_Credits_Web_Site = "https://your-store.tebex.io/",
    Buy_Level_Price = 5,
    Buy_Level_Price_Type = "credit", -- "credit", "cash" or "bank"
    Total_XP = 500,           -- XP needed per level
    Daily_Quiz_Award = "1000", -- XP for a correct quiz answer
    Daily_Get_Spin_Credit = 1, -- credits for an extra spin
    Max_Level = 30            -- the most levels the Buy Levels slider offers
}
```

### Season and resets

```lua
Data_Settings = {
    endingTime = 30,           -- season length in days
    dailySpin = true,
    restartDailyDataHours = 0, -- hour of the day (0-23) when daily missions reset
    restartWeeklyDays = 7      -- weekly missions reset every 7 days
}
```

> `restartDailyDataHours` is a number from 0 to 23, not a time like "00:00".

### Admin commands

```lua
Command = {
    Open_Menu = "openMenu",
    Add_Level = "addLevel",
    Remove_Level = "removeLevel",
    Add_XP = "addXP",
    Set_Premium = "setPremium",
    Clear_Player_Data = "refreshPlayerData",
    Clear_Players_Data = "allRefreshPlayersData",   -- server console only
    Clear_Script_Data = "refreshScriptData",        -- server console only
    Clear_Daily_Data = "refreshDailyData",          -- server console only
    Clear_Weekly_Data = "refreshWeeklyData",        -- server console only
    Add_Credit = "addCredit",
    Remove_Credit = "removeCredit",
    Get_Credit = "getCredit",
}
```

Commands take the player's **identifier**:

* **QBCore / Qbox**: the character's citizenid, e.g. `/addXP EAX123EE 10`
* **ESX**: the character's ESX identifier

You can see which identifier the battlepass uses for each player in `data/player.json`.

### Server exports

```lua
exports['0bug_Battlepass']:addLevel(identifier, 1)
exports['0bug_Battlepass']:removeLevel(identifier, 1)
exports['0bug_Battlepass']:addXP(identifier, 500)          -- levels up when XP passes the max
exports['0bug_Battlepass']:setPremium(identifier, true)
exports['0bug_Battlepass']:addCredit(identifier, 100)
exports['0bug_Battlepass']:removeCredit(identifier, 50)
local credit = exports['0bug_Battlepass']:getCredit(identifier)
local data = exports['0bug_Battlepass']:getPlayerData(identifier)
exports['0bug_Battlepass']:clearPlayerData(identifier)
exports['0bug_Battlepass']:clearPlayersData()   -- every player
exports['0bug_Battlepass']:clearScriptData()    -- missions, spins, quizzes
exports['0bug_Battlepass']:clearDailyData()     -- daily missions, spins, quizzes only
exports['0bug_Battlepass']:clearWeeklyData()    -- weekly missions only
```

Getting the identifier:

```lua
-- QBCore
local identifier = QBCore.Functions.GetPlayer(source).PlayerData.citizenid

-- Qbox
local identifier = exports.qbx_core:GetPlayer(source).PlayerData.citizenid

-- ESX
local identifier = ESX.GetPlayerFromId(source).identifier
```

### Missions, quiz and rewards

All in `0bug_Battlepass/config/`:

| File                     | What's in it         |
| ------------------------ | -------------------- |
| `dailyMissionsList.json` | Daily missions       |
| `weeklyMissions.json`    | Weekly missions      |
| `dailyQuizList.json`     | Daily quiz questions |
| `dailySpinList.json`     | Lucky spin rewards   |
| `freeProducts.json`      | Free reward track    |
| `premiumProducts.json`   | Premium reward track |

#### Missions

```json
{
    "title": "Buy Something from the Store",
    "description": "Visit a store and purchase any item.",
    "value": 1,
    "totalValue": 3,
    "trigger": "0bug-Battlepass:BuyFromStore",
    "triggerAddXP": 50
}
```

* `totalValue`: how many times the player has to do it
* `trigger`: the event that counts one completion
* `triggerAddXP`: XP for completing the mission

Add more numbered sets (`"2"`, `"3"`…) and the battlepass picks a different set each day.

Then fire the mission's event from the script where the action happens:

```lua
-- server side (e.g. when a player eats)
TriggerClientEvent('0bug-Battlepass:EatFood', source)

-- client side (e.g. when a player drinks)
TriggerEvent('0bug-Battlepass:DrinkWater')
```

#### Daily quiz

```json
"1": {
    "question": "Which establishment allows players to modify their vehicles?",
    "answers": [
        { "title": "Auto Tune Garage", "correct": false },
        { "title": "Speedy Custom Shop", "correct": true }
    ]
}
```

#### Rewards

```json
{ "id": 1, "type": "item", "title": "Sandwich", "name": "sandwich", "amount": 5 },
{ "id": 2, "type": "cash", "title": "Cash Reward", "name": "cash", "amount": 1000 },
{ "id": 3, "type": "car", "title": "BMX", "name": "bmx", "customImage": "bmx.png", "amount": 1 }
```

* `type`: `item`, `illegalItem`, `cash`, `car` or `xp`
* `name`: the item, vehicle or money name on your server (it must work with `/giveitem` or your car spawner)
* `customImage` (optional): an image in `0bug_Battlepass/resources/image/`

Vehicles are saved with the `Vehicles` settings of [0bug-core](https://0bugscripts.gitbook.io/0bugscripts/0bug-core/settings).

#### Lucky spin

Same as rewards, plus `probability` (the chance out of 100):

```json
{ "id": 1, "type": "item", "title": "Lockpick", "name": "lockpick", "probability": 3, "amount": 5 }
```
