PDA

View Full Version : My /admins command


PlayHard
31/12/2011, 01:42 PM
My problem is that when I type /admins it shows all the players who are connected to the server. If a player is an admin for sure it shows his rank before his/her name, but if the player is a normal player it just show his name. I want it to show ONLY the admins names.

YCMD:admins(playerid, params[])
{
if(gPlayerLoggedIn[playerid] == 0) return 1;

SCM(playerid, COLOR_WHITE, "Administrators online:");
foreach(Player, i)
{
new level[128], string[128];

if(PlayerInfo[playerid][Admin] == 0 && PlayerInfo[i][Admin] > 1 /*&& AdminDuty[i] == 1*/)
{
switch(PlayerInfo[i][Admin])
{
case 2: level = ""adminlevel2"";
case 3: level = ""adminlevel3"";
case 4: level = ""adminlevel4"";
case 5: level = ""adminlevel5"";
}
format(string, sizeof(string), "%s %s", level, PlayerName(i));
SCM(playerid, COLOR_GREY, string);
}
if(PlayerInfo[playerid][Admin] > 0)
{
switch(PlayerInfo[i][Admin])
{
case 1: level = ""adminlevel1" (1)";
case 2: level = ""adminlevel2" (2)";
case 3: level = ""adminlevel3" (3)";
case 4: level = ""adminlevel4" (4)";
case 5: level = ""adminlevel5" (5)";
}
format(string, sizeof(string), "%s %s", level, PlayerName(i));
SCM(playerid, COLOR_GREY, string);
}
}
return 1;
}

I tried this

else if(PlayerInfo[playerid][Admin] == 0)
{
format(string,sizeof(string), "");

}

Lol, but it didn't work.

James Coral
31/12/2011, 02:13 PM
Errors??

PlayHard
31/12/2011, 02:18 PM
There are no errors.

Norck
31/12/2011, 02:18 PM
Try this:

YCMD:admins(playerid, params[])
{
if(gPlayerLoggedIn[playerid] == 0) return 1;

SCM(playerid, COLOR_WHITE, "Administrators online:");
foreach(Player, i)
{
new level[128], string[128];

if(PlayerInfo[i][Admin] > 0)
{
switch(PlayerInfo[i][Admin])
{
case 1: level = ""adminlevel1" (1)";
case 2: level = ""adminlevel2" (2)";
case 3: level = ""adminlevel3" (3)";
case 4: level = ""adminlevel4" (4)";
case 5: level = ""adminlevel5" (5)";
}
format(string, sizeof(string), "%s %s", level, PlayerName(i));
SCM(playerid, COLOR_GREY, string);
}
}
return 1;
}

PlayHard
31/12/2011, 02:34 PM
Thank you, I think it works.

Norck
31/12/2011, 02:39 PM
Thank you, I think it works.

You are welcome :)