Gamemode.WeaponEquip

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameWeaponEquip
SyntaxGM:WeaponEquip( Weapon Weapon )
DescriptionCalled as a weapon entity is picked up by a player.
ReturnsNil
Lua StateNewerServer.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.WeaponEquip]Gamemode.WeaponEquip [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]

Examples

DescriptionWhen a player picks up a weapon, they are told what they just picked up.
Used onNewerServer.png
Code
hook.Add("WeaponEquip", "Grabbin.Peelz", function(weapon)
 
	-- put everything inside this timer so it's called on the next frame.
	timer.Simple(0, function() 
 
		local ply = weapon:GetOwner() -- no longer a null entity.
 
		ply:PrintMessage(3, "Picked Up: "..weapon:GetClass()) -- inform the player.
 
	end) 	
end)
OutputPicked Up: <weapon name> Printed In The Players Chat


Additional Notes


Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox