SA-MP Forums Archive
adminstring - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: adminstring (/showthread.php?tid=632356)



adminstring - Melktert - 12.04.2017

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;
    }




Re: adminstring - Sew_Sumi - 12.04.2017

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?


Re: adminstring - DarkSkull - 12.04.2017

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


Re: adminstring - Kraeror - 12.04.2017

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!


Re: adminstring - DarkSkull - 12.04.2017

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;




Re: adminstring - GangstaSunny. - 12.04.2017

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.