cold down?


function ENT:Use( activator, caller )
 

 
	if ( activator:IsPlayer() ) then
 
		// Give the collecting player some free health
		local health = activator:Health()
		activator:GiveAmmo( 50,       "Pistol")
 
	end
 
end

how do i make a cold-down? like if i use it i have to wait 20 secounds before i can use it again.

//Gusssan - Thx for answers! :slight_smile:


(User was banned for this post ("Wrong section" - mahalis))

[lua]function ENT:Use( activator, caller )
if ( activator:IsPlayer() ) then
if( self.CoolDown and self.CoolDown < CurTime() ) then
// Give the collecting player some free health
local health = activator:Health()
activator:GiveAmmo( 50, “Pistol”)
self.CoolDown = CurTime() + 20 // Replace 20 with the Cool Down time in seconds
else
// Give the collecting player some free health
local health = activator:Health()
activator:GiveAmmo( 50, “Pistol”)
self.CoolDown = CurTime() + 20
end

end

end
[/lua]

[editline]03:19PM[/editline]

Oh and i assume you mean Cool Down, not Cold Down? :v:

[lua]
function ENT:Use(shit)
if (self.NextUse or 0) < CurTime() then
print(“COCK”)
end
self.NextUse = CurTime() + 9000

end[/lua]

I like mine better :downs:

A lot of people who want a cool-down just want it to only do stuff when you first press use on it. In which case put
self:SetUseType(SIMPLE_USE) in the ENT:Initialize() hook.