[Include] fastCommands 0.4.2b | Fast and Simple Co
#1

fastCommands -Fast and Simple Command Processor

Info: Include fCmd is an improved version of cmd (to Zeex) in more features and faster performance. Include used in the same way as an ordinary cmd.

Ver:0.4.2b


Functions:


pawn Код:
native ARG<slot>; //(string) (slot = argument);
    native ARG_FLOAT<slot>; //(float) (slot = argument);
    native ARG_INT<slot>; //(int) (slot = argument);
    native ARG_COUNT<>;//number of arguments in the command
    native Command_Alt(fromCmd, toCmd);//Dodawanie alternatywnej komendy (np /v to /cars)
Cons:
Код:
argCount[MAX_PLAYERS], 
argData[MAX_PLAYERS][MAX_ARGPARAMETRS][96];
Benefits:
  • Execution speed.
    No need to use sscanf for most commands with parameters.
    Faster write a command with arguments (and they do not need to create local variables).
Example of using command with an argument:


pawn Код:
CMD:sping(playerid, params[])
{
    if(ARG_COUNT<> <= 0)
    {
        SendClientMessage(playerid, 0xFF0000FF, "Użyj /sping <id gracza>");
        return 1;
    }
   
    if(!IsPlayerConnected(ARG_INT<0>))
    {
        SendClientMessage(playerid, 0xFF0000FF, "The given player is not connected");
        return 1;
    }
   
    new str[32];
    format(str, sizeof(str), "Ping player id %d is %dms", ARG_INT<0>, GetPlayerPing(ARG_INT<0>));
    SendClientMessage(playerid, 0x00FF00FF, str);
    return 1;
}
Download: Click Me!


Contrast of speed of operation:
Код:
#1[fastCmd]: 25ms
#2[fastCmd]: 25ms
#3[fastCmd]: 25ms
#4[fastCmd]: 24ms
#5[fastCmd]: 24ms
#6[fastCmd]: 26ms

#1[zcmd]: 357ms
#2[zCmd]: 344ms
#3[zCmd]: 347ms
#4[zCmd]: 346ms
#5[zCmd]: 349ms
#6[zCmd]: 345ms
Код:
 new t;

t = tickcount();
for(new i;i<50000;i++)
{
CallLocalFunction("OnPlayerCommandText", "dd", 0, "/mst");
}
printf("#1[%s]: %dms", type, tickcount() - t);

t = tickcount();
for(new i;i<50000;i++)
{
CallLocalFunction("OnPlayerCommandText", "dd", 0, "/mst fsdfsdf");
}
printf("#2[%s]: %dms", type, tickcount() - t);

t = tickcount();
for(new i;i<50000;i++)
{
CallLocalFunction("OnPlayerCommandText", "dd", 0, "/dsd");
}
printf("#3[%s]: %dms",type, tickcount() - t);

t = tickcount();
for(new i;i<50000;i++)
{
CallLocalFunction("OnPlayerCommandText", "dd", 0, "/gdfgdfgdgdgdg");
}
printf("#4[%s]: %dms",type, tickcount() - t);


t = tickcount();
for(new i;i<50000;i++)
{
CallLocalFunction("OnPlayerCommandText", "dd", 0, "/gdfgdfgdgdgdg sdfgdfgdfg");
}
printf("#5[%s]: %dms",type, tickcount() - t);

t = tickcount();
for(new i;i<50000;i++)
{
CallLocalFunction("OnPlayerCommandText", "dd", 0, "/sping 0");
}
printf("#6[%s]: %dms",type, tickcount() - t);

t = tickcount();
Sorry for my English, the original topic http://pawno.pl/index.php?/topic/252...and-processor/
Reply


Messages In This Thread
fastCommands 0.4.2b | Fast and Simple Co - by RCON1 - 20.04.2014, 10:37
Re: fastCommands 0.4.2b | Fast and Simple Co - by Niko_boy - 20.04.2014, 11:25
Re: fastCommands 0.4.2b | Fast and Simple Co - by Ada32 - 20.04.2014, 12:40
Re: fastCommands 0.4.2b | Fast and Simple Co - by Pottus - 20.04.2014, 12:54
Re: fastCommands 0.4.2b | Fast and Simple Co - by RCON1 - 20.04.2014, 14:05
Re: fastCommands 0.4.2b | Fast and Simple Co - by RCON1 - 20.04.2014, 14:21

Forum Jump:


Users browsing this thread: 1 Guest(s)