How to make that ?
#1

Hi, can somebody tell me how the online admins (RCON) can be shown in a msgbox dialog ? For an example if a player type /admins and he will see an dialog with title : Server Online Admins(the number of online admins): and under it the list of online administrators for example x96664 (mine id) ?
Reply
#2

make a CMD
pawn Код:
CMD:admins
for ZCMD! and do an
pawn Код:
OnDialogResponse
Reply
#3

Why ondialogresponse? That doesn't make sence...
pawn Код:
if(!strcmp(cmdtext, "/admins", true))
 {
    new linestring[128], name[MAX_PLAYER_NAME+1];
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerAdmin(i))
        {
            GetPlayerName(i, name, sizeof(name));
            format(linestring,sizeof(linestring),"Rcon Admin: %s",name);
SendClientMessage(playerid,-1,linestring);
        }
    }

}
Reply
#4

pawn Код:
COMMAND:admins(playerid, params[])
{
    SendClientMessage(playerid, 0x80FF00FF, "Online admins:");
    for(new i; i != GetMaxPlayers(); ++i)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerAdmin(i))
            {
                new pName[MAX_PLAYER_NAME], adminsMessage[100], finalMessage[500];
                GetPlayerName(playerid, pName, sizeof(pName));
                format(adminsMessage, sizeof(adminsMessage), "%s(%d)\n", pName, playerid);
                strcat(finalMessage, adminsMessage);
                ShowPlayerDialog(playerid, 1000, DIALOG_STYLE_MSGBOX, "Online Admins", finalMessage, "Okay", "");
            }
        }
    }
    return 1;
}
Not tested, and works with ZCMD, I can convert it to strcmp if you wish. But it would be easier with messages, here is my somewhat overdone command for my server. Please tell me if it doesn't work so I can fix it for you.

pawn Код:
COMMAND:admins(playerid, params[])
{
    new bool:adminOnline;
    foreach(new i : Player) { if(P_DATA[i][AdminLevel] >= 1) { adminOnline = true; } }
    if(adminOnline == true)
    {
        SendClientMessage(playerid, COLOR_WHITE, "List of online admins:");
        foreach(new i : Player)
        {
            if(P_DATA[i][AdminLevel] >= 1)
            {
                new iRank[20], iAdmin[80];
                switch(P_DATA[i][AdminLevel])
                {
                    case 1: iRank = "Junior Moderator";
                    case 2: iRank = "Moderator";
                    case 3: iRank = "Administrator";
                    case 4: iRank = "Head Administrator";
                    case 5: iRank = "Owner";
                    default: iRank = "Unknown";
                }
                format(iAdmin, sizeof(iAdmin), EMBED_GREEN"%s(%d)"EMBED_WHITE" Rank - %s - Level %d", ReturnPlayerName(i), i, iRank, P_DATA[i][AdminLevel]);
                SendClientMessage(playerid, COLOR_WHITE, iAdmin);
            }
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "No admins are currently online!");
    }
    return 1;
}
The 'PAWN' tags somehow screwed up the syntax of the code.
Reply
#5

After you did ShowPlayerDialog WHERE IS THE DIALOG RESPONSE ?!?!
Reply
#6

Quote:
Originally Posted by Red_Dragon.
Посмотреть сообщение
After you did ShowPlayerDialog WHERE IS THE DIALOG RESPONSE ?!?!
Is that a response to my reply?
Reply
#7

Quote:
Originally Posted by Red_Dragon.
Посмотреть сообщение
After you did ShowPlayerDialog WHERE IS THE DIALOG RESPONSE ?!?!
Are you sure your mind is at the right place? Didn't use drugs or something?
Reply
#8

I wouldn't use the one Roel used, because this will look like this with 4 RCON admins:
Rcon Admin: KwardeRcon Admin:KevinRcon Admin: PlayerRcon Admin:Admin
I'd prefer this one:
pawn Код:
CMD:admins(playerid, params[])
{
    new str[128], pName[MAX_PLAYER_NAME], adminCount;
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (!IsPlayerConnected(i) || !IsPlayerAdmin(i)) continue; //Skip non-RCON admins and non-connected players
        adminCount++;
        GetPlayerName(i, pName, MAX_PLAYER_NAME);
        if (adminCount == 1) format (str, 128, "%s", pName);
        else if(adminCount > 1) format(str, 128, "%s , %s", str, pName);
    }
    if (adminCount >= 1)
    {
        SendClientMessage(playerid, 0x00FF00AA, "* Online RCON admin(s):");
        SendClientMessage(playerid, 0xFFFFFFAA, str);
    }
    else SendClientMessage(playerid, 0xFF0000AA, "* No RCON admins online!");
    return 1;
}
When no RCON admins are logged in, you'll get a red text saying * No RCON admins online!. Otherwise, with 4 RCON admins, it'd look like this:

* Online RCON admin(s):
Kwarde , Kevin , Player , Admin
Reply
#9

Quote:
Originally Posted by Bicentric
Посмотреть сообщение
pawn Код:
COMMAND:admins(playerid, params[])
{
    SendClientMessage(playerid, 0x80FF00FF, "Online admins:");
    for(new i; i != GetMaxPlayers(); ++i)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerAdmin(i))
            {
                new pName[MAX_PLAYER_NAME], adminsMessage[100], finalMessage[500];
                GetPlayerName(playerid, pName, sizeof(pName));
                format(adminsMessage, sizeof(adminsMessage), "%s(%d)\n", pName, playerid);
                strcat(finalMessage, adminsMessage);
                ShowPlayerDialog(playerid, 1000, DIALOG_STYLE_MSGBOX, "Online Admins", finalMessage, "Okay", "");
            }
        }
    }
    return 1;
}
Not tested, and works with ZCMD, I can convert it to strcmp if you wish. But it would be easier with messages, here is my somewhat overdone command for my server. Please tell me if it doesn't work so I can fix it for you.
I will test it now and I have a reason to do it in a dialog it's because I want to have something different from the other servers.
Reply
#10

Edit: Fixed!
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)