From 784aa4e1df8ec78a1c765e77b2ab1c123b0669ef Mon Sep 17 00:00:00 2001 From: MarioRogue <34819886+MarioRogue@users.noreply.github.com> Date: Sat, 9 Jun 2018 23:27:44 +0300 Subject: [PATCH] No more respawn for no reason --- client/main.lua | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/client/main.lua b/client/main.lua index 71730d3e..89b66ab5 100644 --- a/client/main.lua +++ b/client/main.lua @@ -58,29 +58,33 @@ AddEventHandler('esx_ambulancejob:heal', function(_type) end) function StartRespawnToHospitalMenuTimer() - ESX.SetTimeout(Config.MenuRespawnToHospitalDelay, function() - ESX.UI.Menu.Open( - 'default', GetCurrentResourceName(), 'respawn_hospital', - { - title = _U('respawn_at_hospital'), - align = 'top-left', - elements = { - {label = _U('no'), value = 'no'}, - {label = _U('yes'), value = 'yes'} - } - }, function(data, menu) - if data.current.value == 'yes' then - RemoveItemsAfterRPDeath() - end - menu.close() - end) - end) + ESX.SetTimeout(Config.MenuRespawnToHospitalDelay, function() + if IsDead then + ESX.UI.Menu.Open( + 'default', GetCurrentResourceName(), 'respawn_hospital', + { + title = _U('respawn_at_hospital'), + align = 'bottom-right', + elements = { + {label = _U('no'), value = 'no'}, + {label = _U('yes'), value = 'yes'} + } + }, function(data, menu) + if data.current.value == 'yes' then + RemoveItemsAfterRPDeath() + end + menu.close() + end) + end + end) end function StartRespawnTimer() - ESX.SetTimeout(Config.RespawnDelayAfterRPDeath, function() - RemoveItemsAfterRPDeath() - end) + ESX.SetTimeout(Config.RespawnDelayAfterRPDeath, function() + if IsDead then + RemoveItemsAfterRPDeath() + end + end) end function StartDistressSignal()