Garry's Mod Wiki



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


Triggers all outputs stored using ENTITY:StoreOutput.

ACTIVATOR / CALLER / TRIGGER_PLAYER globals are only available during execution, they are unset directly afterwards.


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() local MapLua = ents.Create( "lua_run" ) MapLua:SetName( "triggerhook" ) MapLua:Spawn() for _, v in ipairs( ents.FindByClass( "trigger_teleport" ) ) do 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: 30ms

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