Reviving items

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


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)

function ITEM:CanPlayerBuy(ply)
return !ply:Alive()

there ya go

Or if you want them to be revived where they died

local pos, ang = ply:GetPos(), ply:GetAngles()

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.


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