mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 18:28:52 +00:00
refactor: Optimize death module
This commit is contained in:
+8
-10
@@ -405,17 +405,15 @@ function StartServerSyncLoops()
|
||||
end)
|
||||
end
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while Config.EnableDefaultInventory do
|
||||
Citizen.Wait(9)
|
||||
|
||||
if IsControlJustReleased(0, 289) then
|
||||
if IsInputDisabled(0) and not isDead and not ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') then
|
||||
ESX.ShowInventory()
|
||||
end
|
||||
if Config.EnableDefaultInventory then
|
||||
RegisterCommand('showinv', function()
|
||||
if not isDead and not ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') then
|
||||
ESX.ShowInventory()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterKeyMapping('showinv', _U('keymap_showinventory'), 'keyboard', 'F2')
|
||||
end
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
|
||||
@@ -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