mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
♻️ Little JobsPlayerCount refactor
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user