Garry's Mod Wiki

Revision Difference

WEAPON:TakeSecondaryAmmo#512179

<function name="TakeSecondaryAmmo" parent="WEAPON" type="hook">⤶ <ishook>yes</ishook>⤶ <description>A convenience function to remove secondary ammo from clip.</description>⤶ <realm>Shared</realm>⤶ <args>⤶ <arg name="amount" type="number">How much of secondary ammo to remove</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>As defined in weapon_base</description>⤶ <code>⤶ function SWEP:TakeSecondaryAmmo( num )⤶ ⤶ -- Doesn't use clips⤶ if ( self.Weapon:Clip2() &amp;lt;= 0 ) then ⤶ ⤶ if ( self:Ammo2() &amp;lt;= 0 ) then return end⤶ ⤶ self.Owner:RemoveAmmo( num, self.Weapon:GetSecondaryAmmoType() )⤶ ⤶ return end⤶ ⤶ self.Weapon:SetClip2( self.Weapon:Clip2() - num ) ⤶ ⤶ end⤶ </code>⤶ ⤶ </example>