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



Online Players - Micko123 - 03.11.2016

Hey guys. I want to make online player count. Is there any way to do it without timer??
I tried like this
PHP код:
public OnPlayerConnect(playerid)
{
        
format(string1sizeof(string1), "%d"Iter_Count(Player));
    
PlayerTextDrawSetString(playeridOnlineRecordTD[playerid][2], string1);
    return 
1;

But it is not working

Do I need to use timer??


Re: Onlie Players - oMa37 - 03.11.2016

Make it a global textdraw, This function will change the textdraw string ONLY for the player that have joined.


Respuesta: Re: Onlie Players - Ner0x96 - 04.11.2016

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Make it a global textdraw, This function will change the textdraw string ONLY for the player that have joined.
Agree hehe.
But you have to put it in OnPlayerDisconnect to (the count will be '--' and the TD will have to get updated)


Re: Onlie Players - Micko123 - 04.11.2016

I have this
PHP код:
new PlayersOnline//global
public OnPlayerConnect(playerid)
{
        new 
string2[5];
    
PlayersOnline ++;
    
format(string2sizeof(string2), "%d%"PlayersOnline);
        
TextDrawSetString(OnlineRecordTD[2], string2);
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
       
PlayersOnline --;
       
format(string2sizeof(string2), "%d%"PlayersOnline);
       
TextDrawSetString(OnlineRecordTD[2], string2);    
        return 
1;

But still not working I created TD like this
PHP код:
OnlineRecordTD[2] = TextDrawCreate(112.666671290.551269"1000");
    
TextDrawLetterSize(OnlineRecordTD[2], 0.4000001.600000);
    
TextDrawAlignment(OnlineRecordTD[2], 1);
    
TextDrawColor(OnlineRecordTD[2], 16777215);
    
TextDrawSetShadow(OnlineRecordTD[2], 0);
    
TextDrawSetOutline(OnlineRecordTD[2], 0);
    
TextDrawBackgroundColor(OnlineRecordTD[2], 255);
    
TextDrawFont(OnlineRecordTD[2], 1);
    
TextDrawSetProportional(OnlineRecordTD[2], 1);
    
TextDrawSetShadow(OnlineRecordTD[2], 0); 
When I join it says 1000.. Any ideas?


Re: Onlie Players - Hunud - 04.11.2016

create an loop for this textdraw


Re: Onlie Players - Micko123 - 04.11.2016

Wut?


Re: Onlie Players - Hunud - 04.11.2016

new PlayersOnline[MAX_PLAYERS];

On each an created textdraw onlinerecordTd add [playerid] and put that textdraw in loop


Re: Onlie Players - Micko123 - 04.11.2016

This is wheat they said..

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Make it a global textdraw, This function will change the textdraw string ONLY for the player that have joined.
And I tried with player textdraw.. same problem


Re: Onlie Players - RoboN1X - 04.11.2016

Try this:
Код:
new PlayersOnline;
public OnGameModeInit()
{

	OnlineRecordTD[2] = TextDrawCreate(112.666671, 290.551269, "0");
	TextDrawLetterSize(OnlineRecordTD[2], 0.400000, 1.600000);
	TextDrawAlignment(OnlineRecordTD[2], 1);
	TextDrawColor(OnlineRecordTD[2], 16777215);
	TextDrawSetShadow(OnlineRecordTD[2], 0);
	TextDrawSetOutline(OnlineRecordTD[2], 0);
	TextDrawBackgroundColor(OnlineRecordTD[2], 255);
	TextDrawFont(OnlineRecordTD[2], 1);
	TextDrawSetProportional(OnlineRecordTD[2], 1);
	TextDrawSetShadow(OnlineRecordTD[2], 0);

	return 1;
}

public OnPlayerConnect(playerid)
{

	if(!IsPlayerNPC(playerid))
	{
		new pcount[5];
		valstr(pcount, ++PlayersOnline);
		TextDrawSetString(OnlineRecordTD[2], pcount);
		TextDrawShowForPlayer(playerid, OnlineRecordTD[2]);
	}

	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{

	if(!IsPlayerNPC(playerid))
	{
		new pcount[5];
		valstr(pcount, --PlayersOnline);
		TextDrawSetString(OnlineRecordTD[2], pcount);
	}
	
	return 1;
}
EDIT: Of course, you have to declare new OnlineRecordTD[] as global as well.

Sorry for my bad english.


Re: Onlie Players - Micko123 - 04.11.2016

Hold on..

EDIT: Nope.. same