Admins list dialog
#1

Hey i want make my admins command a dialog one so please help guys this is the code
CMD:admins(playerid,params[])
{
#pragma unused params
new count = 0;
new string[128];
new ChangeColor;
Inter_SendClientMessage(playerid, green, " ");
Inter_SendClientMessage(playerid, green, "___________ |- Online Admins -| ___________");
Inter_SendClientMessage(playerid, green, " ");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if(AccInfo[i][Level] >= 1 && AccInfo[i][Hide] == 0)
{
if(AccInfo[i][Level] > 5)
{
AdmRank = "Professional Admin";
ChangeColor = Color_Professional_Admin;
}
if(IsPlayerAdmin(i))
{
AdmRank = "RCON Administrator";
ChangeColor = Color_RCON_Administrator;
}
else
{
switch(AccInfo[i][Level])
{
case 1: {
AdmRank = "Basic Moderator";
ChangeColor = Color_Basic_Moderator;
}
case 2: {
AdmRank = "Moderator";
ChangeColor = Color_Moderator;
}
case 3: {
AdmRank = "Master Moderator";
ChangeColor = Color_Master_Moderator;
}
case 4: {
AdmRank = "Administrator";
ChangeColor = Color_Administrator;
}
case 5: {
AdmRank = "Master Administrator";
ChangeColor = Color_Master_Administrator;
}
}
}
switch(AccInfo[i][OnDuty])
{
case 0: AdmDuty = "Playing!";
case 1: AdmDuty = "On Duty!";
}
format(string, 128, "Level: %d - %s (Id:%i) | %s | %s",AccInfo[i][Level], PlayerName2(i),i,AdmRank,AdmDuty);
Inter_SendClientMessage(playerid, ChangeColor, string);
count++;
}
}
}
if (count == 0)
Inter_SendClientMessage(playerid,red,"No admin online in the list");
Inter_SendClientMessage(playerid, green, " _______________________________________");
return 1;
}
please dont tell me another one i just one this one please
Reply
#2

pawn Код:
new
        Rank[ 40 ],
        msgColor,
        Duty[ 10 ]
        count,
        str[ 128 ]
    ;
    Inter_SendClientMessage(playerid, green, " ");
    Inter_SendClientMessage(playerid, green, "___________ |- Online Admins -| ___________");
    Inter_SendClientMessage(playerid, green, " ");

    for ( new i = 0 ; i < MAX_PLAYERS ; ++ i ) {
        if (!IsPlayerConnected( i )) continue;
        if (AccInfo[i][Hide]) continue;
        if (AccInfo[i][Level] < 1) continue;
        if (!IsPlayerAdmin(i)) {
            switch (AccInfo[i][Level]) {
                case 1: {
                    Rank = "Basic Moderator";
                    msgColor = Color_Basic_Moderator;
                }
                case 2: {
                    Rank = "Moderator";
                    msgColor = Color_Moderator;
                }
                case 3: {
                    Rank = "Master Moderator";
                    msgColor = Color_Master_Moderator;
                }
                case 4: {
                    Rank = "Administrator";
                    msgColor = Color_Administrator;
                }
                case 5: {
                    Rank = "Master Administrator";
                    msgColor = Color_Master_Administrator;
                }
                default: {
                    Rank = "Professional Admin";
                    msgColor = Color_Professional_Admin;
                }
            }
        }
        else Rank = "RCON Administrator";
       
        if (AccInfo[i][OnDuty]) Duty = "Playing";
        else Duty = "On Duty!";
       
        format( str , 128 , "Level: %d - %s (Id:%i) | %s | %s", AccInfo[i][Level] , PlayerName2(i) , i , Rank , Duty );
        Inter_SendClientMessage( playerid , msgColor , str );
       
        count ++;
   
    }

    if ( count < 1 ) {
        Inter_SendClientMessage(playerid,red,"No admin online in the list");
        Inter_SendClientMessage(playerid, green, " _______________________________________");
    }
Reply
#3

It's not the answer please tell me one good other
Reply
#4

Код:
if (strcmp("/admins", cmdtext, true, 10) == 0)
	{
		new string[256], name[MAX_PLAYER_NAME];
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
  			if(AccInfo[i][Level] > 0)
  			{
  			    GetPlayerName(playerid, name, sizeof(name));
				format(string, sizeof(string), "%s%s(ID: %d) Level: %d\n", string, name, i, AccInfo[i][Level]);
				ShowPlayerDialog(playerid, 189, DIALOG_STYLE_MSGBOX, "Online Admins", string, "Ok", "Cancel");
			}
		}
		return 1;
	}
Reply
#5

The above code should work, but there's no need to show the dialog inside the for loop (because the string isn't totally formatted yet), it should be right after the for loop. Here's your command and next time use [ pawn ] pawn code here [ /pawn ], please:

pawn Код:
CMD:admins(playerid,params[])
{
    #pragma unused params
    new count = 0;
    new string[128];
    new ChangeColor;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            if(AccInfo[i][Level] >= 1 && AccInfo[i][Hide] == 0)
            {
                if(AccInfo[i][Level] > 5)
                {
                    AdmRank = "Professional Admin";
                    ChangeColor = Color_Professional_Admin;
                }
                if(IsPlayerAdmin(i))
                {
                    AdmRank = "RCON Administrator";
                    ChangeColor = Color_RCON_Administrator;
                }
                else
                {
                    switch(AccInfo[i][Level])
                    {
                        case 1: {
                            AdmRank = "Basic Moderator";
                            ChangeColor = Color_Basic_Moderator;
                        }
                        case 2: {
                            AdmRank = "Moderator";
                            ChangeColor = Color_Moderator;
                        }
                        case 3: {
                            AdmRank = "Master Moderator";
                            ChangeColor = Color_Master_Moderator;
                        }
                        case 4: {
                            AdmRank = "Administrator";
                            ChangeColor = Color_Administrator;
                        }
                        case 5: {
                            AdmRank = "Master Administrator";
                            ChangeColor = Color_Master_Administrator;
                        }
                    }
                }
                switch(AccInfo[i][OnDuty])
                {
                    case 0: AdmDuty = "Playing!";
                    case 1: AdmDuty = "On Duty!";
                }
                format(string, sizeof(string), "%sLevel: %d - %s (Id:%i) | %s | %s\n", string, AccInfo[i][Level], PlayerName2(i),i,AdmRank,AdmDuty);
                count++;
            }
        }
    }
    if (count == 0)
        format(string, sizeof(string), "No Admins online!");
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Online Admins", str, "Ok", ""); // consider changing the dialog id
    return 1;
}
Reply
#6

Quote:
Originally Posted by HellSphinX
Посмотреть сообщение
The above code should work, but there's no need to show the dialog inside the for loop (because the string isn't totally formatted yet), it should be right after the for loop. Here's your command and next time use [ pawn ] pawn code here [ /pawn ], please:

pawn Код:
CMD:admins(playerid,params[])
{
    #pragma unused params
    new count = 0;
    new string[128];
    new ChangeColor;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            if(AccInfo[i][Level] >= 1 && AccInfo[i][Hide] == 0)
            {
                if(AccInfo[i][Level] > 5)
                {
                    AdmRank = "Professional Admin";
                    ChangeColor = Color_Professional_Admin;
                }
                if(IsPlayerAdmin(i))
                {
                    AdmRank = "RCON Administrator";
                    ChangeColor = Color_RCON_Administrator;
                }
                else
                {
                    switch(AccInfo[i][Level])
                    {
                        case 1: {
                            AdmRank = "Basic Moderator";
                            ChangeColor = Color_Basic_Moderator;
                        }
                        case 2: {
                            AdmRank = "Moderator";
                            ChangeColor = Color_Moderator;
                        }
                        case 3: {
                            AdmRank = "Master Moderator";
                            ChangeColor = Color_Master_Moderator;
                        }
                        case 4: {
                            AdmRank = "Administrator";
                            ChangeColor = Color_Administrator;
                        }
                        case 5: {
                            AdmRank = "Master Administrator";
                            ChangeColor = Color_Master_Administrator;
                        }
                    }
                }
                switch(AccInfo[i][OnDuty])
                {
                    case 0: AdmDuty = "Playing!";
                    case 1: AdmDuty = "On Duty!";
                }
                format(string, sizeof(string), "%sLevel: %d - %s (Id:%i) | %s | %s\n", string, AccInfo[i][Level], PlayerName2(i),i,AdmRank,AdmDuty);
                count++;
            }
        }
    }
    if (count == 0)
        format(string, sizeof(string), "No Admins online!");
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Online Admins", str, "Ok", ""); // consider changing the dialog id
    return 1;
}
Oh yea, my bad.
It was suppose to go outside the loop.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)