Count Down Textdraw bug
#1

Ey guys. So I created a basic countdown and for some reason it glitches the last numbers are stayng allways.
I mean exemple countdow is 10 secconds
So it goes from 10 to 9 - 10stays then 9 stays then 8 and so on..

hares my script. I have no idea how to fix it..

Код:
new CountDownFromAmount;
new PlayerText:dcd[MAX_PLAYERS];
new DeathTm[MAX_PLAYERS];
command(cds, playerid, params[])
{
	CountDownFromAmount = 10;
	DeathTm[playerid] = SetTimerEx(" CountDownTimer",1000,true,"i",playerid);
	return 1;
}

forward CountDownTimer(playerid);

public CountDownTimer(playerid)
{
	CountDownFromAmount--;
	new string[128];
	format(string, 128, "%d", CountDownFromAmount);
	dcd[playerid] = CreatePlayerTextDraw(playerid, 100, 100, string);
	PlayerTextDrawShow(playerid, dcd[playerid]);
	PlayerTextDrawUseBox(playerid, dcd[playerid], 0);
	PlayerTextDrawSetOutline(playerid, dcd[playerid], 0);
	PlayerTextDrawSetShadow(playerid, dcd[playerid], 0);
	PlayerTextDrawSetProportional(playerid, dcd[playerid], 1);
	PlayerTextDrawSetOutline(playerid, dcd[playerid], 0);
	if (CountDownFromAmount == 0)
	{
		GameTextForAll("End of round!!", 3000, 5);
	}
	return 1;
}
Tryed so much ways none worked. Help? :X
Reply
#2

You should create the textdraw once, and update it every second.
You're just creating new ones on top of the others, which are never destroyed.

Create the textdraw in your command and store it's ID in an array.
Then use PlayerTextDrawSetString to update it inside your timer.

Also, when the timer reaches 0, use KillTimer to stop counting down, otherwise it will keep running forever.
Reply
#3

Oh yah Thanks for the response that seems logical why didint I think if that..
And about kill ye Ik that, Im just using this for testing Ill add it up though. Thanks. Ill get back to ya if I wont know something. Ill give u rep :>
edit:

PS. How can I set its string to one and position the text draw where I want?

Should I do something like that?

Код:
dcd[playerid] = CreatePlayerTextDraw(playerid, 100, 100, " ");
PlayerTextDrawSetString(playerid, dcd[playerid], string);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)