
local tblAllHooks = {}

hooks = {}

function hooks.Add(strEvent, vHookID, fCallback)
    local tblHooks = tblAllHooks[strEvent] or {}
    tblAllHooks[strEvent] = tblHooks
    
    tblHooks[vHookID] = fCallback
end

function hooks.Remove(strEvent, vHookID)
    local tblHooks = tblAllHooks[strEvent]
    
    if tblHooks then
        tblHooks[vHookID] = fCallback
    end
end

function hooks.Call(strEvent, ...)
    local tblHooks = tblAllHooks[strEvent]
    
    if tblHooks then
        for vID, fHook in pairs(tblHooks) do
            local bOkay, strErr = pcall(fHook, ...)
            
            if not bOkay then
                _HookErr(vID, strErr)
                tblHooks[vID] = nil
            end
        end
    end
end
