Garry's Mod Wiki

Revision Difference

WEAPON:TakePrimaryAmmo#553181

<function name="TakePrimaryAmmo" parent="WEAPON" type="hook"> <ishook>yes</ishook>⤶ <description>A convenience function to remove primary ammo from clip.</description> <realm>Shared</realm> <args> <arg name="amount" type="number">Amount of primary ammo to remove</arg> </args> </function> <example> <description>As defined in weapon_base</description> <code> function SWEP:TakePrimaryAmmo( num ) -- Doesn't use clips if ( self.Weapon:Clip1() <= 0 ) then if ( self:Ammo1() <= 0 ) then return end self:GetOwner():RemoveAmmo( num, self.Weapon:GetPrimaryAmmoType() ) return end self.Weapon:SetClip1( self.Weapon:Clip1() - num ) end </code> </example>