From 590044b5d64ea2a079a535e346d5d2720db2dd93 Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Mon, 12 Feb 2024 23:27:43 +0100 Subject: [PATCH] refactor(client): revive function --- client/events.lua | 26 +++++++++++++++++++++++++- client/functions.lua | 44 -------------------------------------------- 2 files changed, 25 insertions(+), 45 deletions(-) diff --git a/client/events.lua b/client/events.lua index 48b0f40..ac32cbb 100644 --- a/client/events.lua +++ b/client/events.lua @@ -22,7 +22,31 @@ RegisterNetEvent("ND:updateLastLocation", function(location) end) RegisterNetEvent("ND:revivePlayer", function() - NDCore.revivePlayer(true) + if source == "" then return end + 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, 0.2, 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 end) RegisterNetEvent("ND:characterUnloaded") diff --git a/client/functions.lua b/client/functions.lua index db45685..09a7991 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -33,50 +33,6 @@ function NDCore.getConfig(info) return Config[info] end -function NDCore.revivePlayer(reset, keepDead) - 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 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, 0.2, 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 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(...) lib.notify(...) end