hook.Call

From Garry's Mod
Revision as of 15:25, 24 January 2014 by Robotboy655 (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

vararg args

The arguments to be passed to the functions

Returns

any

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