Skip to content

Commit

Permalink
fix(server/player): exports for offline players (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason authored Dec 7, 2024
1 parent 46da66a commit e61c4c0
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,11 @@ function SetPlayerPrimaryJob(citizenid, jobName)
assert(job.grades[grade] ~= nil, ('job %s does not have grade %s'):format(jobName, grade))

player.PlayerData.job = toPlayerJob(jobName, job, grade)
Save(player.PlayerData.source)

if not player.Offline then
if player.Offline then
SaveOffline(player.PlayerData)
else
Save(player.PlayerData.source)
UpdatePlayerData(player.PlayerData.source)
TriggerEvent('QBCore:Server:OnJobUpdate', player.PlayerData.source, player.PlayerData.job)
TriggerClientEvent('QBCore:Client:OnJobUpdate', player.PlayerData.source, player.PlayerData.job)
Expand Down Expand Up @@ -316,7 +318,11 @@ function RemovePlayerFromJob(citizenid, jobName)
local job = GetJob('unemployed')
assert(job ~= nil, 'cannot find unemployed job. Does it exist in shared/jobs.lua?')
player.PlayerData.job = toPlayerJob('unemployed', job, 0)
Save(player.PlayerData.source)
if player.Offline then
SaveOffline(player.PlayerData)
else
Save(player.PlayerData.source)
end
end

if not player.Offline then
Expand Down Expand Up @@ -419,9 +425,10 @@ function SetPlayerPrimaryGang(citizenid, gangName)
}
}

Save(player.PlayerData.source)

if not player.Offline then
if player.Offline then
SaveOffline(player.PlayerData)
else
Save(player.PlayerData.source)
UpdatePlayerData(player.PlayerData.source)
TriggerEvent('QBCore:Server:OnGangUpdate', player.PlayerData.source, player.PlayerData.gang)
TriggerClientEvent('QBCore:Client:OnGangUpdate', player.PlayerData.source, player.PlayerData.gang)
Expand Down Expand Up @@ -541,7 +548,11 @@ function RemovePlayerFromGang(citizenid, gangName)
level = 0
}
}
Save(player.PlayerData.source)
if player.Offline then
SaveOffline(player.PlayerData)
else
Save(player.PlayerData.source)
end
end

if not player.Offline then
Expand Down

0 comments on commit e61c4c0

Please sign in to comment.