SA-MP Forums Archive
Possible? - 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: Possible? (/showthread.php?tid=304802)



Possible? - KingyKings - 19.12.2011

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!! =)


Re: Possible? - Gamer_Z - 19.12.2011

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.


Re: Possible? - KingyKings - 19.12.2011

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


Re: Possible? - Rob_Maate - 19.12.2011

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.



Re: Possible? - Gamer_Z - 19.12.2011

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"


Re: Possible? - KingyKings - 19.12.2011

Thankyou!