Problem with textdraw countdown -
Face9000 - 05.06.2011
Hi guys,i created a textdraw command when a player enter in a zone,all works but it shows:
"Stay here for -240 seconds"
Where normal should be "Stay here for 60 seconds..59..58"
Here's the code:
pawn Код:
forward CountDown(playerid);
public CountDown(playerid)
{
seconds--;
new string[178];
format(string,sizeof(string),"Stay in the turf %d for take over it!",seconds);
TextDrawSetString(CountDownTD,string);
if(seconds == 0)
{
TextDrawHideForPlayer(playerid, CountDownTD);
}
return 1;
}
pawn Код:
SetTimerEx("CountDown", 120000, true, "i", 1);
What's wrong?Thanks for help.
Re: Problem with textdraw countdown -
Mean - 05.06.2011
Before the forward, try to put
Re: Problem with textdraw countdown -
Face9000 - 05.06.2011
Thanks,but now the seconds doesnt decrease on textdraw.
They're frozen at: "Stay in the turf for 60 seconds"
How to fix?
Re: Problem with textdraw countdown -
Face9000 - 06.06.2011
Anyone can help me?
Re: Problem with textdraw countdown -
Mean - 06.06.2011
You need to hide it and re-show it to update probbably.
Re: Problem with textdraw countdown -
Face9000 - 06.06.2011
Already tried,it doens't work
AW: Problem with textdraw countdown -
Nero_3D - 06.06.2011
Mh the countdown code looks okey BUT look the timer
pawn Код:
SetTimerEx("CountDown", 120000, true, "i", 1);
it only gets called each 120000ms :O
And there should be playerid instead of a 1 at the end
Than the timer never stops after completing (no KillTimer)
I would write a Countdown like that
pawn Код:
forward TurfCountDown(playerid, seconds);
public TurfCountDown(playerid, seconds)
{
static string[64] = "Stay in the turf ";
varstr(string[17], seconds, false);
strcat(string, " for take over it!");
TextDrawSetString(CountDownTD, string);
if(--seconds < 0) {
TextDrawHideForPlayer(playerid, CountDownTD);
} else {
TextDrawShowForPlayer(playerid, CountDownTD);
SetTimerEx("TurfCountDown", 1000, false, "ii", playerid, seconds);
}
}
This code can be used more as once at the same time
Re: Problem with textdraw countdown -
Face9000 - 06.06.2011
I use killtimer in the gangzone turf (when the turf is done taken),the only problem that textdraw shows only:
"Stay in the turf for 120 seconds"
But the seconds doesnt decrease...
And i use "i" because i do a loop on all players.
AW: Problem with textdraw countdown -
Nero_3D - 06.06.2011
Quote:
Originally Posted by Logitech90
I use killtimer in the gangzone turf (when the turf is done taken),the only problem that textdraw shows only:
"Stay in the turf for 120 seconds"
But the seconds doesnt decrease...
And i use "i" because i do a loop on all players.
|
Sure that the countdown doesnt decrease if the code only gets called each 120 seconds
You need to call it each seconds!
And you should know that "i" is just the format for SetTimerEx not the parameter
You just send a 1 to your function Countdown
I would recommend the wiki page about SetTimerEx, it looks like that there are some things unclear
Re: Problem with textdraw countdown -
Face9000 - 06.06.2011
Umh,so,what i need to do?
I need only to decrease timer or what?
Thanks for patience.
Re: Problem with textdraw countdown -
Basicz - 06.06.2011
Errrrrrrrrrr........... Like this ?
pawn Код:
new
seconds = 60
;
forward CountDown(playerid);
public CountDown(playerid)
{
seconds--;
new string[178];
format(string,sizeof(string),"Stay in the turf %d for take over it!",seconds);
TextDrawSetString(CountDownTD,string);
if(seconds == 0)
{
TextDrawHideForPlayer(playerid, CountDownTD);
KillTimer( countTimer[ playerid ] );
seconds = 60;
}
return 1;
}
new
countTimer[ MAX_PLAYERS ]
;
countTimer[ playerid ] = SetTimerEx("CountDown", 1000, true, "i", playerid);
Re: Problem with textdraw countdown -
Face9000 - 06.06.2011
Fixed.