♻️ Little JobsPlayerCount refactor

This commit is contained in:
Gellipapa
2023-09-04 23:50:30 +02:00
parent 9e404fa022
commit 715ee856ba
+4 -2
View File
@@ -378,7 +378,8 @@ AddEventHandler('playerDropped', function(reason)
if xPlayer then
TriggerEvent('esx:playerDropped', playerId, reason)
local job = xPlayer.getJob().name
ESX.JobsPlayerCount[job] = ((ESX.JobsPlayerCount[job] and ESX.JobsPlayerCount[job] > 0) and ESX.JobsPlayerCount[job] or 1) -1
local currentJob = ESX.JobsPlayerCount[job]
ESX.JobsPlayerCount[job] = ((currentJob and currentJob > 0) and currentJob or 1) -1
Core.playersByIdentifier[xPlayer.identifier] = nil
Core.SavePlayer(xPlayer, function()
@@ -393,7 +394,8 @@ AddEventHandler("esx:playerLoaded", function(playerId, xPlayer, isNew)
end)
AddEventHandler("esx:setJob", function(src, job, lastJob)
ESX.JobsPlayerCount[lastJob.name] = ((ESX.JobsPlayerCount[lastJob.name] and ESX.JobsPlayerCount[lastJob.name] > 0) and ESX.JobsPlayerCount[lastJob.name] or 1) -1
local currentLastJob = ESX.JobsPlayerCount[lastJob.name]
ESX.JobsPlayerCount[lastJob.name] = ((currentLastJob and currentLastJob > 0) and currentLastJob or 1) -1
ESX.JobsPlayerCount[job.name] = (ESX.JobsPlayerCount[job.name] or 0) + 1
end)