Revive players


Can somebody tell me how can i revive players after they died?
For example: if i press USE on his body then i revive him.

Well you could use the function ply.Spawn(I cant find it on the Wiki, is it normal?) and a function that would save where they died and respawn them where they died. Im not gonna do it for you but im giving you some clues.

do something like

local trace = ply:GetEyeTrace()
if(trace:IsPlayer() and !trace:IsAlive()) then
— spawn function or something to bring them back :stuck_out_tongue:

Trace returns a table, and a “dead” player isn’t actually a player.

Hook PlayerDeath, get the players ragdoll (ply:GetRagdollEntity()), set a variable on it (ragdoll.Player = ply) then you can use the code hardmod posted, except replace trace:IsPlayer() with trace.Entity.ply and remove the not alive part.

Something like this or what? i dont really understand.

local function RevivePlayer( ply )

ragdoll.Player = ply

local trace = ply:GetEyeTrace()  
if trace.Entity.ply then  
   -- asdadsasdasd

hook.Add( “PlayerDeath”, “playerDeathTest”, RevivePlayer)


local function RevivePlayerDeathHook( victim, weapon, killer ) – When a player dies…
local ragdoll = victim:GetRagdollEntity() – …get the ragdoll…
ragdoll.ply = victim – …and add the player as a member.
hook.Add(“PlayerDeath”, “RevivePlayerDeathHook”, RevivePlayerDeathHook)

local function RevivePlayer( user, entity)
if (entity.ply) then
local position = entity:GetPos()
hook.Add(“PlayerUse”, “RevivePlayer”, RevivePlayer)

Untested, but should work.

nvm i did it. Thanks for help