You maybe also know this, you write a plugin and notice that you are constantly repeate your code.
Some people use their their own include files, or use packages available in the community to compensate that.
Well, but what if you have many plugins that are based on events or chathooks?.
You create an Commandlistener, Hookevent etc in all your plugins.
You again write the same structures and callbacks again and again for any plugin you use.
Many of you may know the wonderful Smlib.
This package tries to fix the first problem mentioned, but what is with the second?
I begun to write a Basehook - plugin for myself which "hooks" often used functions like: chat, round-events, death-events, teamjoin, and other things which can be useful.
The advantage of this is a better structure in my plugins.
Take a look at this theoretical example.
Before
PHP Code:
public OnPluginStart() { AddCommandListener(Listener, "say"); AddCommandListener(Listener, "say_team"); }
public Action:Listener(client, const String:command[], argc) { decl String:message[192];
public Action:Basehook_OnSay(client, const String:message[], len) { // Do something with the message
return Plugin_Continue; }
For larger scripts with a lot of events that can mean a huge difference in lines.
The disadvantages are that i always must run two plugins.
Whether it has a major impact on performance, well i have not tested extensively yet.
Maybe one of you knows more about whether the above makes sense, and if so how.
It must indeed have a good reason why not everyone implements this basic idea for himself.