Skip to content

Commit

Permalink
fix(server/player): onJobUpdate mirror onGangUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
mafewtm authored Nov 11, 2024
1 parent 19c6925 commit 74ac69f
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -903,24 +903,37 @@ function CreatePlayer(playerData, Offline)

AddEventHandler('qbx_core:server:onJobUpdate', function(jobName, job)
if self.PlayerData.job.name ~= jobName then return end

if not job then
self.Functions.setJob('unemployed', 0)
return
end
self.PlayerData.job.label = job.label
self.PlayerData.job.type = job.type or 'none'
local jobGrade = job.grades[self.PlayerData.job.grade.level]
if jobGrade then
self.PlayerData.job.grade.name = jobGrade.name
self.PlayerData.job.payment = jobGrade.payment or 30
self.PlayerData.job.isboss = jobGrade.isboss or false
else
self.PlayerData.job.grade = {
name = 'No Grades',
level = 0,
payment = 30,
self.PlayerData.job = {
name = 'unemployed',
label = 'Civilian',
isboss = false,
onduty = true,
payment = 10,
grade = {
name = 'Freelancer',
level = 0,
}
}
else
self.PlayerData.job.label = job.label
self.PlayerData.job.type = job.type or 'none'

local jobGrade = job.grades[self.PlayerData.job.grade.level]

if jobGrade then
self.PlayerData.job.grade.name = jobGrade.name
self.PlayerData.job.payment = jobGrade.payment or 30
self.PlayerData.job.isboss = jobGrade.isboss or false
else
self.PlayerData.job.grade = {
name = 'No Grades',
level = 0,
payment = 30,
isboss = false,
}
end
end

if not self.Offline then
Expand All @@ -932,6 +945,7 @@ function CreatePlayer(playerData, Offline)

AddEventHandler('qbx_core:server:onGangUpdate', function(gangName, gang)
if self.PlayerData.gang.name ~= gangName then return end

if not gang then
self.PlayerData.gang = {
name = 'none',
Expand All @@ -944,7 +958,9 @@ function CreatePlayer(playerData, Offline)
}
else
self.PlayerData.gang.label = gang.label

local gangGrade = gang.grades[self.PlayerData.gang.grade.level]

if gangGrade then
self.PlayerData.gang.isboss = gangGrade.isboss or false
else
Expand All @@ -955,6 +971,7 @@ function CreatePlayer(playerData, Offline)
self.PlayerData.gang.isboss = false
end
end

if not self.Offline then
UpdatePlayerData(self.PlayerData.source)
TriggerEvent('QBCore:Server:OnGangUpdate', self.PlayerData.source, self.PlayerData.gang)
Expand Down

0 comments on commit 74ac69f

Please sign in to comment.