mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 15:01:40 +00:00
Add a menu to ask the player if he wants to be respawned at the hospital.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 ?',
|
||||
}
|
||||
Reference in New Issue
Block a user