Are there any negative side effects to setting hooks this way?
#9
There is another solution. You can store all callbacks in a hooks table, and register all callbacks from this table, for example:
Code:
hooks={} function hooks.tick(e,d) -- Will be registered as HOOK_TICK hook.   -- Do something cool return ... -- Return something cool end function Initialize(Plugin) Plugin:SetName("SomeCoolPlugin") Plugin:SetVersion(1)   if hooks then     for k,v in pairs(hooks) do       cPluginManager.AddHook(cPluginManager["HOOK_"..string.upper(k)], v)     end   end PLUGIN = Plugin -- NOTE: only needed if you want OnDisable() to use GetName() or something like that   if commands then     for k,v in pairs(commands) do       cPluginManager.BindCommand(unpack(v))     end   end LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) return true end function OnDisable() LOG(PLUGIN:GetName() .. " is shutting down...") end
Reply
Thanks given by:


Messages In This Thread
RE: Are there any negative side effects to setting hooks this way? - by TC1061 - 01-09-2018, 03:15 AM



Users browsing this thread: 1 Guest(s)