Revive players

Hello.

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

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

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.

[lua]
local function RevivePlayer( ply )

ply:GetRagdollEntity()
ragdoll.Player = ply

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

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

[/lua]

[LUA]
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.
end
hook.Add(“PlayerDeath”, “RevivePlayerDeathHook”, RevivePlayerDeathHook)

local function RevivePlayer( user, entity)
if (entity.ply) then
local position = entity:GetPos()
entity.ply:SetPos(position)
entity.ply:Spawn()
end
end
hook.Add(“PlayerUse”, “RevivePlayer”, RevivePlayer)
[/LUA]

Untested, but should work.

nvm i did it. Thanks for help