Admin Line problem
#1

Hello I want code to show all the admins in one line not every admin in line example

Admins: Test[Owner]
Admins: Test2[Leader]
.
.

I want it :

Admins: Test[Owner], Test2[Leader] .. etc
Im using lux admin system
and
Here is the code:


Код:
dcmd_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 = "{00C0FF}Manager/Owner";
						ChangeColor = Color_Professional_Admin;
					}
 					if(IsPlayerAdmin(i))
				  	{
				  		AdmRank = "{6EF83C}Rcon";
				  		ChangeColor = Color_RCON_Administrator;
				  	}
				    else
				    {
				 		switch(AccInfo[i][Level])
						{
							case 1: {
							AdmRank = "{6EF83C}Tester";
							ChangeColor = Color_Basic_Moderator;
							}
							case 2: {
							AdmRank = "{C3C3C3}Mod";
							ChangeColor = Color_Moderator;
							}
							case 3: {
							AdmRank = "{00C0FF}Admin";
							ChangeColor = Color_Master_Moderator;
							}
							case 4: {
							AdmRank = "{F3FF02}Leader";
							ChangeColor = Color_Administrator;
							}
							case 5: {
							AdmRank = "{C3C3C3}Manager";
							ChangeColor = Color_Master_Administrator;
							}
						}
					}
		 			switch(AccInfo[i][OnDuty])
					{
						case 0: AdmDuty = "Playing!";
						case 1: AdmDuty = "On Duty!";
					}
					format(string, 128, "Admins: {F81414}%s {F81414}[%s{F81414}]",PlayerName2(i),AdmRank);
					SendClientMessage(playerid, ChangeColor, string);
					count++;
				}
			}
		}
		if (count == 0)
		SendClientMessage(playerid,orange,"{C77D87}No {F3FF02}Administrators {C77D87}online!");
		return 1;
}
Reply
#2

First have a variable that you increment in the loop. In the loop, format something like "{F81414}%s [%s]" and then use strcat to append it to a larger string. When your variable that you increment reaches something like 3-4 (depending on how many admins you want to display on one line), send the message and clear the large buffer.

I won't write the exact code for you, but this should give you an idea:
pawn Код:
new szLine[156], PlayerName[MAX_PLAYER_NAME], szAdmin[40], lineUsed;
for(new i = 0; i != MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        // Format the admin's name with the rank here
        GetPlayerName(i, PlayerName, sizeof(MAX_PLAYER_NAME));
        format(szAdmin, sizeof(szAdmin), "%s [%s]", PlayerName, rank);
        strcat(szLine, szAdmin);

        lineUsed ++;
        if(lineUsed == 4)
        {
            SendClientMessage(playerid, COLOR, szLine); // Send the long line
            szLine[0] = EOS; // Clear out the buffer
        }
        else
        {
            strcat(szLine, ", "); // Append a comma so our list looks nicer
        }
    }
}
Increase the size of the szAdmin array if necessary. Also use 3 instead of 4 if your rank messages for admins are long.

This code should give you the basic idea of how to do it. I used to have similar code, but I switched to using dialogs.
Reply
#3

I can not script, so can you give me it then i will copy please?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)