Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server/player): setting job/gang to/from unemployed/none #513

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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