Skip to content

Commit

Permalink
Merge pull request #1111 from Z3rio/fix-isboss-sync
Browse files Browse the repository at this point in the history
fix: gang/job validation
  • Loading branch information
GhzGarage authored Jul 25, 2024
2 parents a45efe7 + 4344c3a commit e488cbe
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,50 @@ function QBCore.Player.CheckPlayerData(source, PlayerData)
PlayerData.name = GetPlayerName(source)
end

local validatedJob = false
if PlayerData.job and PlayerData.job.name ~= nil and PlayerData.job.grade and PlayerData.job.grade.level ~= nil then
local jobInfo = QBCore.Shared.Jobs[PlayerData.job.name]

if jobInfo then
local jobGradeInfo = jobInfo.grades[tostring(PlayerData.job.grade.level)]
if jobGradeInfo then
PlayerData.job.label = jobInfo.label
PlayerData.job.grade.name = jobGradeInfo.name
PlayerData.job.payment = jobGradeInfo.payment
PlayerData.job.grade.isboss = jobGradeInfo.isboss or false
PlayerData.job.isboss = jobGradeInfo.isboss or false
validatedJob = true
end
end
end

if validatedJob == false then
-- set to nil, as the default job (unemployed) will be added by `applyDefaults`
PlayerData.job = nil
end

local validatedGang = false
if PlayerData.gang and PlayerData.gang.name ~= nil and PlayerData.gang.grade and PlayerData.gang.grade.level ~= nil then
local gangInfo = QBCore.Shared.Gangs[PlayerData.gang.name]

if gangInfo then
local gangGradeInfo = gangInfo.grades[tostring(PlayerData.gang.grade.level)]
if gangGradeInfo then
PlayerData.gang.label = gangInfo.label
PlayerData.gang.grade.name = gangGradeInfo.name
PlayerData.gang.payment = gangGradeInfo.payment
PlayerData.gang.grade.isboss = gangGradeInfo.isboss or false
PlayerData.gang.isboss = gangGradeInfo.isboss or false
validatedGang = true
end
end
end

if validatedGang == false then
-- set to nil, as the default gang (unemployed) will be added by `applyDefaults`
PlayerData.gang = nil
end

applyDefaults(PlayerData, QBCore.Config.Player.PlayerDefaults)

if GetResourceState('qb-inventory') ~= 'missing' then
Expand Down

0 comments on commit e488cbe

Please sign in to comment.