Weapon.GetPrimaryAmmoType

From GMod Wiki

Jump to: navigation, search


Function
Syntax Weapon:GetPrimaryAmmoType( )
Description:
Returns the type of ammo that the weapon's primary fire takes.
Returns: Number
In Object: Weapon
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Weapon.GetPrimaryAmmoType]Weapon.GetPrimaryAmmoType [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


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox