SWEP.TakePrimaryAmmo

From GMod Wiki

Revision as of 18:20, 7 June 2010 by Crazy Quebecer (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Event Hook
Hook NameTakePrimaryAmmo
SyntaxSWEP:TakePrimaryAmmo( Integer num )
DescriptionTakes desired ammo from player's primary ammo.
ReturnsNil
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=SWEP.TakePrimaryAmmo]SWEP.TakePrimaryAmmo [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]

Definition of the function

Because it is a convenience function, it is defined by the game.

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

Examples

DescriptionN/A
Used onNewerMissing.png
Code
LuaIco3.pngThis page needs an example to demonstrate the item detailed on this page. See how to make one here.
See more articles that need examples here.
OutputN/A


Additiona Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox