Garry's Mod Wiki

Revision Difference

WEAPON:CanPrimaryAttack#523771

<function name="CanPrimaryAttack" 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 primary attack</ret> </rets> </function> <example> <description>As defined in weapon_base</description> <code> function SWEP:CanPrimaryAttack() if ( self.Weapon:Clip1() &lt;= 0 ) then if ( self.Weapon:Clip1() <= 0 ) then self:EmitSound( "Weapon_Pistol.Empty" ) self:SetNextPrimaryFire( CurTime() + 0.2 ) self:Reload() return false end return true end </code> </example>