diff --git a/client/main.lua b/client/main.lua index 418ea4b3..82f8a623 100644 --- a/client/main.lua +++ b/client/main.lua @@ -37,6 +37,63 @@ function RespawnPed(ped, coords) SetPlayerInvincible(ped, false) TriggerEvent('playerSpawned', coords.x, coords.y, coords.z, coords.heading) ClearPedBloodDamage(ped) + ESX.UI.Menu.CloseAll() +end + +function StartRespawnToHospitalMenuTimer() + Citizen.Trace('starting timer') + ESX.SetTimeout(Config.MenuRespawnToHospitalDelay, function() + + Citizen.Trace('menu should appear') + + if IsDead then + + local elements = {} + + table.insert(elements, {label = 'OUI', value = 'yes'}) + + ESX.UI.Menu.Open( + 'default', GetCurrentResourceName(), 'menuName', + { + title = _U('respawn_at_hospital'), + align = 'top-left', + elements = elements + }, + function(data, menu) --Submit Cb + menu.close() + + Citizen.CreateThread(function() + + DoScreenFadeOut(800) + + while not IsScreenFadedOut() do + Citizen.Wait(0) + end + + ESX.TriggerServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function() + + TriggerServerEvent('esx:updateLastPosition', Config.Zones.HospitalInteriorInside1.Pos) + + RespawnPed(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside1.Pos) + StopScreenEffect('DeathFailOut') + DoScreenFadeIn(800) + end) + + end) + end, + function(data, menu) --Cancel Cb + --menu.close() + end, + function(data, menu) --Change Cb + --print(data.current.value) + end + ) + + + end + + end) + end function StartRespawnTimer() @@ -475,6 +532,7 @@ AddEventHandler('esx_ambulancejob:onPlayerDeath', function() IsDead = true StartRespawnTimer() + StartRespawnToHospitalMenuTimer() StartScreenEffect('DeathFailOut', 0, false) end) diff --git a/config.lua b/config.lua index 209fef42..8e1b8a90 100644 --- a/config.lua +++ b/config.lua @@ -2,6 +2,7 @@ Config = {} Config.DrawDistance = 100.0 Config.MarkerColor = {r = 102, g = 0, b = 102} Config.RespawnDelayAfterRPDeath = 10 * 60 * 1000 +Config.MenuRespawnToHospitalDelay= 1 * 60 * 1000 Config.RemoveWeaponsAfterRPDeath = true Config.RemoveCashAfterRPDeath = true Config.RemoveItemsAfterRPDeath = true diff --git a/locales/fr.lua b/locales/fr.lua index dc9819e1..44cf4e5c 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -32,4 +32,6 @@ Locales['fr'] = { ['ems_menu_putincar'] = 'mettre dans véhicule', -- Phone ['alert_ambulance'] = 'alerte Ambulance', + -- Death + ['respawn_at_hospital'] = 'voulez-vous être transporté à l\'hôpital ?', } \ No newline at end of file