Garry's Mod Wiki

Entity:Fire

  Entity:Fire( string input, string param = nil, number delay = 0, Entity activator = nil, Entity caller = nil )

Description

Fires an entity's input, conforming to the map IO event queue system. You can find inputs for most entities on the Valve Developer Wiki

See also Entity:Input for a function that bypasses the event queue and GM:AcceptInput.

Arguments

1 string input
The name of the input to fire
2 string param = nil
The value to give to the input, can also be a number or a boolean.
3 number delay = 0
Delay in seconds before firing
4 Entity activator = nil
The entity that caused this input (i.e. the player who pushed a button)
5 Entity caller = nil
The entity that is triggering this input (i.e. the button that was pushed)

Example

If you are looking at a door, this will lock it

// Entity(1) is considered a player in this example local tr = Entity( 1 ):GetEyeTrace() local ent = tr.Entity if IsValid( ent ) then ent:Fire("Lock") end