Exports

Every export of the Battle Pass, with its arguments, return value and an example

6 min read · Updated Dec 3, 2026

Wherever an export asks for who, a number must be the server id of an online player. A string can be a server id or a character id.

Server exports

AddXP

Adds XP to a player. Levels are worked out from the new total.

Side: Server

Arguments

NameTypeRequiredDescription
whonumber or stringYesThe player: the server id of an online player (a number), or the character id (citizenid on qbx and qb, identifier on ESX).
amountnumberYesXP to add, 1 or more. Decimals are cut off.
reasonstringNoText shown to the player in the notification and passed to the event.

Returns

number: the new total XP, never above the XP of the last level. false when the player or the amount is not valid.

How to use it

lua
local total = exports.TopXBattlepass:AddXP(source, 250, 'Delivery finished')

if total then
    print(('Player %s now has %s XP'):format(source, total))
end

Good to know

  • Works for offline players when you pass the character id.
  • Fires topx_battlepass:onXpAdd, and topx_battlepass:onLevelUp when a level is gained.

RemoveXP

Takes XP away from a player. The total never goes below 0.

Side: Server

Arguments

NameTypeRequiredDescription
whonumber or stringYesThe player: the server id of an online player (a number), or the character id (citizenid on qbx and qb, identifier on ESX).
amountnumberYesXP to remove, 1 or more.
reasonstringNoText shown to the player in the notification and passed to the event.

Returns

number: the new total XP. false when the player or the amount is not valid.

How to use it

lua
exports.TopXBattlepass:RemoveXP(source, 100, 'Rule break')

Good to know

  • Fires topx_battlepass:onXpRemove.

SetXP

Sets the total XP of a player to an exact value.

Side: Server

Arguments

NameTypeRequiredDescription
whonumber or stringYesThe player: the server id of an online player (a number), or the character id (citizenid on qbx and qb, identifier on ESX).
amountnumberYesThe new total, from 0 to the XP of the last level.
reasonstringNoText shown to the player in the notification and passed to the event.

Returns

number: the new total XP. false when the player is not valid or the amount is outside the range.

How to use it

lua
exports.TopXBattlepass:SetXP('ABC12345', 0, 'Reset by staff')

Good to know

  • Fires onXpAdd or onXpRemove for the difference, and onLevelUp when the new total is a higher level.

GetXP

Reads the total XP of an online player.

Side: Server

Arguments

NameTypeRequiredDescription
whonumber or stringYesAn online player: server id (number) or character id (string).

Returns

number: the XP in the current season. 0 when the player is offline or unknown.

How to use it

lua
local xp = exports.TopXBattlepass:GetXP(source)

GetLevel

Reads the level of an online player.

Side: Server

Arguments

NameTypeRequiredDescription
whonumber or stringYesAn online player: server id (number) or character id (string).

Returns

number: the level in the current season. 0 when the player is offline or unknown.

How to use it

lua
if exports.TopXBattlepass:GetLevel(source) < 10 then
    return false -- this job needs level 10
end

HasPremium

Checks if an online player has the premium track.

Side: Server

Arguments

NameTypeRequiredDescription
whonumber or stringYesAn online player: server id (number) or character id (string).

Returns

boolean: true with premium. false without it, or when the player is offline.

How to use it

lua
local price = exports.TopXBattlepass:HasPremium(source) and 500 or 1000

SetPremium

Turns premium on or off for a player.

Side: Server

Arguments

NameTypeRequiredDescription
whonumber or stringYesThe player: the server id of an online player (a number), or the character id (citizenid on qbx and qb, identifier on ESX).
valuebooleanYestrue gives premium, false or nil removes it.

Returns

boolean: true when saved. false when the player is not valid or Config.BattlepassTypes is free.

How to use it

lua
exports.TopXBattlepass:SetPremium(source, true)

Good to know

  • Works for offline players when you pass the character id.
  • Fires topx_battlepass:onPremiumChange with by = 'export'.
  • For Tebex use the console command battlepass_premium {id} instead, it also keeps purchases of players who never joined.

GetSeason

Reads the current season.

Side: Server

Arguments

None.

Returns

table: { id: number, name: string, maxLevel: number, startedAt: number (unix time), mode: 'timed' or 'permanent', ... }.

How to use it

lua
local season = exports.TopXBattlepass:GetSeason()

print(season.id, season.name)

AddMissionProgress

Moves a mission of an online player forward. This is how a mission of the kind script is filled.

Side: Server

Arguments

NameTypeRequiredDescription
whonumber or stringYesAn online player: server id (number) or character id (string).
missionIdstringYesThe id of the mission, as made in /battlepassadmin, Missions.
amountnumberYesProgress to add, more than 0.

Returns

boolean: true only when this call finished the mission. false when the progress was added but the goal is not reached yet, and also when the player, the mission or the amount is not valid, or the mission is already done.

How to use it

lua
-- count one delivered package
AddEventHandler('myjob:server:delivered', function(playerId)
    local finished = exports.TopXBattlepass:AddMissionProgress(playerId, 'deliver_packages', 1)

    if finished then print('Mission done') end
end)

Good to know

  • The XP of the mission is given by itself when it finishes.
  • Fires topx_battlepass:onMissionComplete when it finishes.

CompleteMission

Finishes a mission of an online player at once.

Side: Server

Arguments

NameTypeRequiredDescription
whonumber or stringYesAn online player: server id (number) or character id (string).
missionIdstringYesThe id of the mission.

Returns

boolean: true when the mission was finished. false when it is unknown, off, already done, or the player is offline.

How to use it

lua
exports.TopXBattlepass:CompleteMission(source, 'first_heist')

Client exports

OpenBattlepass

Opens the battle pass window for the local player, the same as /battlepass.

Side: Client

Arguments

None.

Returns

Nothing.

How to use it

lua
RegisterCommand('rewards', function()
    exports.TopXBattlepass:OpenBattlepass()
end, false)

Good to know

  • Nothing happens when a TopX window is already open.