SA-MP Forums Archive
/Admins - Need Help! - 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: /Admins - Need Help! (/showthread.php?tid=610609)



/Admins - Need Help! - TheHonnor - 26.06.2016

Hi mates, I'm TheHonnor!
Recently i made a command called '/Admins'. What does do this command?
Well, this command will Show you a DIALOG_STYLE_TABLIST_HEADERS dialog with all connected admins on server.

Photo with dialog: http://imgur.com/4a5aDEK

Ok, what's the trouble? In the photo, I'm the only connected admin. But, if there are more than one connected admins on the server, then the dialog will show "Admin name" "Level" "Status" "Rcon Access" where the admins must appear.

Код:
CMD:admins(playerid)
{
    if(PlayerInfo[playerid][pVip] >= 1 || PlayerInfo[playerid][Level] >= 1)
    {
        Str[0] = '\0'; new TotalCount = 0, HonnCaption[52], Status[64], HonnT[24];
        //----------------------------------------------------------------------
        foreach(new i: Player) if(PlayerInfo[i][Level] >= 1)
        {
            if(IsPlayerAdmin(i))                            HonnT = "{00FF00}Yes";
            else if(!IsPlayerAdmin(i))                      HonnT = "{FF0000}No";
            //------------------------------------------------------------------
            if(PlayerInfo[i][AFKBRB] 	  == 1)             Status = "{FFFF00}AFK";
            else if(PlayerInfo[i][Hidden] == 1)             Status = "{FF8000}Hidden";
            else                                            Status = "{FFFFFF}Playing";
            //------------------------------------------------------------------
            format(Str, sizeof(Str), "Admin Name\tLevel\tStatus\tRCON Access\n{00FF00}%s{FFFFFF}(%d)\t{00BBF6}%d\t%s\t%s\n%s", PlayerName(i), i, PlayerInfo[i][Level], Status, HonnT, Str); TotalCount++;
	}
        //----------------------------------------------------------------------
        format(HonnCaption, 128, "{00BBF6}Online Admins - {FF0000}%d", TotalCount);
	//----------------------------------------------------------------------
	if(TotalCount == 0) return GameTextForPlayer(playerid, "~w~~h~No Admins ~r~~h~Online", 3000, 4);
	else return ShowPlayerDialog(playerid, 123, DIALOG_STYLE_TABLIST_HEADERS, HonnCaption, Str, "Close", "");
    }
    else return SendLangInfo(playerid, "{FF0000}Vrei sa raportezi un jucator? Foloseste /Report [ID] [Motiv] !", "Do you wanna report someone? Use /Report [ID] [Reason] !");
}
Thanks in advance and sorry for my english, I'm romanian ^_^


Re: /Admins - Need Help! - Mencent - 26.06.2016

Hello!

It's because you format the string again and again.
Do it like this:
PHP код:
CMD:admins(playerid)
{
    if(
PlayerInfo[playerid][pVip] >= || PlayerInfo[playerid][Level] >= 1)
    {
        
Str[0] = '\0';
        new 
TotalCount,HonnCaption[52],Status[64],HonnT[24],FullString[600];
        foreach(new 
iPlayer)
        {
            if(
PlayerInfo[i][Level] >= 1)
            {
                if(
IsPlayerAdmin(i))                            HonnT "{00FF00}Yes";
                else if(!
IsPlayerAdmin(i))                      HonnT "{FF0000}No";
                
//------------------------------------------------------------------
                
if(PlayerInfo[i][AFKBRB]       == 1)             Status "{FFFF00}AFK";
                else if(
PlayerInfo[i][Hidden] == 1)             Status "{FF8000}Hidden";
                else                                            
Status "{FFFFFF}Playing";
                
//------------------------------------------------------------------
                
format(Str,sizeof(Str),"{00FF00}%s{FFFFFF}(%d)\t{00BBF6}%d\t%s\t%s\n%s",PlayerName(i),i,PlayerInfo[i][Level],Status,HonnT,Str);
                
TotalCount ++;
            }
        }
        
format(FullString,sizeof(FullString),"Admin Name\tLevel\tStatus\tRCON Acces\n%s",Str);
        if(
TotalCount == 0)return GameTextForPlayer(playerid"~w~~h~No Admins ~r~~h~Online"30004);
        else return 
ShowPlayerDialog(playerid123DIALOG_STYLE_TABLIST_HEADERSHonnCaptionFullString"Close""");
    }
    else return 
SendLangInfo(playerid"{FF0000}Vrei sa raportezi un jucator? Foloseste /Report [ID] [Motiv] !""Do you wanna report someone? Use /Report [ID] [Reason] !");




Re: /Admins - Need Help! - TheHonnor - 26.06.2016

Thanks @Mencent, for your help. I will try. Now i know that this is surely the problem


Re: /Admins - Need Help! - TheHonnor - 26.06.2016

@Mencent, sorry, I have tried your how you said. But it doesn't work
If there's no online admin, the message will appear, but if there is >= 1 online admins, then the dialog won't be desplayed.

Other?


Re: /Admins - Need Help! - Sjn - 26.06.2016

PHP код:
CMD:admins(playerid)
{
    if(
PlayerInfo[playerid][pVip] >= || PlayerInfo[playerid][Level] >= 1)
    {
        
Str[0] = '\0'; new TotalCount 0HonnCaption[52], Status[64], HonnT[24];
        
//----------------------------------------------------------------------
        
foreach(new iPlayer) if(PlayerInfo[i][Level] >= 1)
        {
            if(
IsPlayerAdmin(i))                            HonnT "{00FF00}Yes";
            else if(!
IsPlayerAdmin(i))                      HonnT "{FF0000}No";
            
//------------------------------------------------------------------
            
if(PlayerInfo[i][AFKBRB]       == 1)             Status "{FFFF00}AFK";
            else if(
PlayerInfo[i][Hidden] == 1)             Status "{FF8000}Hidden";
            else                                            
Status "{FFFFFF}Playing";
            
//------------------------------------------------------------------
            
format(Strsizeof(Str), "{00FF00}%s{FFFFFF}(%d)\t{00BBF6}%d\t%s\t%s\n%s"PlayerName(i), iPlayerInfo[i][Level], StatusHonnTStr); TotalCount++;
    }
        
//----------------------------------------------------------------------
        
format(HonnCaption128"{00BBF6}Online Admins - {FF0000}%d"TotalCount);
    
//----------------------------------------------------------------------
        
switch(TotalCount)
        {
            case 
0: return GameTextForPlayer(playerid"~w~~h~No Admins ~r~~h~Online"30004);
            case 
1: return ShowPlayerDialog(playerid123DIALOG_STYLE_LISTHonnCaptionStr"Close""");
            default:
            {
                
format(Strsizeof(str), "Admin Name\tLevel\tStatus\tRCON Access\n%s"Str);
                return 
ShowPlayerDialog(playerid123DIALOG_STYLE_TABLIST_HEADERSHonnCaptionStr"Close""");
            }
        }
    }
    else return 
SendLangInfo(playerid"{FF0000}Vrei sa raportezi un jucator? Foloseste /Report [ID] [Motiv] !""Do you wanna report someone? Use /Report [ID] [Reason] !");




Re: /Admins - Need Help! - Mencent - 27.06.2016

PHP код:
CMD:admins(playerid)
{
    if(
PlayerInfo[playerid][pVip] >= || PlayerInfo[playerid][Level] >= 1)
    {
        
Str[0] = '\0';
        new 
TotalCount,HonnCaption[52],Status[64],HonnT[24],FullString[600];
        foreach(new 
iPlayer)
        {
            if(
PlayerInfo[i][Level] >= 1)
            {
                if(
IsPlayerAdmin(i))                            HonnT "{00FF00}Yes";
                else if(!
IsPlayerAdmin(i))                      HonnT "{FF0000}No";
                
//------------------------------------------------------------------
                
if(PlayerInfo[i][AFKBRB]       == 1)             Status "{FFFF00}AFK";
                else if(
PlayerInfo[i][Hidden] == 1)             Status "{FF8000}Hidden";
                else                                            
Status "{FFFFFF}Playing";
                
//------------------------------------------------------------------
                
format(Str,sizeof(Str),"{00FF00}%s{FFFFFF}(%d)\t{00BBF6}%d\t%s\t%s\n%s",PlayerName(i),i,PlayerInfo[i][Level],Status,HonnT,Str);
                
TotalCount ++;
            }
        }
        
format(HonnCaption128"{00BBF6}Online Admins - {FF0000}%d"TotalCount);
        
format(FullString,sizeof(FullString),"Admin Name\tLevel\tStatus\tRCON Acces\n%s",Str);
        if(
TotalCount == 0)return GameTextForPlayer(playerid"~w~~h~No Admins ~r~~h~Online"30004);
        else return 
ShowPlayerDialog(playerid123DIALOG_STYLE_TABLIST_HEADERSHonnCaptionFullString"Close""");
    }
    else return 
SendLangInfo(playerid"{FF0000}Vrei sa raportezi un jucator? Foloseste /Report [ID] [Motiv] !""Do you wanna report someone? Use /Report [ID] [Reason] !");

Actually it should work. Try this.


Re: /Admins - Need Help! - Sew_Sumi - 27.06.2016

Someone should at least be using strcat...

https://sampwiki.blast.hk/wiki/Strcat

Код:
strcat(FullString, Str);
You'll want to make the tab header be put in first, then add the names to each turn to Str. The FullString should then have the entire dialogue set once it's finished the loops.