mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
feat: revive player
This commit is contained in:
@@ -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(...)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user