Garry's Mod Wiki

GM:AcceptInput

  boolean GM:AcceptInput( Entity ent, string input, Entity activator, Entity caller, any value )

Description

Called when a map I/O event occurs.

See also Entity:Fire and Entity:Input for functions to fire Inputs on entities.

Arguments

1 Entity ent
Entity that receives the input
2 string input
The input name. Is not guaranteed to be a valid input on the entity.
3 Entity activator
Activator of the input
4 Entity caller
Caller of the input
5 any value
Data provided with the input. Will be either a string, a number, a boolean or a nil.

Returns

1 boolean
Return true to prevent this input from being processed. Do not return otherwise.

Example

This would block any input that the lua_run entity would receive.

hook.Add( "AcceptInput", "BlockLuaRun", function( ent, name, activator, caller, data ) if ( ent:GetClass() == "lua_run" ) then return true end end )

Example

Block the Open/Close input on doors.

local DoorClasses = { ["func_door"] = true, ["func_door_rotating"] = true } local BlockedInputs = { ["Open"] = true, ["Close"] = true } hook.Add( "AcceptInput", "BlockDoors", function( ent, name, activator, caller, data ) if ( BlockedInputs[name] and DoorClasses[ent:GetClass()] ) then return true end end )