refactor(es_extended/client/modules/death): cleanup redundant checks

This commit is contained in:
Ilias Rbayti
2024-11-28 18:49:34 +01:00
parent e2c4ab73a6
commit 1bbd9b119a
+1 -7
View File
@@ -44,12 +44,6 @@ function Death:Natural()
end
function Death:Damaged(victim)
local victimId = NetworkGetPlayerIndexFromPed(victim)
local isDead = IsPedDeadOrDying(victim, true) or IsPedFatallyInjured(victim)
if victimId ~= ESX.playerId or not isDead then
return
end
self.killerEntity = GetPedSourceOfDeath(ESX.PlayerData.ped)
self.deathCause = GetPedCauseOfDeath(ESX.PlayerData.ped)
self.killerId = NetworkGetPlayerIndexFromPed(self.killerEntity)
@@ -69,7 +63,7 @@ end
AddEventHandler("esx:onPlayerSpawn", function()
Citizen.CreateThreadNow(function()
while not ESX.PlayerData.dead do
if IsPedDeadOrDying(ESX.PlayerData.ped, true) then
if IsPedDeadOrDying(ESX.PlayerData.ped, true) or IsPedFatallyInjured(ESX.PlayerData.ped) then
Death:Damaged(ESX.PlayerData.ped)
break
end