hook.Add
From GMod Wiki
Function | |
Syntax |
hook.Add( String hook, String unique_name, Function hook_func ) Where is this used? |
Description: | |
Hook an event to a function | |
Returns: | nil |
Part of Library: | Hook |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Hook.Add]Hook.Add [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Additional Notes
- 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.