Stats TextDraw Bug
#1

Hello, I'v added to my server stats such as kills deaths,score, i'v added it under onplayerupdate or even set a timer, its working for few mins , then when i get more players and relog , the stats is disappearing, is that a bug or there are wrong something ?
Reply
#2

May I see your code ?
Reply
#3

Код:
/*
	**************************
	Filtsript version v3.3  **
	**************************
*/


#include <a_samp>


enum PlayerDB
{
	Kills,
	Deaths,
	bool:Box,
}
new PlayerData[MAX_PLAYERS][PlayerDB];
forward StatsInfromation();


new Text: PlayerStats[MAX_PLAYERS];
new Text: Textdraw1;



public OnFilterScriptInit()
{
	
	SetTimer("StatsInfromation",1000 , 1);
 	for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
 	{
	    PlayerStats[playerid] = TextDrawCreate(231.000000,405.000000,"-");
	    Textdraw1 = TextDrawCreate(260.000000,391.000000,"STATS");
	    TextDrawUseBox(PlayerStats[playerid],1);
	    TextDrawBoxColor(PlayerStats[playerid],0xffffff33);
	    TextDrawTextSize(PlayerStats[playerid],389.000000,119.000000);
	    TextDrawAlignment(PlayerStats[playerid],0);
	    TextDrawAlignment(Textdraw1,0);
	    TextDrawBackgroundColor(PlayerStats[playerid],0x000000ff);
	    TextDrawBackgroundColor(Textdraw1,0xff000033);
	    TextDrawFont(PlayerStats[playerid],2);
	    TextDrawLetterSize(PlayerStats[playerid],0.399999,1.200000);
	    TextDrawFont(Textdraw1,2);
	    TextDrawLetterSize(Textdraw1,0.799999,1.300000);
	    TextDrawColor(PlayerStats[playerid],0xffffffff);
	    TextDrawColor(Textdraw1,0xffffffff);
	    TextDrawSetOutline(PlayerStats[playerid],1);
	    TextDrawSetOutline(Textdraw1,1);
	    TextDrawSetProportional(PlayerStats[playerid],1);
	    TextDrawSetProportional(Textdraw1,1);
	    TextDrawSetShadow(PlayerStats[playerid],1);
	    TextDrawSetShadow(Textdraw1,1);

	}
	return 1;
}

//______________________________________________________________________________
public OnFilterScriptExit()
{
    for(new i = 0;i < MAX_PLAYERS; i++)
    {
        TextDrawDestroy(PlayerStats[i]);
    }
    TextDrawDestroy(Textdraw1);
	return 1;
}
//______________________________________________________________________________
public OnPlayerConnect(playerid)
{


	TextDrawShowForPlayer(playerid, PlayerStats[playerid]);
	TextDrawShowForPlayer(playerid, Textdraw1);

	return 1;
}
//______________________________________________________________________________



//______________________________________________________________________________
public StatsInfromation()
{
    new str[128];
	for(new i=0;i<MAX_PLAYERS;i++)
	{
		if (IsPlayerConnected(i))
	    {
	        format(str, sizeof(str), "Kills: %d - Deaths: %d" , PlayerData[i][Kills], PlayerData[i][Deaths]);
	        TextDrawSetString(PlayerStats[i],str);
    	}
	}
	return 1;
}
//______________________________________________________________________________
//                            2009/2010 ©
Reply
#4

Which textdraw is disappearing ? Both of them ?
Reply
#5

Create per-player textdraws instead of what your doing and you don't even need to use a timer, just update the textdraw every time the stat changes.

Example:
pawn Код:
new PlayerText:Time[MAX_PLAYERS];

Time[playerid] = CreatePlayerTextDraw(playerid, 554.000000, 205.000000, "~g~05:00");
PlayerTextDrawAlignment(playerid, Time[playerid], 2);
PlayerTextDrawBackgroundColor(playerid, Time[playerid], 22);
PlayerTextDrawFont(playerid, Time[playerid], 2);
PlayerTextDrawLetterSize(playerid, Time[playerid], 0.560000, 6.100000);
PlayerTextDrawColor(playerid, Time[playerid], -1);
PlayerTextDrawSetOutline(playerid, Time[playerid], 1);
PlayerTextDrawSetProportional(playerid, Time[playerid], 1);
PlayerTextDrawSetSelectable(playerid, Time[playerid], 0);

// To update the textdraw
new string[128];
format(string, sizeof (string), "~g~%02d:%02d", minutes, seconds);
PlayerTextDrawSetString(playerid, Time[playerid], string);
Reply
#6

Quote:
Originally Posted by RenovanZ
Посмотреть сообщение
Which textdraw is disappearing ? Both of them ?
Both of them, i must restart server to back it.
Reply
#7

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Create per-player textdraws instead of what your doing and you don't even need to use a timer, just update the textdraw every time the stat changes.

Example:
pawn Код:
new PlayerText:Time[MAX_PLAYERS];

Time[playerid] = CreatePlayerTextDraw(playerid, 554.000000, 205.000000, "~g~05:00");
PlayerTextDrawAlignment(playerid, Time[playerid], 2);
PlayerTextDrawBackgroundColor(playerid, Time[playerid], 22);
PlayerTextDrawFont(playerid, Time[playerid], 2);
PlayerTextDrawLetterSize(playerid, Time[playerid], 0.560000, 6.100000);
PlayerTextDrawColor(playerid, Time[playerid], -1);
PlayerTextDrawSetOutline(playerid, Time[playerid], 1);
PlayerTextDrawSetProportional(playerid, Time[playerid], 1);
PlayerTextDrawSetSelectable(playerid, Time[playerid], 0);

// To update the textdraw
new string[128];
format(string, sizeof (string), "~g~%02d:%02d", minutes, seconds);
PlayerTextDrawSetString(playerid, Time[playerid], string);
Thanks + rep , but where to add both of functions? onplayerupdate?
Reply
#8

Quote:
Originally Posted by SPA
Посмотреть сообщение
Thanks + rep , but where to add both of functions? onplayerupdate?
You should place the first function to OnPlayerConnect (dont forget to show it).
Also, you shouldn't place the second function to OnPlayerUpdate, just place it OnPlayerDeath, because Death and Kills only updated at the OnPlayerDeath, right ?
Reply


Forum Jump:


Users browsing this thread: