All pastes #420245 Raw Edit

Hook

public lua v1 · immutable
·published 2007-04-02 00:01 UTC
rendered paste body
hook = {}hook.Hooks = {}hook.Count = 0hook.ALL = 1hook.MSG = 2hook.PM = 3hook.JOIN = 4function hook.Call(typ, ...)	for k,v in hook.Hooks do		if v.type == typ or v.type == hook.ALL then			v.func(unpack(arg))		end	endendfunction hook.Add(func, typ, name)	typ = typ or hook.ALL	name = name or "hook"..hook.Count		if not table.haskey(hook.Hooks, name) hook.Count = hook.Count + 1 end		hook.Hooks[name] = {func = func, type = typ}endfunction hook.Remove(name)	table.remove(hook.Hooks, name)end