TOOL:LeftClick

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameLeftClick
SyntaxTOOL:LeftClick( TraceRes tr )
DescriptionCalled when the user left clicks.
ReturnsNil
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=TOOL:LeftClick]TOOL:LeftClick [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionIgnite the object in front of the player for a 1 minute burn.
Used onNewerShared.png
Code
function TOOL:LeftClick( tr )
 
	if (!tr.Entity) then return false end -- Is the trace an entity?
	if (!tr.Entity:IsValid() ) then return false end -- Is the entity valid?
	if (tr.Entity:IsPlayer()) then return false end -- Is the entity a player? We dont wanna burn players, if you want to burn them, remove this line.
	if (tr.Entity:IsWorld()) then return false end -- Is the entity an world entity? We dont wanna ruin the map.
 
	if ( CLIENT ) then return true end
 
	tr.Entity:Extinguish() -- Extinguish the fire on the entity,
	tr.Entity:Ignite( 60, 0 ) -- then add a new one for 60 seconds.
 
	return true
 
end
OutputN/A


Additional Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox