Player.RemoveAmmo

From GMod Wiki

Jump to: navigation, search
Function
Syntax Player:RemoveAmmo( Integer amount, String ammo type )
Description:
Remove a specific type of ammo from a player.
Returns: nil
In Object: Player
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Player.RemoveAmmo]Player.RemoveAmmo [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionThis example removes one SMG bullet every second.
Used onNewerServer.png
Code
 
local Timer = 0
local function DrainSMGAmmo ()
	if (Timer < RealTime()) then
		for k,pl in pairs (player.GetAll()) do
			if pl:Alive() then
				pl:RemoveAmmo (1, "smg1")
			end
		end
 
		Timer = RealTime() + 1 -- Add one second
	end
end
 
hook.Add ("Think", "DSMGA", DrainSMGAmmo)
 
OutputN/A


Types

AR2 - Ammunition of the AR2/Pulse Rifle
AlyxGun - (name in-game "5.7mm Ammo")
Pistol - Ammunition of the 9MM Pistol 
SMG1 - Ammunition of the SMG/MP7
357 - Ammunition of the .357 Magnum
XBowBolt - Ammunition of the Crossbow
Buckshot - Ammunition of the Shotgun
RPG_Round - Ammunition of the RPG/Rocket Launcher
SMG1_Grenade - Ammunition for the SMG/MP7 grenade launcher (secondary fire)
SniperRound
SniperPenetratedRound - (name in-game ".45 Ammo")
Grenade - Note you must be given the grenade weapon (weapon_frag) before you can throw grenades.
Thumper - Ammunition cannot exceed 2 (name in-game "Explosive C4 Ammo")
Gravity - (name in-game "4.6MM Ammo")
Battery - (name in-game "9MM Ammo")
GaussEnergy 
CombineCannon - (name in-game ".50 Ammo")
AirboatGun - (name in-game "5.56MM Ammo")
StriderMinigun - (name in-game "7.62MM Ammo")
HelicopterGun
AR2AltFire - Ammunition of the AR2/Pulse Rifle 'combine ball' (secondary fire)
slam - Like Grenade, but for the Selectable Lightweight Attack Munition (S.L.A.M)

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox