That will send the total online number every time it loops through an admin Also, it will not show the admins name because all you did was get the name of the player who called the command at the top. Try this. Could use some more improvement as far as optimization goes but should work plenty fine.
pawn Код:
dcmd_admins(playerid, params[])
{
#pragma unused params
new
string[128],count,
pName[MAX_PLAYER_NAME];
SendClientMessage(playerid,COLOR_BROWN,"|__Online Admin/Mods/Vips__|");
for(new i=0;i<= MAX_SERVER_PLAYERS;i++)
{
if(PlayerInfo[i][level])
GetPlayerName(i,pName,24);
else
continue;
count++;
switch(PlayerInfo[i][level])
{
case 1:format(string, 60, "Name: %s | Level: 1 [VIP]",pName);
case 2:format(string, 60, "Name: %s | Level: 2 [MOD]",pName);
case 3:format(string, 60, "Name: %s | Level: 3 [ADMIN]",pName);
}
if(IsPlayerAdmin(i))
format(string, 60, "Name: %s | Level: %d [SERVER ADMIN/OWNER]",pName,PlayerInfo[playerid][level]);
SendClientMessage(playerid,COLOR_ORANGE,string);
}
SendClientMessage(playerid,COLOR_BROWN,"------------------------");
if(count)
format(string, 128,"Total Online: %d",count);
else
return SendClientMessage(playerid,COLOR_BROWN,"There are currently no admins online."),1;
SendClientMessage(playerid,COLOR_BROWN,string);
return 1;
}
Another way you could do it is just to have the switch statement and then continue the loop's iteration if the case is 0.