SA-MP Forums Archive
Players List - Textdraw problem - 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: Players List - Textdraw problem (/showthread.php?tid=578346)



Players List - Textdraw problem - SiNuS - 18.06.2015

Hi, i want to do a Textdraw with a list of players.

I want something like this: http://s20.postimg.org/ohwbu6njx/sa_mp_004.png
But player names are not added as above ( like a list )
Simply, the first player is replaced by the second , there isn"t a new line.
Here is my code:
What"s wrong?
Код:
stock RefreshWantedList()
{
    foreach(Player, i)
    {
	      if(IsPlayerConnected(i))
		  {
          new suspectname[MAX_PLAYER_NAME], string[128];
		  foreach(Player, c)
          {
	      if(IsPlayerConnected©)
		  {
		  if(WantedShow[c] > 0 && IsACop©)
		  {
                  PlayerTextDrawHide(c, WantedHeader[c]);
                  //PlayerTextDrawHide(c, WantedList[c]);
                  PlayerTextDrawShow(c, WantedHeader[c]);
                  GetPlayerName(i, suspectname, sizeof(suspectname));
                  if(WantedLevel[i] >= 1)
			      {
                      PlayerTextDrawHide(c, WantedList[c]);
			          format(string, sizeof(string), "ID: %d - Name: %s - WL: %d~n~",i,suspectname,WantedLevel[i]);
			          PlayerTextDrawSetString(c, WantedList[c], string);
			          PlayerTextDrawShow(c, WantedList[c]);
			      }
		  }
		  }
		  }
	      }
     }
}



Re: Players List - Textdraw problem - Darkwood17 - 18.06.2015

Try this:
PHP код:
stock RefreshWantedList()
{
    foreach(
Playeri)
    {
        if(
IsPlayerConnected(i))
        new 
suspectname[MAX_PLAYER_NAME], string[128];
        
GetPlayerName(isuspectnamesizeof(suspectname));
        foreach(
Playerc)
        {
            if(
IsPlayerConnected(c))
            if(
WantedShow[c] > && IsACop(c))
            {
                
PlayerTextDrawHide(cWantedHeader[c]);
                
//PlayerTextDrawHide(c, WantedList[c]);
                
PlayerTextDrawShow(cWantedHeader[c]);
                if(
WantedLevel[i] >= 1)
                {
                    
PlayerTextDrawHide(cWantedList[c]);
                    
format(stringsizeof(string), "ID: %d - Name: %s - WL: %d~n~",i,suspectname,WantedLevel[i]);
                    
PlayerTextDrawSetString(cWantedList[c], string);
                    
PlayerTextDrawShow(cWantedList[c]);
                }
            }
        }
    }

This should be under if(IsPlayerConnected(i)) check:
Код:
GetPlayerName(i, suspectname, sizeof(suspectname));



Re: Players List - Textdraw problem - SiNuS - 18.06.2015

Same problem..


Re: Players List - Textdraw problem - AndySedeyn - 18.06.2015

You don't have to use the "IsPlayerConnected" function because foreach does that internally! You are also using an outdated syntax of foreach.

PHP код:
foreach(new Player



Re: Players List - Textdraw problem - SiNuS - 18.06.2015

Ok. The code now:

Код:
stock RefreshWantedList()
{
    foreach(new i : Player)
    {
        new suspectname[MAX_PLAYER_NAME], string[128];
        GetPlayerName(i, suspectname, sizeof(suspectname));
        foreach(new c : Player)
        {
            if(WantedShow[c] > 0 && IsACop©)
            {
                PlayerTextDrawHide(c, WantedHeader[c]);
                PlayerTextDrawShow(c, WantedHeader[c]);
                if(WantedLevel[i] >= 1)
                {
                    PlayerTextDrawHide(c, WantedList[c]);
                    format(string, sizeof(string), "ID: %d - Name: %s - WL: %d~n~",i,suspectname,WantedLevel[i]);
                    PlayerTextDrawSetString(c, WantedList[c], string);
                    PlayerTextDrawShow(c, WantedList[c]);
                }
            }
        }
    }
}
Still same problem..


Re: Players List - Textdraw problem - AndySedeyn - 18.06.2015

That's because you are changing the same textdraw with new information. You are not actually creating new textdraws. You make an x amount of textdraws, whereas x is equal to the amount of lines you want to show. You show the equal amount of textdraws as there is information.

That might not be as understandable as it is for me. To put it into steps:
- Create a fix set amount of textdraws (if you want to have maximum 10 lines on the screen, then create 10 textdraws).
- Update the first textdraw with new information and the second textdraw with the old information from the first textdraw (And so on..- Every time new information is acquired, you update the first line with the new info, and update the rest with old information).


Re: Players List - Textdraw problem - SiNuS - 19.06.2015

This is the single option ? .. because i don"t get it


Re: Players List - Textdraw problem - SiNuS - 24.06.2015

up..


Re: Players List - Textdraw problem - Shetch - 24.06.2015

Код:
stock RefreshWantedList()
{
    foreach(new i : Player)
    {
        new suspectname[MAX_PLAYER_NAME], string[128];
        GetPlayerName(i, suspectname, sizeof(suspectname));
        foreach(new c : Player)
        {
            if(WantedShow[c] > 0 && IsACop©)
            {
                PlayerTextDrawHide(c, WantedHeader[c]);
                PlayerTextDrawShow(c, WantedHeader[c]);
                if(WantedLevel[i] >= 1)
                {
                    PlayerTextDrawHide(c, WantedList[c]);
                    format(string, sizeof(string), "%sID: %d - Name: %s - WL: %d~n~",string,i,suspectname,WantedLevel[i]);
                    PlayerTextDrawSetString(c, WantedList[c], string);
                    PlayerTextDrawShow(c, WantedList[c]);
                }
            }
        }
    }
}
Try this.


Re: Players List - Textdraw problem - Jefff - 24.06.2015

pawn Код:
stock RefreshWantedList()
{
    new suspectname[MAX_PLAYER_NAME], szTemp[55], szStr[55 char], string[1024 char];
    foreach(new i : Player)
    {
        if(WantedLevel[i] > 0)
        {
            GetPlayerName(i, suspectname, MAX_PLAYER_NAME);
            format(szTemp, sizeof(szTemp), "ID: %d - Name: %s - WL: %d~n~",i,suspectname,WantedLevel[i]);
            strpack(szStr,szTemp);
            strcat(string,szStr);
        }
    }
    foreach(new c : Player)
    {
        if(WantedShow[c] > 0 && IsACop(c))
        {
            PlayerTextDrawSetString(c, WantedList[c], string);
            PlayerTextDrawShow(c, WantedList[c]);
        }
    }
}