feat: revive player

This commit is contained in:
Andyyy7666
2023-09-24 11:19:22 +02:00
parent 0e35b412fb
commit bbaf1aa90f
2 changed files with 47 additions and 0 deletions

View File

@@ -26,6 +26,45 @@ function NDCore.getPlayersFromCoords(distance, coords)
return closePlayers return closePlayers
end end
function NDCore.revivePlayer(reset, keepDead)
local usingAmbulance = GetResourceState("ND_Ambulance") == "started"
local veh = GetVehiclePedIsIn(cache.ped)
local seat = cache.seat
local coords = GetEntityCoords(cache.ped)
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, GetEntityHeading(cache.ped), true, true, false)
local ped = PlayerPedId()
if cache.ped ~= ped then
DeleteEntity(cache.ped)
ClearAreaOfPeds(coords.x, coords.y, coords.z, 1.5, false)
end
SetEntityInvincible(ped, false)
FreezeEntityPosition(ped, false)
SetEntityVisible(ped, true)
SetEveryoneIgnorePlayer(ped, false)
SetPedCanBeTargetted(ped, true)
SetEntityCanBeDamaged(ped, true)
SetBlockingOfNonTemporaryEvents(ped, false)
SetPedCanRagdollFromPlayerImpact(ped, true)
ClearPedTasksImmediately(ped)
if veh and veh ~= 0 then
SetPedIntoVehicle(ped, veh, seat)
end
if not keepDead then
LocalPlayer.state.dead = false
end
if reset and GetPedMovementClipset(ped) == `move_m@injured` then
ClearEntityLastDamageEntity(ped)
SetPedMoveRateOverride(ped, 1.0)
ResetPedMovementClipset(ped, 0)
end
if reset and usingAmbulance then
exports["ND_Ambulance"]:resetBodyDamage()
end
end
function NDCore.notify(...) function NDCore.notify(...)
if GetResourceState("ModernHUD") == "started" then if GetResourceState("ModernHUD") == "started" then
exports["ModernHUD"]:notify(...) exports["ModernHUD"]:notify(...)

View File

@@ -261,6 +261,14 @@ local function createCharacterTable(info)
return true return true
end end
function self.revive()
self.triggerEvent("ND:revivePlayer")
self.setMetadata({
dead = nil,
deathInfo = nil,
})
end
---@param reason string ---@param reason string
function self.drop(reason) function self.drop(reason)
if not self.source then return end if not self.source then return end