Author Topic: /c admins bugged  (Read 5681 times)

0 Members and 2 Guests are viewing this topic.

Offline saberman

  • Street Thug
  • *
  • Posts: 22
    • View Profile
/c admins bugged
« on: May 28, 2011, 09:24:19 am »
[pawn]   else if (strcmp(cmd, "admins", true) == 0) {
   new Count,i,name[24],string[256];
   for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2) Count++;
   if(!Count) return SendClientMessage(playerid, BLUE,"No admins ingame.");
   if(Count == 1)
   {
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2) break;
   GetPlayerName(i,name,24);
   if(PlayerInfo[playerid][Level] == 5)
   {
         format(string,256,"Present Owners: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   if(PlayerInfo[playerid][Level] == 4)
   {
         format(string,256,"Present Managers: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   if(PlayerInfo[playerid][Level] == 3)
   {
         format(string,256,"Present Administrators: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   if(PlayerInfo[playerid][Level] == 2)
   {
         format(string,256,"Present Moderators: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   return 1;
   }
   if(Count >= 1)
   {
      new bool:First = false;
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2)
     {
         GetPlayerName(i,name,24);
         if(!First)
       {
            if(PlayerInfo[playerid][Level] == 5)
            {
               format(string,256,"Present Owners: %s(%d)",name,i);
               SendClientMessage(playerid, BLUE, string);
            }
            First = true;
         }
         else format(string,256,"%s, %s(%d)",string,name,i);
      }
      return SendClientMessage(playerid, BLUE, string);
   }
   if(Count >= 1)
   {
      new bool:First = false;
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2)
     {
         GetPlayerName(i,name,24);
         if(!First)
       {
            if(PlayerInfo[playerid][Level] == 4)
            {
               format(string,256,"Present Managers: %s(%d)",name,i);
               SendClientMessage(playerid, BLUE, string);
            }
            First = true;
         }
         else format(string,256,"%s, %s(%d)",string,name,i);
      }
      return SendClientMessage(playerid, BLUE, string);
   }
   if(Count >= 1)
   {
      new bool:First = false;
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2)
     {
         GetPlayerName(i,name,24);
         if(!First)
       {
            if(PlayerInfo[playerid][Level] == 3)
            {
               format(string,256,"Present Administrators: %s(%d)",name,i);
               SendClientMessage(playerid, BLUE, string);
            }
            First = true;
         }
         else format(string,256,"%s, %s(%d)",string,name,i);
      }
      return SendClientMessage(playerid, BLUE, string);
   }
   if(Count >= 1)
   {
      new bool:First = false;
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2)
     {
         GetPlayerName(i,name,24);
         if(!First)
       {
            if(PlayerInfo[playerid][Level] == 2)
            {
               format(string,256,"Present Moderators: %s(%d)",name,i);
               SendClientMessage(playerid, BLUE, string);
            }
            First = true;
         }
         else format(string,256,"%s, %s(%d)",string,name,i);
      }
      return SendClientMessage(playerid, BLUE, string);
   }
   GetPlayerName(playerid, name, 32);
   printf("%s has used /admins command");
   return 1;
}[/pawn]
Even administrators/managers/moderators(level 3/4/2) are shown in Present: Owners when there is one.

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: /c admins bugged
« Reply #1 on: May 28, 2011, 09:36:14 am »
[pawn]if(PlayerInfo[playerid][Level] == 5)
   {
         format(string,256,"Present Owners: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   if(PlayerInfo[playerid][Level] == 4)
   {
         format(string,256,"Present Managers: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   if(PlayerInfo[playerid][Level] == 3)
   {
         format(string,256,"Present Administrators: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   if(PlayerInfo[playerid][Level] == 2)
   {
         format(string,256,"Present Moderators: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
[/pawn]

From what I'm seeing, you tend to be making the same mistake, which is confusing variables. When you code, stop and look it over to make sure it makes sense.
[pawn]
if(PlayerInfo[playerid][Level] ==
[/pawn]

Should be
[pawn]
if(PlayerInfo[Level] ==
[/pawn]
Do not PM me for support.




Offline saberman

  • Street Thug
  • *
  • Posts: 22
    • View Profile
Re: /c admins bugged
« Reply #2 on: May 29, 2011, 06:53:37 pm »
Thanks a lot Storm!!!

Offline saberman

  • Street Thug
  • *
  • Posts: 22
    • View Profile
Re: /c admins bugged
« Reply #3 on: May 29, 2011, 07:13:55 pm »
Another problem.
[pawn]   else if (strcmp(cmd, "admins", true) == 0) {
   new Count,i,name[24],string[256];
   for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2) Count++;
   if(!Count) return SendClientMessage(playerid, BLUE,"No admins ingame.");
   if(Count == 1)
   {
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2) break;
   GetPlayerName(i,name,24);
   if(PlayerInfo[Level] == 5)
   {
         format(string,256,"Present Owners: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   if(PlayerInfo[Level] == 4)
   {
         format(string,256,"Present Managers: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   if(PlayerInfo[Level] == 3)
   {
         format(string,256,"Present Administrators: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   if(PlayerInfo[Level] == 2)
   {
         format(string,256,"Present Moderators: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   return 1;
   }
   if(Count >= 1)
   {
      new bool:First = false;
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2)
     {
         GetPlayerName(i,name,24);
         if(!First)
       {
            if(PlayerInfo[Level] == 5)
            {
               format(string,256,"Present Owners: %s(%d)",name,i);
               SendClientMessage(playerid, BLUE, string);
            }
            First = true;
         }
         else format(string,256,"%s, %s(%d)",string,name,i);
      }
      return SendClientMessage(playerid, BLUE, string);
   }
   if(Count >= 1)
   {
      new bool:First = false;
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2)
     {
         GetPlayerName(i,name,24);
         if(!First)
       {
            if(PlayerInfo[Level] == 4)
            {
               format(string,256,"Present Managers: %s(%d)",name,i);
               SendClientMessage(playerid, BLUE, string);
            }
            First = true;
         }
         else format(string,256,"%s, %s(%d)",string,name,i);
      }
      return SendClientMessage(playerid, BLUE, string);
   }
   if(Count >= 1)
   {
      new bool:First = false;
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2)
     {
         GetPlayerName(i,name,24);
         if(!First)
       {
            if(PlayerInfo[Level] == 3)
            {
               format(string,256,"Present Administrators: %s(%d)",name,i);
               SendClientMessage(playerid, BLUE, string);
            }
            First = true;
         }
         else format(string,256,"%s, %s(%d)",string,name,i);
      }
      return SendClientMessage(playerid, BLUE, string);
   }
   if(Count >= 1)
   {
      new bool:First = false;
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2)
     {
         GetPlayerName(i,name,24);
         if(!First)
       {
            if(PlayerInfo[Level] == 2)
            {
               format(string,256,"Present Moderators: %s(%d)",name,i);
               SendClientMessage(playerid, BLUE, string);
            }
            First = true;
         }
         else format(string,256,"%s, %s(%d)",string,name,i);
      }
      return SendClientMessage(playerid, BLUE, string);
   }
   GetPlayerName(playerid, name, 32);
   printf("%s has used /admins command");
   return 1;
}[/pawn]
It says like, I set Dawood's level to 4(manager) and I have 5(Owner) and it says: "Present Owners: Sabreman(1), Dawood(0)"

How to fix it? Dawood's name should appear in Present Managers

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: /c admins bugged
« Reply #4 on: May 29, 2011, 09:22:09 pm »
[pawn]format(string,256,"Present Owners: %s(%d)",name,i);[/pawn]

Replace that with:
[pawn]format(string,256,"Present Owners: %s(%d)",name,PlayerInfo[Level]);[/pawn]
Do not PM me for support.




Offline saberman

  • Street Thug
  • *
  • Posts: 22
    • View Profile
Re: /c admins bugged
« Reply #5 on: May 30, 2011, 09:42:27 am »
[pawn]format(string,256,"Present Owners: %s(%d)",name,i);[/pawn]

Replace that with:
[pawn]format(string,256,"Present Owners: %s(%d)",name,PlayerInfo[Level]);[/pawn]
Actually the "i" is the ID of the person. Not the level :)

Offline saberman

  • Street Thug
  • *
  • Posts: 22
    • View Profile
Re: /c admins bugged
« Reply #6 on: May 30, 2011, 05:48:53 pm »
Help please.

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: /c admins bugged
« Reply #7 on: May 30, 2011, 07:07:11 pm »
[pawn]         if(!First)
       {
            if(PlayerInfo[Level] == 5)
            {
               format(string,256,"Present Owners: %s(%d)",name,i);
               SendClientMessage(playerid, BLUE, string);
            }
            First = true;
         }
         else format(string,256,"%s, %s(%d)",string,name,i);[/pawn]

There's a few things wrong with this code. First thing is that you're saying "If the first person we run into is a level 5, place them as a present admin. Otherwise, don't do anything. If they're not first, place them all in the Current Owners string."

You'd probably have to rescript this piece of the code with four 128-cell long strings
[pawn]
new owners[128], managers[128], admins[128], moderators[128];
[/pawn]

Then have four First variables for each group.
[pawn]
new Bool:ownerFirst, Bool:managerFirst, Bool:adminFirst, Bool:moderatorFirst;
[/pawn]

You'd then have to place each group in its respective string, then set their individual "First" variables.
Do not PM me for support.




Offline saberman

  • Street Thug
  • *
  • Posts: 22
    • View Profile
Re: /c admins bugged
« Reply #8 on: June 05, 2011, 07:30:49 pm »
Will do so this week. Thanks for the help.

Offline saberman

  • Street Thug
  • *
  • Posts: 22
    • View Profile
Re: /c admins bugged
« Reply #9 on: June 06, 2011, 10:13:33 am »
What's wrong here?
[pawn]   else if (strcmp(cmd, "admins", true) == 0) {
   new Count,i,name[24],string[256];
   for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2) Count++;
   if(!Count) return SendClientMessage(playerid, BLUE,"No admins ingame.");
   if(Count == 1)
   {
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] >= 2) break;
   GetPlayerName(i,name,24);
   if(PlayerInfo[playerid][Level] == 5)
   {
         format(string,256,"Present Owners: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   if(PlayerInfo[playerid][Level] == 4)
   {
         format(string,256,"Present Managers: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   if(PlayerInfo[playerid][Level] == 3)
   {
         format(string,256,"Present Administrators: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   if(PlayerInfo[playerid][Level] == 2)
   {
         format(string,256,"Present Moderators: %s(%d)",name,i);
         SendClientMessage(playerid, BLUE, string);
      }
   return 1;
   }
   if(Count >= 1)
   {
      new owners[128], managers[128], admins[128], mods[128];
      new bool:ofirst = false, bool:mfirst = false, bool:afirst = false, bool:mdfirst = false;
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] == 5)
     {
         GetPlayerName(i,name,24);
         if(!ofirst)
         {
            format(owners,128,"Present Owners: %s(%d)",name,i);
            SendClientMessage(playerid, BLUE, owners);
            ofirst = true;
         }
         else format(owners,128,"%s, %s",owners,name);
      }
      SendClientMessage(playerid, BLUE, string);
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] == 4)
     {
         GetPlayerName(i,name,24);
         if(!mfirst)
         {
            format(managers,128,"Present Managers: %s(%d)",name,i);
            SendClientMessage(playerid, BLUE, managers);
            mfirst = true;
         }
         else format(managers,128,"%s, %s",managers,name);
      }
      SendClientMessage(playerid, BLUE, managers);
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] == 3)
     {
         GetPlayerName(i,name,24);
         if(!afirst)
         {
            format(admins,128,"Present Administrators: %s(%d)",name,i);
            SendClientMessage(playerid, BLUE, admins);
            afirst = true;
         }
         else format(admins,128,"%s, %s",admins,name);
      }
      SendClientMessage(playerid, BLUE, admins);
      for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[Level] == 2)
     {
         GetPlayerName(i,name,24);
         if(!mdfirst)
         {
            format(mods,128,"Present Owners: %s(%d)",name,i);
            SendClientMessage(playerid, BLUE, mods);
            mdfirst = true;
         }
         else format(mods,128,"%s, %s",mods,name);
      }
      SendClientMessage(playerid, BLUE, mods);
   }
   GetPlayerName(playerid, name, 32);
   printf("%s has used /admins command");
   return 1;
}[/pawn]

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: /c admins bugged
« Reply #10 on: June 06, 2011, 05:15:35 pm »
if(Count >= 1) should be if(Count > 1)

Also, in that same area, you should put the entire thing (if(IsPlayerConnected(i) && PlayerInfo[Level]...) in that for loop, and then send all the messages after the for loop.
Do not PM me for support.