Hello, I saw this on a server I use to play on and want to know if this is a good command processor...
Код:
// USRP command processor
#define USRP:%1(%2) \
forward u_%1(%2); \
public u_%1(%2)
public OnPlayerCommandText(playerid, cmdtext[])
{
new s = strlen(cmdtext);
if(!s || s == 1) return SendClientMessage(playerid, COLOR_GRAD2, "Please enter a valid command to use, this command is invalid.");
new f[32], c[128], e = strfind(cmdtext, " ", true), p = e;
if(e == -1) { p = s; c = "\1"; }
else {
while(cmdtext[e] == ' ') { e++; }
strmid(c, cmdtext, e, s, 128);
}
if(e == s) { c = "\1"; }
strmid(f, cmdtext, 1, p, 32);
for(new x = 0; x < p; x++) { f[x] = tolower(f[x]); }
format(f, sizeof(f), "u_%s", f);
if(!CallLocalFunction(f, "is", playerid, c)) return SendClientMessage(playerid, COLOR_GRAD2, "The command you entered is invalid, or missing a parameter");
return 1;
}
It must be slower than other processors because there are loops,string arrays,etc and when you use this script in multiple scripts you will have a bug that tells not a valid command even its valid.So leave that to the programmer.
And we don't need a cmd processor I guess.We have ZCMD which is fastest.You can win only if you get your code to be faster than other command processors.