04.05.2013, 03:25
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;
}

