SA-MP Forums Archive
[Include] fastCommands 0.4.2b | Fast and Simple Co - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] fastCommands 0.4.2b | Fast and Simple Co (/showthread.php?tid=508032)



fastCommands 0.4.2b | Fast and Simple Co - RCON1 - 20.04.2014

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: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/


Re: fastCommands 0.4.2b | Fast and Simple Co - Niko_boy - 20.04.2014

it seem good if its really that fast, not sure if only being fast makes it good >.>
However i will still prefer sscanf over this arguments system..


Re: fastCommands 0.4.2b | Fast and Simple Co - Ada32 - 20.04.2014

what's bothering me is we have too many people trying to do their own thing instead of contributing to existing scripts (which is key to community development)


Re: fastCommands 0.4.2b | Fast and Simple Co - Pottus - 20.04.2014

Quote:
Originally Posted by ******
Посмотреть сообщение
ZCMD is slower than this because it is safe, all you have done is removed all security in the name of speed.
I'd rather have security than worry about speed loss furthermore how to expect anyone to ever run as many commands as the test? It is simply impossible and therefore the difference is/would be too small to notice.


Re: fastCommands 0.4.2b | Fast and Simple Co - RCON1 - 20.04.2014

******, what security is zcmd which no fcmd?


Re: fastCommands 0.4.2b | Fast and Simple Co - RCON1 - 20.04.2014

these examples do not cause any error

Test (2)



The library is on my server for several days (05/04/2014) has so far not caused any crash.