# Configuration

### 1️⃣ Customize the BattlePass Settings

Navigate to:\
📂 `resources/0bug_Battlepass/Customize.lua`

Modify the settings as needed:

```lua
Customize = {
    Lang = "en", -- Set language
    ItemImagePath = "nui://qb-inventory/html/images/", -- Path for inventory images
    Tebex_Credit_Readme_Code_Command = "purchase_credit", -- Command for purchasing credits
    Tebex_Premium_Readme_Code_Command = "purchase_premium" -- Command for purchasing premium pass
}
```

📌 **Tip:** Set <mark style="color:red;">ItemImagePath</mark> to match your inventory system (qb-inventory, ox\_inventory, etc.).

### 2️⃣ UI & XP Settings

Configure UI and XP settings inside `Customize.lua`:

```lua
UI_Settings = {
    Open_Buy_More_Credits_Web_Site = "https://0bugscripts.tebex.io/", -- Tebex store link
    Buy_Level_Price = 5, -- Price per level
    Buy_Level_Price_Type = "credit",  -- Options: "credit", "cash", "bank"
    Total_XP = 500, -- XP required to complete the BattlePass
    Daily_Quiz_Award = "1000", -- XP reward for correct quiz answers
    Daily_Get_Spin_Credit = 1 -- Credits needed for extra spins
}
```

### 3️⃣ BattlePass Commands

Here are the available commands you can modify:

```lua
Command = {
    Open_Menu = "openMenu", -- Opens the BattlePass UI
    Add_Level = "addLevel", -- Add levels to a player
    Remove_Level = "removeLevel", -- Remove levels
    Add_XP = "addXP", -- Grant XP manually
    Set_Premium = "setPremium", -- Activate Premium for a player
    Clear_Player_Data = "refreshPlayerData", -- Reset a single player’s data
    Clear_Players_Data = "allRefreshPlayersData", -- Reset all players’ data
    Clear_Script_Data = "refreshScriptData" -- Reset entire BattlePass script data
    Clear_Daily_Data = "clearDailyData", -- Reset daily missions
    Clear_Weekly_Data = "clearWeeklyData", -- Reset weekly missions
    Add_Credit = "addCredit", -- Add credit to a player
    Remove_Credit = "removeCredit", -- Remove credit
    Get_Credit = "getCredit", -- Get credit
}
```

{% hint style="info" %}
Commands like **clearDailyData** should be directly used from txadmin - Server side console.
{% endhint %}

<figure><img src="/files/MCbwlX8muCvzvyolTzHa" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
How to use the commands for each framework :&#x20;
{% endhint %}

When it comes to <mark style="color:blue;">**ESX**</mark><mark style="color:blue;">,</mark> you need to use the player's **license identifier**, and make sure you remove the `license:` part but for <mark style="color:red;">**QBCore**</mark>**/**<mark style="color:yellow;">**QBox**</mark> you need to use the player's **CitizenID** .\
\
You can verify what identifier the script is considering for the player under the data/player.json file

```lua
/addXP a8f50ba88b40bb1677dbd2baaa7af12c68a057ed 10 -- ESX

/addXP EAX123EE 10 -- QBCore or QBox
```

### 4️⃣ Season & Daily Spin Settings

Manage **BattlePass duration, daily resets, and spins** in `Customize.lua`:

```lua
Data_Settings = {
    endingTime = 30, -- BattlePass season duration (days)
    dailySpin = true, -- Enable or disable daily spin
    restartDailyDataHours = "00:00", -- Time to reset daily missions
    restartWeeklyDays = 7 -- Weekly mission reset interval (days)
}
```

### 5️⃣ BattlePass Server Exports&#x20;

{% hint style="info" %}
:bulb: Getting Player Identifier
{% endhint %}

Before using these exports, you need to get the player's identifier for ESX and the player CitizenID for QBCore.

#### **Example:**

{% hint style="info" %}
ESX&#x20;
{% endhint %}

```lua
local playerId = source  -- Gets the player's server ID
local identifier = GetPlayerIdentifier(playerId, 0):gsub('license:', '') -- Retrieves the player's unique identifier
```

{% hint style="danger" %}
QBCore
{% endhint %}

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

### 🎮 Player Data Functions

#### 🔹 **addLevel(identifier, amount)**

Increases a player's level by a given amount.

**Usage:**

```lua
exports['0bug_Battlepass']:addLevel(identifier, 1)
```

***

#### 🔹 **removeLevel(identifier, amount)**

Decreases a player's level by a given amount.

**Usage:**

```lua
exports['0bug_Battlepass']:removeLevel(identifier, 1)
```

***

#### 🔹 **addXP(identifier, amount)**

Adds XP to a player. If XP exceeds the max, it levels up the player.

**Usage:**

```lua
exports['0bug_Battlepass']:addXP(identifier, 500)
```

***

#### 🔹 **setPremium(identifier, value)**

Sets a player's premium status (`true` or `false`).

**Usage:**

```lua
exports['0bug_Battlepass']:setPremium(identifier, true)
```

***

### 💰 Credit Functions

#### 🔹 **addCredit(identifier, amount)**

Adds credits to a player.

**Usage:**

```lua
exports['0bug_Battlepass']:addCredit(identifier, 100)
```

***

#### 🔹 **removeCredit(identifier, amount)**

Removes credits from a player.

**Usage:**

```lua
exports['0bug_Battlepass']:removeCredit(identifier, 50)
```

***

#### 🔹 **getCredit(identifier)**

Returns the player's current credit balance.

**Usage:**

```lua
local credit = exports['0bug_Battlepass']:getCredit(identifier)
print("Player Credit:", credit)
```

***

### 🔄 Data Management Functions

#### 🔹 **clearPlayerData(identifier)**

Clears all stored data for a specific player.

**Usage:**

```lua
exports['0bug_Battlepass']:clearPlayerData(identifier)
```

***

#### 🔹 **clearPlayersData()**

Clears **all** players' data.

**Usage:**

```lua
exports['0bug_Battlepass']:clearPlayersData()
```

***

#### 🔹 **clearScriptData()**

Resets **all script-wide BattlePass data**, including daily missions, spins, quizzes, and weekly missions.&#x20;

**Usage:**

```lua
exports['0bug_Battlepass']:clearScriptData()
```

***

#### 🔹 clearDailyDat&#x61;**()**

Resets **only the daily script data** such as daily missions, spins, quizzes, and tracked daily hours. Weekly data and reward codes remain untouched.

**Usage:**

```lua
exports['0bug_Battlepass']:clearDailyData()
```

***

#### 🔹 clearWeeklyDat&#x61;**()**&#x20;

Resets **only the weekly script data**, including weekly missions and weekly date tracker. Daily data and reward codes remain unchanged.

**Usage :**

```lua
exports['0bug_Battlepass']:clearWeeklyData()
```

***

### 📌 Notes

* **Use `GetPlayerIdentifier(source, 0)`** to get the player's unique identifier.
* **Make sure** `0bug_Battlepass` is started before using these exports.

## 🎯 Configuring Missions, Quiz, & Rewards

### ✅ Editing Missions & Rewards

Navigate to:\
📂 `resources/0bug_Battlepass/config/`

This folder contains **JSON files** for:

* `dailyMissionsList.json` (Daily missions)
* `weeklyMissions.json` (Weekly missions)
* `dailyQuizList.json` (Daily quiz)
* `dailySpinList.json` (Spin rewards)
* `freeProducts.json` (Free rewards)
* `premiumProducts.json` (Premium rewards)

### 📝 Adding a Daily or Weekly Mission

To have variety missions, add more numbered tables ("2", "3", etc.) with different missions. \
The system will then randomly pick one set each day.

<figure><img src="/files/kDiyi5njXKZJ8ELurrcR" alt=""><figcaption></figcaption></figure>

If you want different possible sets of daily missions (so each day could have a different group), you should add more tables with keys like "2", "3", etc., each containing a different set of 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
}

```

🔹 **How it works:**

* `title`: Name of the mission.
* `description`: What players need to do.
* `totalValue`: How many times they must complete it.
* `trigger`: The event that grants XP when triggered.
* `triggerAddXP`: How much XP players earn for completing it.<br>

{% hint style="info" %}
How to implement the Mission in Other Scripts!
{% endhint %}

When adding support for **daily and weekly missions**, we need to ensure that both the **client-side** and **server-side** events are properly triggered.

> **🔄 Server-Side Integration**

To make the mission work, add the event you did set in the config **inside another script** (e.g., when a player eats :hamburger:) :

```lua
RegisterNetEvent('consumables:server:addHunger', function(amount)
    local Player = QBCore.Functions.GetPlayer(source)
    if not Player then return end
    Player.Functions.SetMetaData('hunger', amount)
    TriggerClientEvent('hud:client:UpdateNeeds', source, amount, Player.PlayerData.metadata.thirst)  
    TriggerClientEvent('0bug-Battlepass:EatFood', source)  -- 🔹 This triggers XP for the BattlePass
end)

```

> 📌 **Client-Side Integration**

📂 **Modify your client-side script (e.g., `consumables.lua`) to add XP when a player drinks** 💧

```lua
RegisterNetEvent('consumables:client:Drink', function(itemName)
    QBCore.Functions.Progressbar('drink_something', Lang:t('consumables.drink_progress'), 5000, false, true, {
        disableMovement = false,
        disableCarMovement = false,
        disableMouse = false,
        disableCombat = true
    }, {
        animDict = 'mp_player_intdrink',
        anim = 'loop_bottle',
        flags = 49
    }, {
        model = 'vw_prop_casino_water_bottle_01a',
        bone = 60309,
        coords = vec3(0.0, 0.0, -0.05),
        rotation = vec3(0.0, 0.0, -40),
    }, {}, function() -- Done
        -- Remove the item from inventory
        TriggerEvent('qb-inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'remove')

        -- Update thirst level
        TriggerServerEvent('consumables:server:addThirst', QBCore.Functions.GetPlayerData().metadata.thirst + Config.Consumables.drink[itemName])

        -- 🔹 Add BattlePass XP by triggering the mission event
        TriggerEvent('0bug-Battlepass:DrinkWater') -- Client-side event
    end)
end)

```

### 📚 Setting Up Daily Quiz Questions

Daily quiz questions are stored in:\
📂 `resources/0bug_Battlepass/config/dailyQuizList.json`

Each question follows this structure:

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

```

#### **🔹 Explanation**

* `"1"`: Unique identifier for each quiz question.
* `"question"`: The question players will see.
* `"answers"`: A list of possible answers.
  * `"title"`: The answer text.
  * `"correct"`: **Set to `true` for the correct answer**, all others should be `false`.

### 🎁 Setting Up Free & Premium Rewards

BattlePass rewards are stored in:\
📂 `resources/0bug_Battlepass/config/freeProducts.json` *(for free rewards)*\
📂 `resources/0bug_Battlepass/config/premiumProducts.json` *(for premium rewards)*

Each reward follows this structure:

```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
},
{
    "id": 4,
    "type": "item",
    "title": "Lockpick",
    "name": "lockpick",
    "amount": 5
},
{
    "id": 5,
    "type": "xp",
    "title": "XP Reward",
    "name": "xp",
    "amount": 50
}

```

#### **🔹 Explanation**

* `"id"`: Unique identifier for the reward.
* `"type"`: Defines the type of reward.
* `"title"`: The display name for the reward.
* `"name"`: The **database identifier** of the item, vehicle, or currency.
* `"amount"`: The quantity of the reward.
* `"customImage"` *(optional)*: If you add a custom image, **place the image in**:\
  📂 `resources/0bug_Battlepass/resources/image/`

{% hint style="info" %}
You can define the type with 5 different options :&#x20;
{% endhint %}

* `"item"` → A regular inventory item.
* `"illegalItem"` → An illegal item.
* `"cash"` → In-game money.
* `"car"` → A vehicle reward.
* `"xp"` → Experience points.

### 🎡 Setting Up Daily Spin Rewards

Daily Spin rewards are stored in:\
📂 `resources/0bug_Battlepass/config/dailySpinList.json`

Each reward follows this structure:

```json
"1": [
    {
        "id": 1,
        "type": "item",
        "title": "Lockpick",
        "name": "lockpick",
        "probability": 3,
        "amount": 5
    },
    {
        "id": 2,
        "type": "cash",
        "title": "Cash Reward",
        "name": "cash",
        "probability": 5,
        "amount": 1000
    },
    {
        "id": 3,
        "type": "car",
        "title": "BMX",
        "name": "bmx",
        "customImage": "bmx.png",
        "probability": 2,
        "amount": 1
    }
]
```

#### **🔹 Explanation**

* `"id"`: Unique identifier for the reward.
* `"type"`: Defines the type of reward. Options:
  * `"item"` → A regular inventory item.
  * `"illegalItem"` → An illegal item.
  * `"cash"` → In-game money.
  * `"car"` → A vehicle reward.
  * `"xp"` → Experience points.
* `"title"`: Name of the reward displayed in the UI.
* `"name"`: The item, cash, or car identifier used in the database.
* `"probability"`: Chance (out of 100) to get this reward.
* `"amount"`: The quantity of the reward.
* `"customImage"` *(optional)*: If you add a custom image, **place the image in**:\
  📂 `resources/0bug_Battlepass/resources/image/`


---

# 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://0bugscripts.gitbook.io/0bugscripts/infinity-scripts/battlepass/configuration.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.
