hook.Call

From Garry's Mod
Revision as of 18:19, 11 April 2013 by Tgp1994 (Talk | contribs)
Jump to: navigation, search
 hook.Call( )

Contents

Description

Calls hooks associated with the hook name
Calls all hooks until one returns something other than nil then returns that data.

Arguments

string hookName

The hook name.

Arguments

table gamemodeTable

If the gamemode is specified, the gamemode hook will be called, otherwise not.

Arguments

number args

The arguments to be passed to the functions.

Returns

number

return data from hook's call

Examples

Example

Runs function DoSomething, which eventually calls a hook "DoneDoingSomething", triggering the hooked function DoSomethingElse.

function DoSomething()
    --Does something
    hook.Call("DoneDoingSomething")
end

function DoSomethingElse()
    --Does something else, once the hook DoneDoingSomething is called.
    print("Done!")
end

hook.Add("DoneDoingSomething", "Does something else", DoSomethingElse)

DoSomething()

Output:

Done!
Personal tools
Navigation