โš™๏ธ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
}

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.

Example:

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

๐ŸŽฎ Player Data Functions

๐Ÿ”น addLevel(identifier, amount)

Increases a player's level by a given amount.

Usage:

local identifier = GetPlayerIdentifier(PlayerPedId(), 0):gsub('license:', '')
exports['0bug_Battlepass']:addLevel(identifier, 1)

๐Ÿ”น removeLevel(identifier, amount)

Decreases a player's level by a given amount.

Usage:

local identifier = GetPlayerIdentifier(PlayerPedId(), 0):gsub('license:', '')
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:

local identifier = GetPlayerIdentifier(PlayerPedId(), 0):gsub('license:', '')
exports['0bug_Battlepass']:addXP(identifier, 500)

๐Ÿ”น setPremium(identifier, value)

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

Usage:

local identifier = GetPlayerIdentifier(PlayerPedId(), 0):gsub('license:', '')
exports['0bug_Battlepass']:setPremium(identifier, true)

๐Ÿ’ฐ Credit Functions

๐Ÿ”น addCredit(identifier, amount)

Adds credits to a player.

Usage:

local identifier = GetPlayerIdentifier(PlayerPedId(), 0):gsub('license:', '')
exports['0bug_Battlepass']:addCredit(identifier, 100)

๐Ÿ”น removeCredit(identifier, amount)

Removes credits from a player.

Usage:

local identifier = GetPlayerIdentifier(PlayerPedId(), 0):gsub('license:', '')
exports['0bug_Battlepass']:removeCredit(identifier, 50)

๐Ÿ”น getCredit(identifier)

Returns the player's current credit balance.

Usage:

local identifier = GetPlayerIdentifier(PlayerPedId(), 0):gsub('license:', '')
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:

local identifier = GetPlayerIdentifier(PlayerPedId(), 0):gsub('license:', '')
exports['0bug_Battlepass']:clearPlayerData(identifier)

๐Ÿ”น clearPlayersData()

Clears all players' data.

Usage:

exports['0bug_Battlepass']:clearPlayersData()

๐Ÿ”น clearScriptData()

Resets script-related data (e.g., daily missions, spins, weekly missions).

Usage:

exports['0bug_Battlepass']:clearScriptData()

๐Ÿ“Œ 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