08.01.2014, 11:24
Hi I was wondering if someone can make me a command that shows online admins but in a dialog box which only shows names not level.
#define DIALOG_ONLINEADMINS 1 CMD:admins(playerid, params[]) { new adminstring[128]; if(IsPlayerConnected(playerid)) { for (new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(PlayerInfo[i][pLevel] > 0) { format(adminstring, sizeof(adminstring),"%s%s[ID:%d]\n", adminstring, PlayerName(i), i); } } } ShowPlayerDialog(playerid,DIALOG_ONLINEADMINS,DIALOG_STYLE_MSGBOX,"Online admins",adminstring,"Close",""); } else return SendClientMessage(playerid,-1," No admins online"); return 1; }
#define SOME_DIALOG 1112
YCMD:admins(playerid,params[],help)
{
if(help) SendClientMessage(playerid,-1,"/admins is used to show which admins are currently online.");
new pn[MAX_PLAYER_NAME+2],s[50];//size of 's' depends on the number of admins you have and their name-lenght
//we'll be using the pn string for the playername as temporary string (+2 cuz of '\n')
for(new i=0; i<=GetMaxPlayers(),IsPlayerAdmin(i); i++)
format(pn,sizeof pn,"%s\n",GetName(i)),
strcat(s,pn);
if(s[0] == EOS) return SendClientMessage(playerid,-1,"There are no admins online at the moment.");
ShowPlayerDialog(playerid,SOME_DIALOG,DIALOG_STYLE_MSGBOX,"Admins online",s,"Ok","");
return 1;
}
stock GetName(playerid)
{
new n[MAX_PLAYER_NAME];
GetPlayerName(playerid, n, MAX_PLAYER_NAME);
return n;
}