04.02.2014, 16:34
It happens because string "/me" is prefix of string "/me2". So when you compare first three symbols in "/me" and "/me2" it says that they are equal. It's better for you to use command processors to avoid that.
But if you don't want to use them, a simple fix is to swap the conditions like this:
But if you don't want to use them, a simple fix is to swap the conditions like this:
pawn Код:
if(!strcmp(cmdtext, "/me2", true, 4))
{
if(!cmdtext[4])
{
SendClientMessage(playerid, COLOR_YELLOW2, "** Usage: /me2 <Message>");
SendClientMessage(playerid, COLOR_YELLOW2, "* Displays the specified chat message to all players (in lime).");
return 1;
}
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "*** %s (ID:%d) %s", str,playerid,cmdtext[4]);
SendClientMessageToAll(COLOR_LIME, str);
return 1;
}
if(!strcmp(cmdtext, "/me", true, 3))
{
if(!cmdtext[3])
{
SendClientMessage(playerid, COLOR_YELLOW2, "** Usage: /me <Message>");
SendClientMessage(playerid, COLOR_YELLOW2, "* Displays the specified chat message to all players (in pink).");
return 1;
}
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "*** %s (ID:%d) %s", str,playerid,cmdtext[4]);
SendClientMessageToAll(COLOR_PINK, str);
return 1;
}