Hook

From GMod Wiki

Jump to: navigation, search


Library Functions

Shared

NewerShared.png hook.Add
NewerShared.png hook.Call
NewerShared.png hook.GetTable
NewerShared.png hook.Remove

Hooks

A Hook is function that is called when an event happens. There can be an unlimited amount of Hooks hooked to one event when called with hook.Add, but only one hook when overriding the event's function such as GM:PlayerSpawn.

Example:

DescriptionThis would call the function NotifyOfSpawn() in the event of a player spawning.
Used onNewerShared.png
Code
 
function NotifyOfSpawn(ply)
    print("The player "..ply:Nick().." spawned.")
end
 
hook.Add( "PlayerSpawn", "PlayerSpawnMessages", NotifyOfSpawn )
 
OutputN/A
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox