Help Cooldown SWEP

I need help with this one thing i have made on my server, a stick that freezes a player and unfreezes 5 seconds later. So far its working the only problem is their is no cooldown so it can be hit like 10 times on one player and keep them frozen. I need help making a cooldown almost like a reload. I have no clue how to start it off. I cant paste all the code here because it is from DarkRP and idk if i could get in trouble doing so. Its a copy of the stunstick except it has this code under the function SWEP:DoAttack(dmg)



			ent:Freeze( true )
			ent:ChatPrint( "You have been frozen by a Government Official!" )
			self.Owner:ChatPrint( "You have froze this player!" )
		
			timer.Simple( 5, function() 
			ent:Freeze( false ) 
			ent:ChatPrint( "You have thawed out! (UnFrozen)" )
			self.Owner:ChatPrint( "This player has thawed out! (UnFroze)" )
			end )


This is how you would do it.


self:SetNextAttack( 1 )

Didn’t work any other solutions?



	ent:Freeze( true )
	ent:ChatPrint( "You have been frozen by a Government Official!" )
	self.Owner:ChatPrint( "You have froze this player!" )
	timer.Simple( 5, function() 
	ent:Freeze( false ) 
	ent:ChatPrint( "You have thawed out! (UnFrozen)" )
	self.Owner:ChatPrint( "This player has thawed out! (UnFroze)" )
	end )
	self:SetNextAttack( 1 )


and



function SWEP:PrimaryAttack()
    BaseClass.PrimaryAttack(self)
    self:SetNextSecondaryFire(self:GetNextPrimaryFire())
    self:DoAttack(10)
    self:SetNextAttack( 1 )
end

function SWEP:SecondaryAttack()
    BaseClass.PrimaryAttack(self)
    self:SetNextSecondaryFire(self:GetNextPrimaryFire())
    self:DoAttack(10)
    self:SetNextAttack( 1 )
end


Heres how i’m doing it here. Let me clue you in on a little secret. Theres this big book on the web called the wiki with a bunch of documentation on what each class/hook/blah blah does. Theres even tutorials! In fact, i even pulled this straight from a tutorial because i am learning myself.

[lua]
self.Weapon:SetNextSecondaryFire( CurTime() + 1 ) --Adds a one second delay for the shots
[/lua]

If you’re looking how to prevent people from spamming the swep on a player then i’m out of luck. Good luck eating i mean learning.

I tried both



    self:SetNextSecondaryFire( CurTime() +  50 )


and



    self.Weapon:SetNextSecondaryFire( CurTime() +  50 )


Still no good result any others?

Here is the full code : http://pastebin.com/maJ3rR5q

have you tried under the part where you freeze them to check if there already frozen? somthing like



if target:IsFlagSet(64) == false then
        ent:Freeze( true )
        ent:ChatPrint( "You have been frozen by a Government Official!" )
	self.Owner:ChatPrint( "You have froze this player!" )
end


fixed it better for you just replace target with what ever your targets ent is.
this checks the flag on the player to see if there frozen.

Me trying to fix it came across something weird heres the code



function SWEP:PrimaryAttack()
	self:SecondaryAttack()
end

function SWEP:SecondaryAttack()
    BaseClass.PrimaryAttack(self)
    self:SetNextSecondaryFire(CurTime() + 5)
	self:SetNextPrimaryFire(CurTime() + 5)
    self:DoAttack(10)
end


The primary can fire every second but the secondary cant fire untill 5 seconds after the primary or 5 seconds after the last secondary fire any reason?

EDIT : Heres the full code -> http://pastebin.com/MUD4WzwU

My goal is to make the swep take 5-10 seconds after hitting once to be able to hit agian

with your primary all your doing is calling your secondary
instead try somthing like this.



function SWEP:PrimaryAttack()
     self:SetNextPrimaryFire(CurTime() + 5)
     self:SetNextSecondaryFire(CurTime() + 5)
     self:DoAttack(10)
end

function SWEP:SecondaryAttack()
     self:SetNextPrimaryFire(CurTime() + 5)
     self:SetNextSecondaryFire(CurTime() + 5)
     self:DoAttack(10)
end


this should make sure that both prim and secd are set to the same time.