From GMod Wiki
Revision as of 15:38, 18 April 2011 by Lexi
hook.Add( String hook, String unique_name, Function hook_func )
Where is this used?
|Hook an event to a function|
|Part of Library:||Hook|
|BBCode Link:||[b][url=http://wiki.garrysmod.com/?title=Hook.Add]Hook.Add [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]|
- The unique name is to ensure that the hook is only hooked once, even if the code is loaded multiple times, it also serves to delete hooks with hook.Remove.
- There are no restrictions on unique names, so be descriptive! "Addonname's PlayerDeath hook" is more descriptive than "mplydth" and will help people diagnose problems if your code ever breaks.
- Get a list of hooks from Gamemode Hooks.
- If the hook returns a value which is not nil the other hooks and gamemode code will not be called.