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 committed Nov 11, 2024
1 parent 9ac5d07 commit 7683c3d
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -904,23 +904,33 @@ 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
SetJob(self.PlayerData.source, '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 +942,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 +955,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 +968,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 7683c3d

Please sign in to comment.