SA-MP Forums Archive
how to show all connected player in one textdraw ? - 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: how to show all connected player in one textdraw ? (/showthread.php?tid=454425)



how to show all connected player in one textdraw ? - omidi - 28.07.2013

Код:
        new string[128];
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
            if(IsPlayerConnected(i)){
            format(string, sizeof(string), "%s(%d)~n~",PlayerName(i),i);
            PlayerTextDrawSetString(playerid,AllPlayerTextDraw[playerid],string);
            }

  		 }
but it only show 1 player

what should i do to print all players in the same textdraw ?


Re: how to show all connected player in one textdraw ? - Jefff - 28.07.2013

pawn Код:
new string[2000];
for(new i = 0; i < MAX_PLAYERS; i++)
    if(IsPlayerConnected(i))
        format(string, sizeof(string), "%s%s(%d)~n~",string,PlayerName(i),i);

PlayerTextDrawSetString(playerid,AllPlayerTextDraw[playerid],string);



Re: how to show all connected player in one textdraw ? - Sasino97 - 28.07.2013

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
new string[2000];
for(new i = 0; i < MAX_PLAYERS; i++)
    if(IsPlayerConnected(i))
        format(string, sizeof(string), "%s%s(%d)~n~",string,PlayerName(i),i);

PlayerTextDrawSetString(playerid,AllPlayerTextDraw[playerid],string);
format(string, sizeof(string), "%s%s(%d)~n~",string,PlayerName(i),i);
Explanation of what Jefff did:

The server is formatting again the string MAX_PLAYERS times, and only the last connected player is being shown.
But with another %s and adding string as parameter, the string will contain the old string and the new.