Garry's Mod Wiki



  ENTITY:TriggerOutput( string output, Entity activator, string data = "nil" )


Triggers all outputs stored using ENTITY:StoreOutput.


1 string output
Name of output to fire
2 Entity activator
Activator entity
3 string data = "nil"
The data to give to the output.


For engine entities you can use Entity:Fire to hook outputs. This example hooks all trigger_teleport

local function SetupMapLua() MapLua = ents.Create( "lua_run" ) MapLua:SetName( "triggerhook" ) MapLua:Spawn() for k, v in pairs( ents.FindByClass( "trigger_teleport" ) ) do print( v ) v:Fire( "AddOutput", "OnStartTouch triggerhook:RunPassedCode:hook.Run( 'OnTeleport' ):0:-1" ) end end hook.Add( "InitPostEntity", "SetupMapLua", SetupMapLua ) hook.Add( "PostCleanupMap", "SetupMapLua", SetupMapLua ) hook.Add( "OnTeleport", "TestTeleportHook", function() local activator, caller = ACTIVATOR, CALLER print( activator, caller ) end )
Output: When player touches trigger_teleport this will be printed in the console:

Player [1][Player1] Entity [3][trigger_teleport]

Special Pages



Render Time: 27ms

DB GetPage 4
Generate Html 6
SaveChanges (1) 7
Render Body 0
Render Sidebar 7