09.02.2009, 15:32
EDIT: MAY LOOK UN-INDENTED BUT IT IS INTENTED
Hi, Im making an RP,
And im making a pilot school, Ive done the mapicon ect i just need the cmds,
I have done an /requestland, That returns as, Usage: /requestland [ls/sf/lv]
But when i say /requestland ls, That returns as: Unknown Command,
And it shouldnt
MyCode:
Compiles fine.
Hi, Im making an RP,
And im making a pilot school, Ive done the mapicon ect i just need the cmds,
I have done an /requestland, That returns as, Usage: /requestland [ls/sf/lv]
But when i say /requestland ls, That returns as: Unknown Command,
And it shouldnt
MyCode:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
if(strcmp(cmdtext, "/requestland", true) == 0)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /requestland [ls/sf/lv]");
return 1;
}
if(!strcmp(result,"ls",true))
{
SendClientMessageToAll(COLOR_GREY, "%s to LS ATC, %s is requesting landing.");
}
else if(!strcmp(result,"sf",true))
{
SendClientMessageToAll(COLOR_GREY, "%s to SF ATC, %s is requesting landing.");
}
else if(!strcmp(result,"lv",true))
{
SendClientMessageToAll(COLOR_GREY, "%s to LV ATC, %s is requesting landing.");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /requestland [ls/sf/lv]");
}
return 1;
}
if(strcmp(cmdtext, "/runwaycheck", true) == 0)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /runwaycheck [ls/sf/lv]");
return 1;
}
if(!strcmp(result,"ls",true))
{
SendClientMessageToAll(COLOR_GREY, "%s to LS ATC, %s is requesting runway clearance.");
}
else if(!strcmp(result,"sf",true))
{
SendClientMessageToAll(COLOR_GREY, "%s to SF ATC, %s is requesting runway clearance.");
}
else if(!strcmp(result,"lv",true))
{
SendClientMessageToAll(COLOR_GREY, "%s to LV ATC, %s is requesting runway clearance.");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /runwaycheck [ls/sf/lv]");
}
return 1;
}
return 0;
}
stock strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}