CMD:admins(playerid, params[]) { new count = 0; for(new i = 0; i < MAX_PLAYERS; i++) { 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; } ShowPlayerDialog(playerid, DIALOG_ONLINEADMINS, DIALOG_STYLE_MSGBOX,""COL_YELLOW"SEF :: "COL_WHITE"Online Administrators",string,"Okay","Cancel"); count++; } if(!count) ShowPlayerDialog(playerid, DIALOG_NOONLINEADMINS, DIALOG_STYLE_MSGBOX,""COL_YELLOW"SEF :: "COL_WHITE"Online Administrators","There aren't any online admins.","Okay","Cancel"); return 1; }
If you ask like this i doubt anyone will help, also, i hope no one will.
People like you gotta learn how to ask questions: 1. What is the problem 2. Your code 3. What have you tried 4. Have you already tried generalizing your case trying it with an MCVE |
CMD:admins(playerid,params[]) { new count=0; new string[128],name[50]; for(new i=0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) { if(PlayerInfo[i][pAdmin] > 0) { if(PlayerInfo[i][pAdmin]==1){name="Junior Administrator";} if(PlayerInfo[i][pAdmin]==2){name="Senior Administrator";} if(PlayerInfo[i][pAdmin]==3){name="Advisor Administrator";} if(PlayerInfo[i][pAdmin]==4){name="Head Administrator";} if(PlayerInfo[i][pAdmin]==5){name="Server Founder";} format(string,128,"%s - %s",playersname,name); ShowPlayerDialog(playerid, DIALOG_ONLINEADMINS, DIALOG_STYLE_MSGBOX,""COL_YELLOW"SEF :: "COL_WHITE"Online Administrators",string,"Okay","Cancel"); count++; } } else { ShowPlayerDialog(playerid, DIALOG_NOONLINEADMINS, DIALOG_STYLE_MSGBOX,""COL_YELLOW"SEF :: "COL_WHITE"Online Administrators","There aren't any online admins.","Okay","Cancel"); } return 1; }
CMD:admins(playerid,params[])
{
new d_header[50], d_content[144], d_count = 0, d_name[MAX_PLAYER_NAME + 1]; //d_ = dialog
for(new i = 0, j = GetPlayerPoolSize(); i<=j; i++)
{
if(PlayerInfo[i][pAdmin])
{
GetPlayerName(i, d_name, sizeof(d_name));
format(d_content, sizeof(d_content), "%s%s [%d]\n", d_content, d_name, i);
d_count++;
}
}
if(d_count == 0)
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "[notice]", "There are no online admins at the moment!", "Close", "");
else
{
format(d_header, sizeof(d_header), "[admins] - {FFFF00}%d {FFFFFF}admin(s)", d_count);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, d_header, d_content, "Close", "");
}
return 1;
}
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; }
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; } |
gname(pid){
new s[24];
GetPlayerName(pid,s,24);
return s;
}
CMD:admins(pid){
new s[1000],arrRanks[][]={"Junior Administrator","Senior Administrator","Advisor Administrator","Head Administrator","Server Founder"};
foreach(Player,i)if(PlayerInfo[i][pAdmin])format(s,sizeof(s),"%s{FF9900}%s (ID:%i) - Level: %d | %s |\n",s,gname(i),i,PlayerInfo[i][pAdmin],arrRanks[PlayerInfo[i][pAdmin]-1];
ShowPlayerDialog(playerid, DIALOG_ONLINEADMINS, DIALOG_STYLE_MSGBOX, ""COL_YELLOW"SEF :: "COL_WHITE"Online Administrators",
strlen(s)?s:("There aren't any online admins."),
"Okay","Cancel");
return 1;
}