admins online command
#1

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.
Reply
#2

Код:
#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;
}
Reply
#3

removed, sorry forget that you need it in a dialog
Reply
#4

It says unknown command
Reply
#5

what?
Reply
#6

Quote:
Originally Posted by rocker3410
Посмотреть сообщение
It says unknown command
forcing an output of something which is actually nothing,
(something like you're creating a string which is 6 long and trying to output the char at 8, which is not possible since there's nothing after the null char at 5 (counting from '0'))
can cause a "SERVER: unknown command".


use this, it's in YCMD which I'd recommend you to use.
PHP код:
#define SOME_DIALOG 1112
YCMD:admins(playerid,params[],help)
{
    if(
helpSendClientMessage(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=0i<=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(playeridnMAX_PLAYER_NAME);
    return 
n;

im checking for rcon admins since i don't know how you define admins in your script of course.
You just have to change the 2nd condition
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)