Gamemode.ContextScreenClick

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameContextScreenClick
SyntaxGM:ContextScreenClick( Vector aimvec, Integer mousecode, Boolean pressed, Player ply )
DescriptionCalled when player clicks with the context menu open.
ReturnsNil
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.ContextScreenClick]Gamemode.ContextScreenClick [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionPrints a message each time a player performs an action with the mouse.
Used onNewerServer.png
Code
hook.Add("ContextScreenClick","MousePressDebug", function( aimvec, mousecode, pressed, ply )
	local str = tostring(ply)
 
	if pressed then
		str = str.." pressed"
	else
		str = str.." released"
	end
 
	str = str.." the"
 
	if mousecode == MOUSE_LEFT then
		str = str.." left"
	elseif mousecode == MOUSE_RIGHT then
		str = str.." right"
	elseif mousecode == MOUSE_MIDDLE		
		str = str.." middle"
	end
 
	str = str.." mouse button!"
 
	print(str)
 
end)
OutputCrazy Quebecer pressed the the left mouse button!


DescriptionThe one expression version (because we can).
Used onNewerServer.png
Code
hook.Add("ContextScreenClick","MousePressDebug", function( aimvec, mousecode, pressed, ply )
	print(
			tostring(ply)..
			(
				(pressed and " pressed") or
				" released"
			)..
			(
				mousecode == MOUSE_LEFT and " the left" or
				mousecode == MOUSE_RIGHT and " the right" or
				mousecode == MOUSE_MIDDLE and " the middle" or
				" an undefined"
			)..
			" mouse button!"
		)
end)
 
OutputCrazy Quebecer released the the right mouse button!


Additional Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox