Dialog help
#1

Hello guys,

I have some trouble with /admins command. Take a look:


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_STYLE_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;
}
Reply
#2

concatenate the title to string before entering loop
PHP код:
CMD:admins(playeridparams[])
{
    if(
PlayerInfo[playerid][pHour] >= || PlayerInfo[playerid][pAdminLevel] >= || PlayerInfo[playerid][pVIP] >= 1)
    {
        new 
adminstring[128],countadmin=0;
        
format(adminstringsizeof(adminstring),"Name\tPosition\tStatus\n");
        if(
IsPlayerConnected(playerid))
        {
            for (new 
0MAX_PLAYERSi++)
            {
                if(
IsPlayerConnected(i))
                {
                    if(
PlayerInfo[i][pAdminLevel] > 0)
                    {
                        
format(adminstringsizeof(adminstring),"%s%s\t%s\t%s\n"adminstringGetName(i),GetAdminName(i),GetAdminOnlineStatus(i));
                        
countadmin++;
                    }
                }
            }
            
ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STYLE_TABLIST_HEADERS,"{00CED1}Online Staff Members",adminstring,"{00CED1}Close","");
        }
         if(
countadmin == 0) return ShowPlayerDialog(playeridDIALOG_NOONLINEDIALOG_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.
Reply
#3

Thank you very much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)