Garry's Mod Wiki

Revision Difference

WEAPON:CanSecondaryAttack#528306

<function name="CanSecondaryAttack" parent="WEAPON" type="hook"> <ishook>yes</ishook> <description>Helper function for checking for no ammo.</description> <realm>Shared</realm> <rets> <ret name="" type="boolean">Can use secondary attack</ret> </rets> </function> <example> <description>As defined in weapon_base</description> <code> function SWEP:CanSecondaryAttack() if ( self.Weapon:Clip2() <= 0 ) then if ( self:Clip2() <= 0 ) then self.Weapon:EmitSound( "Weapon_Pistol.Empty" ) self.Weapon:SetNextSecondaryFire( CurTime() + 0.2 ) self:EmitSound( "Weapon_Pistol.Empty" ) self:SetNextSecondaryFire( CurTime() + 0.2 ) return false end return true end </code> </example>