mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
feat(es_extended/server/main): add new handler 'esx:playerCrashed' for unloading players stale
This commit is contained in:
@@ -368,6 +368,25 @@ AddEventHandler("esx:playerLogout", function(playerId, cb)
|
||||
TriggerClientEvent("esx:onPlayerLogout", playerId)
|
||||
end)
|
||||
|
||||
AddEventHandler('esx:playerCrashed', function(identifier, cb)
|
||||
local xPlayer = ESX.GetPlayerFromIdentifier(identifier)
|
||||
|
||||
if xPlayer then
|
||||
local playerId = xPlayer.playerId
|
||||
local isExist = DoesPlayerExist(playerId --[[@as string]])
|
||||
|
||||
if playerId and isExist ~= 0 then
|
||||
TriggerEvent('esx:playerDropped', playerId)
|
||||
GlobalState["playerCount"] = GlobalState["playerCount"] - 1
|
||||
Core.playersByIdentifier[identifier] = nil
|
||||
ESX.Players[playerId] = nil
|
||||
if cb then
|
||||
cb()
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
if not Config.CustomInventory then
|
||||
RegisterNetEvent("esx:updateWeaponAmmo", function(weaponName, ammoCount)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
Reference in New Issue
Block a user