xperience | 经验系统
XP Ranking System for FiveM | FiveM 经验排名系统
NOTE:The original author no longer maintains it, so I have taken over.
Features
- Designed to emulate the native GTA:O system
- Saves and loads players XP / rank
- Add / remove XP from your own script / job
- Allows you listen for rank changes to reward players
- Fully customisable UI
- Integrated leaderboard
-
Increasing XP

Rank Up

Install
-
Download and extract the package: GitHub - wusheng666/xperience: FiveM的XP排名系统
Select an option: -
Option 1 - If you want to use
xperienceas a standalone resource then importxperience_standalone.sqlonly -
Option 2 - If using
ESXwithConfig.UseESXset totruethen importxperience_esx.sqlonly. This adds thexpandrankcolumns to theuserstable
- If you’re transitioning from
esx_xp, then don’t importxperience_esx.sql, instead see Transitioning from esx_xp
- Option 3 - If using
QBCorewithConfig.UseQBCoreset totruethen there’s no need to import anysqlfiles as the xp and rank are saved to the player’s metadata - see QBCore Integration
then:
-
Drop the
xperiencedirectory into youresourcesdirectory -
Add
ensure xperienceto yourserver.cfgfile
By default this resource uses oxmysql, but if you don’t want to use / install it then you can use mysql-async by following these instructions:
- Uncomment the
'@mysql-async/lib/MySQL.lua',line infxmanifest.luaand comment out the'@oxmysql/lib/MySQL.lua'line
Transitioning from esx_xp
If you previously used esx_xp and are still using es_extended then do the following to make your current stored xp / rank data compatible with xperience
-
Rename the
rp_xpcolumn in theuserstable toxp -
Rename the
rp_rankcolumn in theuserstable torank -
Set
Config.UseESXtotrue -
Usage
Client Side
Client Exports
Give XP to player
exports.xperience:AddXP(xp --[[ integer ]])
Take XP from player
exports.xperience:RemoveXP(xp --[[ integer ]])
Set player’s XP
exports.xperience:SetXP(xp --[[ integer ]])
Set player’s rank
exports.xperience:SetRank(rank --[[ integer ]])
Get player’s XP
exports.xperience:GetXP()
Get player’s rank
exports.xperience:GetRank()
Get XP required to rank up
exports.xperience:GetXPToNextRank()
Get XP required to reach defined rank
exports.xperience:GetXPToRank(rank --[[ integer ]])
Client Events
Listen for rank up event on the client
AddEventHandler("xperience:client:rankUp", function(newRank, previousRank, player)
-- do something when player ranks up
end)
Listen for rank down event on the client
AddEventHandler("xperience:client:rankDown", function(newRank, previousRank, player)
-- do something when player ranks down
end)
Server Side
Server Exports
Get player’s XP
exports.xperience:GetPlayerXP(playerId --[[ integer ]])
Get player’s rank
exports.xperience:GetPlayerRank(playerId --[[ integer ]])
Get player’s required XP to rank up
exports.xperience:GetPlayerXPToNextRank(playerId --[[ integer ]])
Get player’s required XP to reach defined rank
exports.xperience:GetPlayerXPToRank(playerId --[[ integer ]], rank --[[ integer ]])
Server Triggers
TriggerClientEvent('xperience:client:addXP', playerId --[[ integer ]], xp --[[ integer ]])
TriggerClientEvent('xperience:client:removeXP', playerId --[[ integer ]], xp --[[ integer ]])
TriggerClientEvent('xperience:client:setXP', playerId --[[ integer ]], xp --[[ integer ]])
TriggerClientEvent('xperience:client:setRank', playerId --[[ integer ]], rank --[[ integer ]])
Server Events
RegisterNetEvent('xperience:server:rankUp', function(newRank, previousRank)
-- do something when player ranks up
end)
RegisterNetEvent('xperience:server:rankDown', function(newRank, previousRank)
-- do something when player ranks down
end)
Rank Actions
You can define callbacks on each rank by using the Action function.
The function will be called both when the player reaches the rank and drops to the rank.
You can check whether the player reached or dropped to the new rank by utilising the rankUp parameter.
Config.Ranks = {
[1] = { XP = 0 },
[2] = {
XP = 800, -- The XP required to reach this rank
Action = function(rankUp, prevRank, player)
-- rankUp: boolean - whether the player reached or dropped to this rank
-- prevRank: number - the player's previous rank
-- player: integer - The current player
end
},
[3] = { XP = 2100 },
[4] = { XP = 3800 },
...
}
QBCore Integration
If Config.UseQBCore is set to true then the player’s xp and rank are stored in their metadata. The metadata is saved whenever a player’s xp / rank changes.
Client
local PlayerData = QBCore.Functions.GetPlayerData()
local xp = PlayerData.metadata.xp
local rank = PlayerData.metadata.rank
Server
local Player = QBCore.Functions.GetPlayer(src)
local xp = Player.PlayerData.metadata.xp
local rank = Player.PlayerData.metadata.rank
ESX Integration
Server
local xPlayer = ESX.GetPlayerById(src)
local xp = xPlayer.get('xp')
local rank = xPlayer.get('rank')
Commands
-- Set the theme
/setXPTheme [theme]
Admin Commands
These require ace permissions: e.g. add_ace group.admin command.addXP allow
-- Award XP to player
/addXP [playerId] [xp]
-- Deduct XP from player
/removeXP [playerId] [xp]
-- Set a player's XP
/setXP [playerId] [xp]
-- Set a player's rank
/setRank [playerId] [rank]