Garry's Mod Wiki



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


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, vararg args )
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.
table hook.GetTable()
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 hooks associated with the given event. Calls all hooks 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.

Special Pages



Render Time: 20ms

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