24.02.2010, 17:00
You have to add
underneath
so you should get this
[Off-Topic]
DCMD is just the strcmp method but slightly different.
ZCMD truly is a completely different method (doesn't even use strcmp) so it only needs to be called once per OnPlayerCommandText, where as DCMD is checked and called for each command (until found that is)
Although I must say that ZCMD could easily be made to go faster
ZCMD -> http://zeex.pastebin.ca/1650602 (119 lines)
My version (11 lines)
example command
pawn Код:
new id = strval(tmp);
pawn Код:
tmp = strtok(cmdtext,idx);
pawn Код:
if(strcmp("/pm", cmd, true) == 0)
{
tmp = strtok(cmdtext,idx);
new id=strval(tmp);
if(!strlen(tmp) || strlen(tmp) > 5) {
SendClientMessage(playerid,COLOR_GREEN,"Usage: /pm [id] (Message)");
return 1;
}
[Off-Topic]
DCMD is just the strcmp method but slightly different.
ZCMD truly is a completely different method (doesn't even use strcmp) so it only needs to be called once per OnPlayerCommandText, where as DCMD is checked and called for each command (until found that is)
Although I must say that ZCMD could easily be made to go faster
ZCMD -> http://zeex.pastebin.ca/1650602 (119 lines)
My version (11 lines)
pawn Код:
#define Command(%1) forward CMD_%1(playerid,params[]);\
public CMD_%1(playerid,params[])
public OnPlayerCommandText(playerid,cmdtext[])
{
new tmp[128];
new space = strfind(cmdtext," ");
new cell;
format(tmp,space-1,cmdtext[1]);
while(tmp[cell])tmp[cell]=tolower(tmp[cell]),cell++;
format(tmp,128,"CMD_%s",tmp);
return CallLocalFunction(tmp,"is",playerid,cmdtext[space+1]);
}
pawn Код:
Command(test) //playerid and params[] are assumed
{
SendClientMessage(playerid,0xFFFFFFFF,"This is a test.");
return 1;
}