WEAPON:TakePrimaryAmmo

From Garry's Mod
Jump to: navigation, search
 WEAPON:TakePrimaryAmmo( )

Contents

Description

A convenience function to remove primary ammo from clip.

Arguments

number amount

Amount of primary ammo to remove

Examples

Example

As defined in weapon_base

function SWEP:TakePrimaryAmmo( num )
	
	-- Doesn't use clips
	if ( self.Weapon:Clip1() <= 0 ) then 
	
		if ( self:Ammo1() <= 0 ) then return end
		
		self.Owner:RemoveAmmo( num, self.Weapon:GetPrimaryAmmoType() )
	
	return end
	
	self.Weapon:SetClip1( self.Weapon:Clip1() - num )	
	
end


Personal tools
Navigation