SWEP.ContextScreenClick

From GMod Wiki

Revision as of 03:37, 25 October 2009 by Crazy Quebecer (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Event Hook
Hook NameContextScreenClick
SyntaxSWEP:ContextScreenClick( Vector AimVector, Integer MouseCode, Boolean Pressed, Player Ply )
DescriptionCalled when the Context (C) Menu is open and the player has clicked the screen.
ReturnsNil
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=SWEP.ContextScreenClick]SWEP.ContextScreenClick [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]

Example

DescriptionCreates an entity where you're clicking when the context menu is enabled.
Used onNewerServer.png
Code
function SWEP:ContextScreenClick( aimvec, mousecode, pressed, ply )
	if pressed then -- If it was pressed, not released.
		if mousecode == 107 then -- Left click
			local zombie = ents.Create("npc_zombie")
			zombie:SetPos(ply:GetEyeTrace().HitPos)
			zombie:Spawn()
		elseif mousecode == 108 then -- Right click
			local wep = ents.Create(self:GetClass()) -- Spawn out weapon
			wep:SetPos(ply:GetEyeTrace().HitPos)
			wep:Spawn()
		end
	end
end
OutputA zombie on left click and the weapon you're using on right click.
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox