⚙️Configuration

1️⃣ Customize the BattlePass Settings

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

Modify the settings as needed:

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 ItemImagePath to match your inventory system (qb-inventory, ox_inventory, etc.).

2️⃣ UI & XP Settings

Configure UI and XP settings inside Customize.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:

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
}

Commands like clearDailyData should be directly used from txadmin - Server side console.

How to use the commands for each framework :

When it comes to ESX, you need to use the player's license identifier, and make sure you remove the license: part but for QBCore/QBox 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

/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:

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

💡 Getting Player Identifier

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

Example:

ESX

local playerId = source  -- Gets the player's server ID
local identifier = GetPlayerIdentifier(playerId, 0):gsub('license:', '') -- Retrieves the player's unique identifier
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:

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

🔹 removeLevel(identifier, amount)

Decreases a player's level by a given amount.

Usage:

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:

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

🔹 setPremium(identifier, value)

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

Usage:

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

💰 Credit Functions

🔹 addCredit(identifier, amount)

Adds credits to a player.

Usage:

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

🔹 removeCredit(identifier, amount)

Removes credits from a player.

Usage:

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

🔹 getCredit(identifier)

Returns the player's current credit balance.

Usage:

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:

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

🔹 clearPlayersData()

Clears all players' data.

Usage:

exports['0bug_Battlepass']:clearPlayersData()

🔹 clearScriptData()

Resets all script-wide BattlePass data, including daily missions, spins, quizzes, and weekly missions.

Usage:

exports['0bug_Battlepass']:clearScriptData()

🔹 clearDailyData()

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

Usage:

exports['0bug_Battlepass']:clearDailyData()

🔹 clearWeeklyData()

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

Usage :

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

{
    "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.

How to implement the Mission in Other Scripts!

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 🍔) :

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 💧

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:

"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:

{
    "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/

You can define the type with 5 different options :

  • "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:

"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/

Last updated