Players List - Textdraw problem
#1

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]);
			      }
		  }
		  }
		  }
	      }
     }
}
Reply
#2

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));
Reply
#3

Same problem..
Reply
#4

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

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

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

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

up..
Reply
#9

Код:
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.
Reply
#10

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]);
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)