Right, apparently no-one is going to show you how to properly do it so, first things first! When you format your string you are formatting it for every administrator yet it overwrites the previous one meaning that if you have 5 admins online with the id of 1,5,7,20 and 35 you'd show dialog that only id 35 is currently online as an administrator. The thing you are looking for is a separate string let's say the default one is "string" the one with all admins will be "stringcomplete" and you're going to insert the new admin into the stringcomplete while keeping the record of the old one, usually this is a good enough explanation but I am going to present you a code and while I don't like coding for people because I think this slows down their brain work and doesn't make them learn more, this time I feel like visual code would help you more so here it is:
Код:
CMD:admins(playerid, params[])
{
new count = 0, stringcomplete[1500]; //the reason stringcomplete is 1500 is because if you have more admins you might run out of space so with 1500 you definitely won't any time soon.
for(new i = 0; i < GetPlayerPoolSize(); i++) //MAX_PLAYERS is bad habit, either use foreach include or loop via 0.3.7 native GetPlayerPoolSize()
{
if(!IsPlayerConnected(i)) continue;
if(!PlayerInfo[i][pAdmin]) continue;
new string[90], playersname[MAX_PLAYER_NAME];
GetPlayerName(i, playersname, sizeof(playersname));
switch(PlayerInfo[i][pAdmin])
{
case 1: format(string, sizeof(string), "{FF9900}%s (ID:%i) - Level: %d | Junior Administrator |\n", playersname, i, PlayerInfo[i][pAdmin]);
case 2: format(string, sizeof(string), "{FF9900}%s (ID:%i) - Level: %d | Senior Administrator |\n", playersname, i, PlayerInfo[i][pAdmin]);
case 3: format(string, sizeof(string), "{FF9900}%s (ID:%i) - Level: %d | Advisor Administrator |\n", playersname, i, PlayerInfo[i][pAdmin]);
case 4: format(string, sizeof(string), "{FF0000}%s (ID:%i) - Level: %d | Head Administrator |\n", playersname, i, PlayerInfo[i][pAdmin]);
case 5: format(string, sizeof(string), "{1E90FF}%s (ID:%i) - Level: %d | Server Founder |\n", playersname, i, PlayerInfo[i][pAdmin]);
default: continue;
}
count++;
format(stringcomplete, sizeof(stringcomplete), "%s%s", stringcomplete, string); //method 1 with format
strcat(stringcomplete, string); //method 2 with strcat, use the one you feel like, I don't know which one performs better but they both should do the same job.
}
if(count > 0) ShowPlayerDialog(playerid, DIALOG_ONLINEADMINS, DIALOG_STYLE_MSGBOX,""COL_YELLOW"SEF :: "COL_WHITE"Online Administrators",stringcomplete,"Okay","Cancel"); //You can feel free to showplayerdialog once the whole loop is done not for every single player you loop through.
if(count == 0) ShowPlayerDialog(playerid, DIALOG_NOONLINEADMINS, DIALOG_STYLE_MSGBOX,""COL_YELLOW"SEF :: "COL_WHITE"Online Administrators","There aren't any online admins.","Okay","Cancel");
return 1;
}
There might be some warning with spaces or typos I haven't tested it, I just wrote it on the run in the reply tab without trying it in pawn.