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;
}
SendClientMessageToAll(COLOR_GREY, "%s to LS ATC, %s is requesting landing."); |
new string[128], sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof sendername);
format(string, sizeof(string), "%s to LS ATC, %s is requesting landing.", sendername);
SendClientMessageToAll(COLOR_GREY, string);
Originally Posted by SpiderPork
Quote:
You need to create a format(string, sizeof(string), "%s to LS ATC, %s is requesting landing.", blah blah); Then add it to SendClientMessageToAll. So it should look like this: pawn Код:
|
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;
}
new tmpstr[5];
format(tmpstr,sizeof(tmpstr),"%s",cmdtext[strlen("/command")+1]);
if(!strlen(tmpstr))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /runwaycheck [ls/sf/lv]");
return 1;
}