[Help] Command: /amembers
#1

Hi, i need help with a command. I want an administrator command: /amembers [Faction Number]. If the administrator uses it, it will appears the member who are online of that faction. Example: /amembers 1, will appears something like this:
Members Online: SAPD
Member 1
Member 2
Etc..

But i don't know why it doesn't work. If you are in the National Guard and you use /amembers 1 to see SAPD's online, you will appear there :S I need help. This command is for the 0.3
Here is:
Код:
	if(strcmp(cmd, "/amembers", true) == 0)
{
	  if(IsPlayerConnected(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USA: /amembers [Faction number]");
				return 1;
			}
			new miembrofaccion = strval(tmp);
			if (miembrofaccion == 1)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 1");
          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
			if (miembrofaccion == 2)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 2");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
			if (miembrofaccion == 3)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 3");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 4)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 4");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 5)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 5");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 5 || PlayerInfo[playerid][pLeader] == 5)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 6)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 6");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 6 || PlayerInfo[playerid][pLeader] == 6)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 7)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 7");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 7 || PlayerInfo[playerid][pLeader] == 7)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 8)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 8");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 9)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 9");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 10)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 10");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 10 || PlayerInfo[playerid][pLeader] == 10)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 11)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 11");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 11 || PlayerInfo[playerid][pLeader] == 11)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 12)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 12");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 12 || PlayerInfo[playerid][pLeader] == 12)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 13)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 13");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 13 || PlayerInfo[playerid][pLeader] == 13)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 14)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 14");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 14 || PlayerInfo[playerid][pLeader] == 14)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 15)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 15");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 15 || PlayerInfo[playerid][pLeader] == 15)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 16)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 16");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 16 || PlayerInfo[playerid][pLeader] == 16)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
						if (miembrofaccion == 17)
			{
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
          SendClientMessage(playerid, 0x808000AA, "- Members Online of: Faction 17");

          for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if (IsPlayerConnected(i))
						{
							if(PlayerInfo[playerid][pMember] == 17 || PlayerInfo[playerid][pLeader] == 17)
  						{
  						GetPlayerName(i, sendername, sizeof(sendername));
  						format(string, 256, "%s", sendername);
  						SendClientMessage(playerid, COLOR_LIGHTRED, string);
  							}
						}
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
				}
				return 1;
			}
 		}
 		return 1;
}
Reply
#2

So the problem is that your name also pops up in every faction you want the players dispalyed of ?
Everything else is fine?
There must be something wrong with your conditions....
Reply
#3

For example. You are in the faction 3. If i use /amembers 1, you will appear there :S and if i use /amembers 3 you won't appear there.
Reply
#4

This command is poorly scripted.

pawn Код:
if(!strcmp(cmdtext[1],"amembers",true,8))
{
  if(PlayerInfo[playerid][Admin]<1)return SendClientMessage(playerid, COLOR_GRAD1, "You are not autorized to use this command!");
  if(!cmdtext[10])return SendClientMessage(playerid,COLOR_WHITE,"USA: /aMembers [Faction Number]");
  if(strval(cmdtext[10])>MAXIMUM)return SendClientMessage(playerid,COLOR_WHITE,"USA: /aMembers <1-MAXIMUM>"); //Change MAXIMUM to the highest faction number
  new tempstr[128];
  new tempint = strval(cmdtext[10]);
  format(tempstr,sizeof(tempstr),"- Members Online in Faction %d",tempint);
  SendClientMessage(playerid,0x808000FF,tempstr);
  for(new player; player<MAX_PLAYERS; player++)
  {
    if(!IsPlayerConnected(player))continue;
    if((PlayerInfo[player][pMember]==tempint)||(PlayerInfo[player][pLeader]==tempint))
    {
      GetPlayerName(player,tempstr,sizeof(tempstr));
      SendClientMessage(playerid,COLOR_LIGHTRED,tempstr);
    }
  }
  return 1;
}

As I rebuilt your command I found your problem
pawn Код:
if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1)
As you can see you're checking if the player that typed the command is a member of the group, not if the player in the loop is a member of the group
.
Reply
#5

Can you give me the complete command? I'm new in this..
Reply
#6

Uhm.... that is the complete command, including the strcmp.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)