RegisterNetEvent(‘uptime:revive’)
AddEventHandler(‘uptime:revive’, function()
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
TriggerServerEvent('esx_ambulancejob:setDeathStatus', false)
Citizen.CreateThread(function()
DoScreenFadeOut(800)
while not IsScreenFadedOut() do
Citizen.Wait(50)
end
local formattedCoords = {
x = ESX.Math.Round(coords.x, 1),
y = ESX.Math.Round(coords.y, 1),
z = ESX.Math.Round(coords.z, 1)
}
ESX.SetPlayerData('lastPosition', formattedCoords)
TriggerServerEvent('esx:updateLastPosition', formattedCoords)
RespawnPed(playerPed, formattedCoords, 0.0)
TriggerEvent('esx_ambulancejob:heal', 'big', true)
StopScreenEffect('DeathFailOut')
DoScreenFadeIn(800)
end)
end)
function RespawnPed(ped, coords, heading)
–SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false, true)
–NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, true, false)
SetPlayerInvincible(ped, false)
–TriggerEvent(‘playerSpawned’, coords.x, coords.y, coords.z)
ClearPedBloodDamage(ped)
ESX.UI.Menu.CloseAll()
end