Custom Hooks

How do I make custom hooks?

You make hooks using the hook.Call function. For example, if you wanted to call a “GainedLevel” hook on a random time when you hit a player, it would look like this:

[lua]function GainLevel(pl)
if math.random(1,50) == 50 then
hook.Call(“LevelGained”,nil,pl)
end
end
hook.Add(“ScalePlayerDamage”,“CallHook”,GainLevel)[/lua]

In the hook.Call, all arguments after the second are the arguments supplied in the hook.Add function; so in this instance, when we hooked into the “LevelGained” hook, we could get the player object of who was leveling up.

Awesome, thanks.

Alternately, if your hook is a gamemode function:

gamemode.Call( “Function Name” [, args… ] )