mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
refactor: Optimize death module
This commit is contained in:
@@ -2,13 +2,15 @@ Citizen.CreateThread(function()
|
||||
local isDead = false
|
||||
|
||||
while true do
|
||||
Citizen.Wait(150)
|
||||
Citizen.Wait(0)
|
||||
local letSleep = 0
|
||||
local player = PlayerId()
|
||||
|
||||
if NetworkIsPlayerActive(player) then
|
||||
local playerPed = PlayerPedId()
|
||||
|
||||
if IsPedFatallyInjured(playerPed) and not isDead then
|
||||
letSleep = false
|
||||
isDead = true
|
||||
|
||||
local killerEntity, deathCause = GetPedSourceOfDeath(playerPed), GetPedCauseOfDeath(playerPed)
|
||||
@@ -20,10 +22,14 @@ Citizen.CreateThread(function()
|
||||
PlayerKilled(deathCause)
|
||||
end
|
||||
|
||||
elseif not IsPedFatallyInjured(playerPed) then
|
||||
elseif not IsPedFatallyInjured(playerPed) and isDead then
|
||||
letSleep = false
|
||||
isDead = false
|
||||
end
|
||||
end
|
||||
if letSleep then
|
||||
Citizen.Wait(500)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user