15.10.2012, 18:32
r_commands - Clear and fast command processor!
Hello all,
This is my first command processor, very fast and simple.
I'm building a big library and this is the smallest part of the library.
Usage
Simple, here two examples:
pawn Code:
COMMAND:test(playerid, params[]) {
}
CMD:test2(playerid, params[]) {
}
pawn Code:
command_test(playerid, "params");
I maked two simple callbacks to full command control:
pawn Code:
forward OnPlayerCommandSent(playerid, cmdtext[]);
forward OnPlayerCommandExecuted(playerid, cmdtext[], bool:success);
Test script:
pawn Code:
#include <r_commands>
#include <zcmd>
#define FILTERSCRIPT
public OnFilterScriptInit()
{
new
tick = GetTickCount(),
tick2;
for (new i = 0; i != 100000; i ++) // 100000 times
{
command_test(0, "\1");
}
tick2 = GetTickCount() - tick;
printf("rcmd: %d ms", tick2);
tick = GetTickCount();
for (new i = 0; i != 100000; i ++) // 100000 times
{
cmd_test(0, "\1");
}
tick2 = GetTickCount() - tick;
printf("zcmd: %d ms", tick2);
return 1;
}
//==============================================================================
CMD:test(playerid, params[]) { //RCmd
for (new i = 0; i < 500; i ++)
{
}
return 1;
}
COMMAND:test(playerid, params[]) { //ZCmd
for (new i = 0; i < 500; i ++)
{
}
return 1;
}
Quote:
rcmd: 2187 ms zcmd: 2253 ms -- zcmd-rcmd = 2253-2187 = 66ms |
Download
Pastebin: http://pastebin.com/BP9wjpAY
Suggestions
* Use ****** sscanf2 plugin for make more than one parameter!
* Don't write the command name in big letters
Enjoy!