12.04.2017, 21:12
Like Sew_Sumi said, You don't need to check if the playerid is connected.
Try this code. Nothing happens if no admins is online is because you don't add a count to the loop. Try and let me know if this works.
EDIT: I've updated the code try Now. Just realized something. This should show all the admins and show a message if there are no admins
PHP код:
CMD:admins(playerid, params[])
{
new adminstring[256],tempstr[128], admins = 0;
for (new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] > 0)
{
format(tempstr, sizeof(tempstr),"{FFFFFF}%s {FFFF00}[ID:%d]{FFFFFF}\n", PlayerName(i), i);
strcat(adminstring, tempstr, sizeof(adminstring));
admins++;
}
}
}
if(admins > 0) {
ShowPlayerDialog(playerid,DIALOG_ONLINEADMINS,DIALOG_STYLE_MSGBOX,"Online admins",adminstring,"Close","");
} else {
SendClientMessage(playerid, 0xFF0000FF, "No admins online")
}
return 1;
}
EDIT: I've updated the code try Now. Just realized something. This should show all the admins and show a message if there are no admins