/admins doesn't update list!
#1

So when an admin leaves the game, His name will still be shown on the admins list!

Код:
CMD:admins(playerid, params[])
{
      if(connected[playerid] == true) return GameTextForPlayer(playerid, "~r~Spawn First", 5000, 5);
      if(pInfo[playerid][Admin] < 1) return SendClientMessage(playerid, -1, "{C3C3C3}(INFO) You don't have the priviliges to use this command.");
      new str[128], count=0;
	  for(new j = 1; j <= 3; j++)
	  {
		  for(new i = 0; i < MAX_PLAYERS; i++)
		  {
			  if(pInfo[i][Admin] == j)
			  {
				 format(str, 256, "{66ff99}%s (level: %d)", PlayerName[i], pInfo[i][Admin]);
				 SendClientMessage(playerid, -1, str);
				 count ++;
			  }
		  }
	  }
	  format(str, sizeof(str), "{66ff99}There are currently %d admins online.", count);
	  SendClientMessage(playerid, -1, str);
	  return 1;
}
Reply
#2

so if you type /admins when that admin is offline,his name is still there?
Reply
#3

yeah
Reply
#4

Just add this line in your script. I haven't tested it, but it should work accordingly now.

Код:
   	if(count == 0)
	SendClientMessage(playerid,COLOR_WHITE,"There are currently no administrators online.");
	return 1;
}
Reply
#5

Quote:
Originally Posted by Thundey
Посмотреть сообщение
Just add this line in your script. I haven't tested it, but it should work accordingly now.

Код:
   	if(count == 0)
	SendClientMessage(playerid,COLOR_WHITE,"There are currently no administrators online.");
	return 1;
}
If you don't know what the problem is ; you really shouldn't answer or at least try to coherent answer. By the way, there is no offense on that.

The problem is here:
PHP код:
for(new 0MAX_PLAYERSi++) 
You shouldn't loop through 0 to 1000 (by default) but only through connected players.
PHP код:
for(new iGetPlayerPoolSize(); <= ji++) 
Reply
#6

If the name still shows up after they've logged out, I'm guessing it's because you don't clear player variables when a player logs out or logs in, otherwise it wouldn't show up. Not to mention, you're using an unnecessary loop to check their admin level, you can simply check if their admin level isn't 0, also you're just looping through MAX_PLAYERS and not checking to see if the player's online or not.

pawn Код:
CMD:admins(playerid, params[])
{
      if(connected[playerid] == true) return GameTextForPlayer(playerid, "~r~Spawn First", 5000, 5);
      if(pInfo[playerid][Admin] < 1) return SendClientMessage(playerid, -1, "{C3C3C3}(INFO) You don't have the priviliges to use this command.");
      new str[128], count=0;
      for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)  //better loop as it doesn't go through every player slot, just the max playerid on the server
      {
           if(!IsPlayerConnected(i)) { continue; } //skips any playerids that aren't onine
           if(pInfo[i][Admin] != 0)
       {
            format(str, 256, "{66ff99}%s (level: %d)", PlayerName[i], pInfo[i][Admin]); //str is not 256 long as you declared it to be 128, either change this line or increase the str to 256
        SendClientMessage(playerid, -1, str);
            count ++;
       }
   
     }
     format(str, sizeof(str), "{66ff99}There are currently %d admins online.", count);
     SendClientMessage(playerid, -1, str);
     return 1;
}
Reply
#7

Fixed post:

Код:
for(new i, j = GetPlayerPoolSize(); i <= j; i++)
is really better if you have a lot of slots.
Reply
#8

^^ You should mention on why the change in str handling regarding the size...
Reply
#9

I did a mistake. I've not read post above mine.
Reply
#10

Quote:
Originally Posted by DTV
Посмотреть сообщение
If the name still shows up after they've logged out, I'm guessing it's because you don't clear player variables when a player logs out or logs in, otherwise it wouldn't show up. Not to mention, you're using an unnecessary loop to check their admin level, you can simply check if their admin level isn't 0, also you're just looping through MAX_PLAYERS and not checking to see if the player's online or not.

pawn Код:
CMD:admins(playerid, params[])
{
      if(connected[playerid] == true) return GameTextForPlayer(playerid, "~r~Spawn First", 5000, 5);
      if(pInfo[playerid][Admin] < 1) return SendClientMessage(playerid, -1, "{C3C3C3}(INFO) You don't have the priviliges to use this command.");
      new str[128], count=0;
      for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)  //better loop as it doesn't go through every player slot, just the max playerid on the server
      {
           if(!IsPlayerConnected(i)) { continue; } //skips any playerids that aren't onine
           if(pInfo[i][Admin] != 0)
       {
            format(str, 256, "{66ff99}%s (level: %d)", PlayerName[i], pInfo[i][Admin]); //str is not 256 long as you declared it to be 128, either change this line or increase the str to 256
        SendClientMessage(playerid, -1, str);
            count ++;
       }
   
     }
     format(str, sizeof(str), "{66ff99}There are currently %d admins online.", count);
     SendClientMessage(playerid, -1, str);
     return 1;
}
worked thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)