Timer Help?

Ok, so i’ve made a armor charger but it charges extremely fast. I’ve tried using a timer to slow it down but it doesn’t work. How would i make it so every 5 seconds they get 1 health? Thanks in advance!



if self:Health() < 0 then self:Remove() end
		    self:EmitSound( "items/suitchargeok1.wav" )
			ply:SetArmor( ply:Armor() + 1)
			self:SetHealth( self:Health() - 1 )
		if ply:Armor() > 99 then 
			ply:SetArmor(100)
	
		end
	end



timer.Create("GetHealth", 5, 0, functon()
       if self:Health() < 0 then self:Remove() end
		    self:EmitSound( "items/suitchargeok1.wav" )
			ply:SetArmor( ply:Armor() + 1)
			self:SetHealth( self:Health() - 1 )
		if ply:Armor() > 99 then 
			ply:SetArmor(100)
	
		end
	end
end)

[editline]1st May 2015[/editline]

I believe that would work, I wrote it really quick and didn’t test it though.

Nope, didn’t work.

you might have to move the timer into the if statement then.

ex.


if self:Health() < 0 then self:Remove() end
         self:EmitSound( "items/suitchargeok1.wav" )
         timer.Create("GetHealth", 5, 0, function()
	        ply:SetArmor( ply:Armor() + 1)
         end)
         timer.Create("GetArmor", 5, 0, function()
		self:SetHealth( self:Health() - 1 )
         end)
	 if ply:Armor() > 99 then 
		ply:SetArmor(100)
	
		end
	end
end)

FYI, another untested code, but this one makes more sense.

Nope, still didn’t work xD

Dumb question I know already, but if this is an addon you created did you restart the server? Because I know I have to do it sometimes to get them to adjust, or atleast a map change.

You’re putting it in a function/hook, right?