Possible?
#1

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!! =)
Reply
#2

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

Okay. Yes thats the kind of thing I want. Is there a tutorial for this? Thanks
Reply
#4

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

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

Thankyou!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)