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)
argCount[MAX_PLAYERS], argData[MAX_PLAYERS][MAX_ARGPARAMETRS][96];
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;
}
#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();
ZCMD is slower than this because it is safe, all you have done is removed all security in the name of speed.
|