Command error message - not working perfect
#1

Ok so i have this command:

Код:
if(strcmp(cmd, "/showmembers", true) == 0 || strcmp(cmd, "/sm", true) == 0)
	{
		SendClientMessage(playerid, COLOR_GREEN, "__________ Online Members __________");
	    for(new i=0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
			    if(PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1)
			    {
				    if(PlayerInfo[i][pMember] == 1 || PlayerInfo[i][pLeader] == 1)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 2||PlayerInfo[playerid][pMember] == 2)
			    {
				    if(PlayerInfo[i][pMember] == 2 || PlayerInfo[i][pLeader] == 2)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 3||PlayerInfo[playerid][pMember] == 3)
			    {
				    if(PlayerInfo[i][pMember] == 3 || PlayerInfo[i][pLeader] == 3)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 4||PlayerInfo[playerid][pMember] == 4)
			    {
				    if(PlayerInfo[i][pMember] == 4 || PlayerInfo[i][pLeader] == 4)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 5||PlayerInfo[playerid][pMember] == 5)
			    {
				    if(PlayerInfo[i][pMember] == 5 || PlayerInfo[i][pLeader] == 5)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 6||PlayerInfo[playerid][pMember] == 6)
			    {
				    if(PlayerInfo[i][pMember] == 6 || PlayerInfo[i][pLeader] == 6)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 8||PlayerInfo[playerid][pMember] == 8)
			    {
				    if(PlayerInfo[i][pMember] == 8 || PlayerInfo[i][pLeader] == 8)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 9||PlayerInfo[playerid][pMember] == 9)
			    {
				    if(PlayerInfo[i][pMember] == 9 || PlayerInfo[i][pLeader] == 9)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 10||PlayerInfo[playerid][pMember] == 10)
			    {
				    if(PlayerInfo[i][pMember] == 10 || PlayerInfo[i][pLeader] == 10)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 11||PlayerInfo[playerid][pMember] == 11)
			    {
				    if(PlayerInfo[i][pMember] == 11 || PlayerInfo[i][pLeader] == 11)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 12||PlayerInfo[playerid][pMember] == 12)
			    {
				    if(PlayerInfo[i][pMember] == 12 || PlayerInfo[i][pLeader] == 12)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 13||PlayerInfo[playerid][pMember] == 13)
			    {
				    if(PlayerInfo[i][pMember] == 13 || PlayerInfo[i][pLeader] == 13)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 14||PlayerInfo[playerid][pMember] == 14)
			    {
				    if(PlayerInfo[i][pMember] == 14 || PlayerInfo[i][pLeader] == 14)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
				else if(PlayerInfo[playerid][pLeader] == 15||PlayerInfo[playerid][pMember] == 15)
			    {
				    if(PlayerInfo[i][pMember] == 15 || PlayerInfo[i][pLeader] == 15)
				    {
						GetPlayerName(i, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "{ffffff}» %s • Rank: {00bfff}%d{ffffff}.", giveplayer,PlayerInfo[i][pRank]);
						SendClientMessage(playerid, COLOR_GREY, string);
					}
				}
			}
		}
	}
At the end of OnPlayerCommandText i have:

Код:
return SendClientMessage(playerid, COLOR_WHITE, "Error: Unknown command");
}
Problem: When i use /showmembers, the command works but it also shows "Error: Unknown command".
I tried with others commands and they work fine, only this command seems to have this problem.
Reply
#2

When you have finished a command (like, send the player a message etc), add "return 1;".
Otherwise the script will continue running and at last reach your "return unknown command" thingy.
Reply
#3

Oh, you're right. Thanks for help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)