Onlie Players
#1

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??
Reply
#2

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

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)
Reply
#4

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

create an loop for this textdraw
Reply
#6

Wut?
Reply
#7

new PlayersOnline[MAX_PLAYERS];

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

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
Reply
#9

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

Hold on..

EDIT: Nope.. same
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)