Player.GetAmmoCount

From GMod Wiki

Revision as of 14:52, 13 September 2009 by UnrealomegaBot (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax Player:GetAmmoCount( String ammo_type )
Description:
Retrieve the amount of ammo a player has.
Returns: Integer
In Object: Player
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Player.GetAmmoCount]Player.GetAmmoCount [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionShows how to use this function to get the total ammo for the currently active weapon.
Used onNewerClient.png
Code
// This returns the total ammo for the currently active weapon.
function GetCurWepTotalAmmo()
	MySelf = LocalPlayer()
 
	actwep = MySelf:GetActiveWeapon()
	if ( ! actwep ) then return -1 end
 
	return MySelf:GetAmmoCount(actwep:GetPrimaryAmmoType())
end
OutputN/A
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox