Garry's Mod Wiki

hook

The hook library allows you to add hooks called by the game engine, allowing multiple scripts to modify game function.

Methods

hook.Add( string eventName, any identifier, function func )
Add a hook to be called upon the given event occurring.
vararg hook.Call( string eventName, table gamemodeTable = nil, vararg args = nil )
Calls all hooks associated with the given event until one returns something other than nil, and then returns that data. In almost all cases, you should use hook. Run instead - it calls hook. Call internally but supplies the gamemode table by itself, making your code neater.
Returns a list of all the hooks registered with hook. Add.
hook.Remove( string eventName, any identifier )
Removes the hook with the supplied identifier from the given event.
any hook.Run( string eventName, vararg args )
Calls all hooks associated with the given event until one returns something other than nil and then returns that data. If no hook returns any data, it will try to call the GAMEMODE:<eventName>; alternative, if one exists. This function internally calls hook. Call. See also: gamemode. Call - same as this, but does not call hooks if the gamemode hasn't defined the function.