16.03.2015, 17:05
This will show only an administrator, what he said Calvin is correct, you'll need to use "strcat".
Your code might only show 4 or 5 administrators and although there is no connected administrators will display the dialog without information about this.
This will show maximum 12 administrators, if you want to add more simply change this.
Your code might only show 4 or 5 administrators and although there is no connected administrators will display the dialog without information about this.
PHP Code:
CMD:admins(playerid, params[])
{
#pragma unused params
//..
new string[41*12], name[24], sformat[41], admins; // string[41*12] = max 12 admins show in dialog.
//..
for(new i; i != MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] >= 1)
{
GetPlayerName(i, name, sizeof(name));
format(sformat, sizeof(sformat), "* %s Level %d.\n", name, PlayerInfo[i][pAdmin]);
strcat(string, sformat);
admins = admins+1;
}
}
}
if(admins < 1)
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, "Info admins", "There are no administrators connected.", "accept", "exit");
else if(admins >= 1)
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MGSBOX, "Info admins", string, "accept", "exit");
return true;
}
PHP Code:
new string[41*12]; // (12)