• SWEP Cooldown for PrimaryAttack
    1 replies, posted
I used self.Weapon:SetNextPrimaryFire(CurTime() + 30) and self:SetNextPrimaryFire(CurTime() + 30) but neither work. I just want to make a cooldown so it cant be used constantly, and I want it to say in the chat that its on cooldown and display how many seconds are left in the cooldown. I've tried so many things but I just cant get it to work so any help at all would be appreciated. function SWEP:PrimaryAttack()          self.Weapon:SetNextPrimaryFire( CurTime() + 30 ) local tr = self.Owner:GetEyeTrace().Entity if not tr:IsValid() then return end if not (tr:IsNPC() or tr:IsPlayer() or ( tr:GetClass() == 'prop_ragdoll' )) then return end --if ( !self:CanPrimaryAttack() ) then return end  if tr:GetPos():Distance( self.Owner:GetPos() ) > self.Primary.Distance then return end RunConsoleCommand( self.PRIMARYPW )      end
self.Weapon should be the same as self, so just use self. Also delaying a console command is a little bit exploitable as the console command can be used multiple times, with just using the command instead of the weapon. Take a look at CanPrimaryAttack, maybe there lays the problem, otherwise the code should work.
Sorry, you need to Log In to post a reply to this thread.