refactor: revive function

This commit is contained in:
Andyyy7666
2023-11-19 00:09:45 +01:00
parent 53255bf336
commit 7cc3bbe42a

View File

@@ -28,6 +28,14 @@ end
function NDCore.revivePlayer(reset, keepDead) function NDCore.revivePlayer(reset, keepDead)
local usingAmbulance = GetResourceState("ND_Ambulance") == "started" local usingAmbulance = GetResourceState("ND_Ambulance") == "started"
if not keepDead then
LocalPlayer.state.dead = false
if usingAmbulance then
local state = Player(cache.serverId).state
state:set("isDead", false, true)
end
end
local veh = GetVehiclePedIsIn(cache.ped) local veh = GetVehiclePedIsIn(cache.ped)
local seat = cache.seat local seat = cache.seat
local coords = GetEntityCoords(cache.ped) local coords = GetEntityCoords(cache.ped)
@@ -36,7 +44,7 @@ function NDCore.revivePlayer(reset, keepDead)
local ped = PlayerPedId() local ped = PlayerPedId()
if cache.ped ~= ped then if cache.ped ~= ped then
DeleteEntity(cache.ped) DeleteEntity(cache.ped)
ClearAreaOfPeds(coords.x, coords.y, coords.z, 1.5, false) ClearAreaOfPeds(coords.x, coords.y, coords.z, 0.2, false)
end end
SetEntityInvincible(ped, false) SetEntityInvincible(ped, false)
@@ -52,9 +60,6 @@ function NDCore.revivePlayer(reset, keepDead)
if veh and veh ~= 0 then if veh and veh ~= 0 then
SetPedIntoVehicle(ped, veh, seat) SetPedIntoVehicle(ped, veh, seat)
end end
if not keepDead then
LocalPlayer.state.dead = false
end
if reset and GetPedMovementClipset(ped) == `move_m@injured` then if reset and GetPedMovementClipset(ped) == `move_m@injured` then
ClearEntityLastDamageEntity(ped) ClearEntityLastDamageEntity(ped)
SetPedMoveRateOverride(ped, 1.0) SetPedMoveRateOverride(ped, 1.0)