Posts: 143
Threads: 52
Joined: Aug 2011
Reputation:
0
Hi guys. Is it possible to make the online players of a server come up in text draw? I am making a lobby kind of thing like cod and I need to know if it is possible and if so how?
I will be so great full if someone can help!! =)
Posts: 1,047
Threads: 23
Joined: Jun 2009
if you mean a list of all players in a TD it's quite simple, make the textdraw, get all player names, format them into a string [max 1024 chars, no colors] and apply the string to the textdraw.
Posts: 143
Threads: 52
Joined: Aug 2011
Reputation:
0
Okay. Yes thats the kind of thing I want. Is there a tutorial for this? Thanks
Posts: 1,047
Threads: 23
Joined: Jun 2009
Quote:
Originally Posted by Rob_Maate
It's all very easy mate.
pawn Код:
//You'll need an array of course new OnlinePlayers[MAX_PLAYERS][MAX_PLAYER_NAME];
//In OnGameModeInit for(new i=0; i<MAX_PLAYERS; i++) { OnlinePlayers[playerid] = "$$NULL$$" //Or whatever, I've always used this for a null string }
//In OnPlayerConnect OnlinePlayers[playerid] = GetPlayerName(playerid);
//In OnPlayerDisconnect OnlinePlayers[playerid] = "$$NULL$$"
//Now. Wherever you initialize the updated textdraw, you want this above it new output[1024]; for(new i=0; i<MAX_PLAYERS; i++) { if(strcmp("$$NULL$$", OnlinePlayers[i] != 0) //Doesn't find it { format(output, sizeof(output), "%s%s\n", output, OnlinePlayers[i]); //Add the online player's name to the list } } //Now just print the textdraw WITH "output" as the td-text.
|
new lines for textdraws are prefixed with "~n~" instead of "\n"