PDA

View Full Version : Dialog help


TomRedlake
12/11/2017, 12:11 PM
Hello guys,

I have some trouble with /admins command. Take a look:
http://i65.tinypic.com/30bff2o.png

Code here:
CMD:admins(playerid, params[])
{
if(PlayerInfo[playerid][pHour] >= 2 || PlayerInfo[playerid][pAdminLevel] >= 1 || PlayerInfo[playerid][pVIP] >= 1)
{
new adminstring[128],countadmin=0;
if(IsPlayerConnected(playerid))
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdminLevel] > 0)
{
format(adminstring, sizeof(adminstring),"Name\tPosition\tStatus\n\%s%s\t%s\t%s\n", adminstring, GetName(i),GetAdminName(i),GetAdminOnlineStatus(i) );
countadmin++;
}
}
}
ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STY LE_TABLIST_HEADERS,"{00CED1}Online Staff Members",adminstring,"{00CED1}Close","");
}
if(countadmin == 0) return ShowPlayerDialog(playerid, DIALOG_NOONLINE, DIALOG_STYLE_MSGBOX,"{00CED1}Online Staff Members","No Staff members online","{00CED1}Close","");
}
return 1;
}

SyS
12/11/2017, 12:18 PM
concatenate the title to string before entering loop

CMD:admins(playerid, params[])
{
if(PlayerInfo[playerid][pHour] >= 2 || PlayerInfo[playerid][pAdminLevel] >= 1 || PlayerInfo[playerid][pVIP] >= 1)
{
new adminstring[128],countadmin=0;
format(adminstring, sizeof(adminstring),"Name\tPosition\tStatus\n");
if(IsPlayerConnected(playerid))
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdminLevel] > 0)
{
format(adminstring, sizeof(adminstring),"%s%s\t%s\t%s\n", adminstring, GetName(i),GetAdminName(i),GetAdminOnlineStatus(i) );
countadmin++;
}
}
}
ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STY LE_TABLIST_HEADERS,"{00CED1}Online Staff Members",adminstring,"{00CED1}Close","");
}
if(countadmin == 0) return ShowPlayerDialog(playerid, DIALOG_NOONLINE, DIALOG_STYLE_MSGBOX,"{00CED1}Online Staff Members","No Staff members online","{00CED1}Close","");
}
return 1;
}


Note:
Use foreach to iterate through connected players
Using strcat would be better.

TomRedlake
12/11/2017, 12:29 PM
Thank you very much :)