Skip to content

Commit

Permalink
fix(server/player): setting job/gang to/from unemployed/none (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason committed Jul 8, 2024
1 parent 7125748 commit e26a246
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,15 @@ function CreatePlayer(playerData, Offline)
lib.print.error(('cannot set job. Job %s does not have grade %s'):format(jobName, grade))
return false
end
if setJobReplaces then
RemovePlayerFromJob(self.PlayerData.citizenid, self.PlayerData.job.name)
if setJobReplaces and self.PlayerData.job.name ~= 'unemployed' then
local success, errorResult = RemovePlayerFromJob(self.PlayerData.citizenid, self.PlayerData.job.name)
if not success then return false, errorResult end
end
local success, errorResult = AddPlayerToJob(self.PlayerData.citizenid, jobName, grade)
if not success then return false, errorResult end
success, errorResult = SetPlayerPrimaryJob(self.PlayerData.citizenid, jobName)
if jobName ~= 'unemployed' then
local success, errorResult = AddPlayerToJob(self.PlayerData.citizenid, jobName, grade)
if not success then return false, errorResult end
end
local success, errorResult = SetPlayerPrimaryJob(self.PlayerData.citizenid, jobName)
if not success then return false, errorResult end
return true
end
Expand All @@ -651,13 +654,15 @@ function CreatePlayer(playerData, Offline)
lib.print.error(('cannot set gang. Gang %s does not have grade %s'):format(gangName, grade))
return false
end
if setGangReplaces then
if setGangReplaces and self.PlayerData.gang.name ~= 'none' then
local success, errorResult = removePlayerFromGang(self.PlayerData.citizenid, self.PlayerData.gang.name)
if not success then return false, errorResult end
end
local success, errorResult = AddPlayerToGang(self.PlayerData.citizenid, gangName, grade)
if not success then return false, errorResult end
success, errorResult = setPlayerPrimaryGang(self.PlayerData.citizenid, gangName)
if gangName ~= 'none' then
local success, errorResult = AddPlayerToGang(self.PlayerData.citizenid, gangName, grade)
if not success then return false, errorResult end
end
local success, errorResult = setPlayerPrimaryGang(self.PlayerData.citizenid, gangName)
if not success then return false, errorResult end
return true
end
Expand Down

0 comments on commit e26a246

Please sign in to comment.