From GMod Wiki
Event Hook
|
Hook Name | TakePrimaryAmmo
|
Syntax | SWEP:TakePrimaryAmmo( Integer num )
|
Description | Takes desired ammo from player's primary ammo.
|
Returns | Nil
|
Lua State |
|
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
Description | N/A |
Used on |
|
Code |
| This 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. | |
Output | N/A |
Additiona Notes
- You can override it to specify your own conditions.
- To use it as such simply call self:TakePrimaryAmmo()
See Also