adminstring
#1

Can someone please help me with this, if there are 2 admins online it only shows 1, and it does nothing if there are no admins online...

PHP код:
CMD:admins(playeridparams[])
{
    new 
adminstring[128];
    if(
IsPlayerConnected(playerid))
    {
      for (new 
0MAX_PLAYERSi++)
      {
        if(
IsPlayerConnected(i))
        {
          if(
PlayerInfo[i][pAdmin] > 0)
          {
            
format(adminstringsizeof(adminstring),"{FFFFFF}%s%s {FFFF00}[ID:%d]{FFFFFF}\n"adminstringPlayerName(i), i);
          }
        }
      }
    
ShowPlayerDialog(playerid,DIALOG_ONLINEADMINS,DIALOG_STYLE_MSGBOX,"Online admins",adminstring,"Close","");
    return 
1;
    }

Reply
#2

You don't need to check if playerid is connected.

Which admin is it showing, the lower ID, or the higher one?

And when none are online, is it showing anything at all, or is it coming up with the dialog box?
Reply
#3

Like Sew_Sumi said, You don't need to check if the playerid is connected.
PHP код:
CMD:admins(playeridparams[])
{
    new 
adminstring[256],tempstr[128], admins 0;
    for (new 
0MAX_PLAYERSi++) {
        if(
IsPlayerConnected(i))
        {
          if(
PlayerInfo[i][pAdmin] > 0)
          {
            
format(tempstrsizeof(tempstr),"{FFFFFF}%s {FFFF00}[ID:%d]{FFFFFF}\n"PlayerName(i), i);
            
strcat(adminstringtempstrsizeof(adminstring));
            
admins++;
          }
        }
      }
    if(
admins 0) {
      
ShowPlayerDialog(playerid,DIALOG_ONLINEADMINS,DIALOG_STYLE_MSGBOX,"Online admins",adminstring,"Close","");
    } else {
      
SendClientMessage(playerid0xFF0000FF"No admins online")
    }
    return 
1;

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
Reply
#4

Here you are:
Quote:

CMD:admins(playerid, params[])
{
new adminstring[128];
new str123[500];
if(IsPlayerConnected(playerid))
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] > 0)
{
format(adminstring, sizeof(adminstring),"{FFFFFF}%s%s {FFFF00}[ID:%d]{FFFFFF}\n", adminstring, PlayerName(i), i);
strcat(str123, adminstring);
}
}
}
ShowPlayerDialog(playerid,DIALOG_ONLINEADMINS,DIAL OG_STYLE_MSGBOX,"Online admins",str123,"Close","");
return 1;
}
}

Please, REP me if i helped!
Reply
#5

UPDATED CODE:

PHP код:
CMD:admins(playeridparams[])
{
    new 
adminstring[256],tempstr[128], admins 0;
    for (new 
0MAX_PLAYERSi++) {
        if(
IsPlayerConnected(i))
        {
          if(
PlayerInfo[i][pAdmin] > 0)
          {
            
format(tempstrsizeof(tempstr),"{FFFFFF}%s {FFFF00}[ID:%d]{FFFFFF}\n"PlayerName(i), i);
            
strcat(adminstringtempstrsizeof(adminstring));
            
admins++;
          }
        }
      }
    if(
admins 0) {
      
ShowPlayerDialog(playerid,DIALOG_ONLINEADMINS,DIALOG_STYLE_MSGBOX,"Online admins",adminstring,"Close","");
    } else {
      
SendClientMessage(playerid0xFF0000FF"No admins online")
    }
    return 
1;

Reply
#6

Please guys. Please. Please. Please. I can't look to this anymore. Over years and years. For so long time i had to see this... Please. Please!

PHP код:
format(string,sizeof(string),"something");
format(string,sizeof(string),"%s something",string); //fck off strcat in this way. 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)