Reviving items

Anyone know how to make a pointshop item that players can purchase that will revive you?

snip

[lua]
ITEM.Name = ‘Revive’
ITEM.Price = 1000
ITEM.Model = ‘models/Items/HealthKit.mdl’
ITEM.NoPreview = true
ITEM.SingleUse = true
ITEM.AllowedUserGroups = { “admin”, “donator” }

function ITEM:OnBuy(ply)
ply:Spawn()
end

function ITEM:CanPlayerBuy(ply)
return !ply:Alive()
end
[/lua]

there ya go

Or if you want them to be revived where they died



local pos, ang = ply:GetPos(), ply:GetAngles()
ply:Spawn()
ply:SetPos(pos)
ply:SetAngles(ang)


-snip-
Forgot spectators can’t buy items

You’ll have to hook when the player dies and store the information then, not immediately on purchase.

But why would they purchase it if they aren’t dead?

No, the position still gets updated when dead; for example when falling.
Storing the data on death could cause some problems, imagine if the player dies in the air.

Entity:DropToFloor

So you’d rather have them spawn where they are whilst dead? What if they’re spectating another player?

I did not think about spectating at all, apologies.

Spectators can buy it if you edit the items “CanBuy” function :wink:

Ye but I was gonna say that Spectators will spawn if they buy it, which I realized it’s not relevant