From e61c4c0b21902a07e650ddf1e9f134ab7c4b3ac5 Mon Sep 17 00:00:00 2001 From: Manason Date: Sat, 7 Dec 2024 10:10:04 -0800 Subject: [PATCH] fix(server/player): exports for offline players (#637) --- server/player.lua | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/server/player.lua b/server/player.lua index 8248e25e5..9ff147ff9 100644 --- a/server/player.lua +++ b/server/player.lua @@ -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) @@ -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 @@ -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) @@ -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