[Include] r_commands - Clear and fast command processor!
#1


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[]) {

}
Also you can call the command public:
pawn Code:
command_test(playerid, "params");
CallBack(s)
I maked two simple callbacks to full command control:
pawn Code:
forward OnPlayerCommandSent(playerid, cmdtext[]);
forward OnPlayerCommandExecuted(playerid, cmdtext[], bool:success);
RCmd vs ZCmd
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;
}
Here the results:
Quote:

rcmd: 2187 ms
zcmd: 2253 ms

-- zcmd-rcmd = 2253-2187 = 66ms

As you see rcmd faster the zcmd in 66ms, and it's the very first version!

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!

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)