ENT.Use

From GMod Wiki

Revision as of 17:06, 25 November 2011 by SiPlus (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Event Hook
Hook NameUse
SyntaxENT:Use( Entity activator, Entity caller[, Integer use_type β, Integer value β] )
DescriptionCalled when the a player presses the 'Use' key on the SENT.
ReturnsNil
Lua StateNewerServer.png
BBCode[b][url=wiki.garrysmod.com/?title=ENT.Use]ENT.Use [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionWhen a player uses the SENT, it will remove itself and the player will gain 5 HP.
Used onNewerServer.png
Code
 
function ENT:Use( activator, caller )
 
	self:Remove()
 
	if ( activator:IsPlayer() ) then
 
		// Give the collecting player some free health
		local health = activator:Health()
		activator:SetHealth( health + 5 )
 
	end
 
end
 
Outputmore health, less entity


Additional Info

SHARED | 0000000000000000 | 00000000000000000 | USE_OFF
SHARED | 0000000000000001 | 00000000000000001 | USE_ON
SHARED | 0000000000000002 | 00000000000000010 | USE_SET
SHARED | 0000000000000003 | 00000000000000011 | USE_TOGGLE

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox