mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
refactor: remove endless death check loop
This commit is contained in:
@@ -1,32 +1,17 @@
|
|||||||
CreateThread(function()
|
AddEventHandler('gameEventTriggered', function(event, data)
|
||||||
local isDead = false
|
if event ~= 'CEventNetworkEntityDamage' then return end
|
||||||
|
local victim, victimDied = data[1], data[4]
|
||||||
while true do
|
if not IsPedAPlayer(victim) then return end
|
||||||
local sleep = 1500
|
local player = PlayerId()
|
||||||
local player = PlayerId()
|
local playerPed = PlayerPedId()
|
||||||
|
if victimDied and NetworkGetPlayerIndexFromPed(victim) == player and IsPedDeadOrDying(victim, true) then
|
||||||
if NetworkIsPlayerActive(player) then
|
local killerEntity, deathCause = GetPedSourceOfDeath(playerPed), GetPedCauseOfDeath(playerPed)
|
||||||
local playerPed = PlayerPedId()
|
local killerClientId = NetworkGetPlayerIndexFromPed(killerEntity)
|
||||||
|
if killerEntity ~= playerPed and killerClientId and NetworkIsPlayerActive(killerClientId) then
|
||||||
if IsPedFatallyInjured(playerPed) and not isDead then
|
PlayerKilledByPlayer(GetPlayerServerId(killerClientId), killerClientId, deathCause)
|
||||||
sleep = 0
|
else
|
||||||
isDead = true
|
PlayerKilled(deathCause)
|
||||||
|
|
||||||
local killerEntity, deathCause = GetPedSourceOfDeath(playerPed), GetPedCauseOfDeath(playerPed)
|
|
||||||
local killerClientId = NetworkGetPlayerIndexFromPed(killerEntity)
|
|
||||||
|
|
||||||
if killerEntity ~= playerPed and killerClientId and NetworkIsPlayerActive(killerClientId) then
|
|
||||||
PlayerKilledByPlayer(GetPlayerServerId(killerClientId), killerClientId, deathCause)
|
|
||||||
else
|
|
||||||
PlayerKilled(deathCause)
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif not IsPedFatallyInjured(playerPed) and isDead then
|
|
||||||
sleep = 0
|
|
||||||
isDead = false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
Wait(sleep)
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user