Hi,
I am trying to create a healt boost that only lasts one round that you can't buy more than one of each round, but the health boost doesn't work. It doesn't update the health to 125.
Any idea why
Here is the code:
ITEM.Name = '125 Health (1 Round)'
ITEM.Price = 125
ITEM.SingleUse = true
ITEM.Material = 'materials/icon16/health.png'
ITEM.SingleUse = true
ITEM.NoPreview = true
function ITEM:OnEquip(ply)
ply:SetHealth(126)
endfunction ITEM:OnHolster(ply)
ply:SetHealth(100)
end
just looked at the pointshop docs, I'd do a print statement on the OnEquip method and see if it gets called, and also check what color the printed text is, if it's orange it's being ran clientside, blue serverside, you want it to be blue.
Perhaps adding a timer and a check if the player is restoring health they shouldnt resulting in healing themselves
function ITEM:OnEquip(ply)
timer.Simple(5,function()
ply.OldHealth = ply:Health()
ply:SetHealth(126)
end)
end
function ITEM:OnHolster(ply)
timer.Simple(5,function()
if ply:Health() == 126 then
ply:SetHealth()
end
end)
end
Aragon is definitely on the right track but the timer is not the best way to go. It sounds like this is for TTT, which will reset the player's health when the round starts. Assuming it is TTT you'll need to use the hook TTTBeginRound to set their health. In the OnEquip function do something like
ply.HealthOverride = 126
and then in the hook loop over the players, set the health for any players with HealthOverride, and set HealthOverride to nil so it doesn't happen again next round.
If it's not TTT you're talking about, your gamemode (or an addon) is probably doing something similar and you'd use something similar to fix it.
Sorry, you need to Log In to post a reply to this thread.