Making a timer count backwards? -
Elysian` - 14.05.2012
I have my timer set to 10 minutes but how would I make it count backwards?
pawn Код:
SetTimer("Message", 600000, false);
pawn Код:
forward Message();
public Message()
{
}
AW: Making a timer count backwards? -
Blueicy - 14.05.2012
There is no "Backward-timer", but you could use a "second" timer and let a global variable count backwards.
But the determination is the same as a normal timer.
Re: Making a timer count backwards? -
iRage - 14.05.2012
You made a timer that runs once every 600 seconds.
I've changed it to be running every second reducing the
variable by 1 on each second until it reaches 0 then it will send a message.
pawn Код:
new variable = 600;
SetTimer("Message", 1000, false);
pawn Код:
forward Message();
public Message()
{
if(variable)
{
variable--;
SetTimer("Message", 1000, false);
}
else
{
// Your code here
}
}
Re: Making a timer count backwards? -
Elysian` - 14.05.2012
I want it so when the Gm starts. This is gonna be used for changing Gamemodes?
Re: Making a timer count backwards? -
Niko_boy - 14.05.2012
At top
pawn Код:
new GMtimer,second,minute;
in
OnGameModeInit()
pawn Код:
minute = 10; // minute u want..
second = 60;// real life 60 seconds
GMtimer = SetTimer("UpdateMinute",2000,false);//addded 2000 to add few lags , fix some sync prob , i discoverd while
scripting mine script
now..
add thsi callback
pawn Код:
forward UpdateMinute();
public UpdateMinute()
{
second --;
if(second <= 0)
{
minute--;// minus a minute from 10 , then 9 , then 8 and so on
second = 60;
}
if(minute <= 0 && second<=0)
{
KillTimer(GMtimer );
//code for Switching gamemde
}
else
{
GMtimer = SetTimer("UpdateMinute",1000,false);
}
}
Re: Making a timer count backwards? -
Elysian` - 14.05.2012
Thanks Niko,
But How would I add this in a textdraw?
Minutes : seconds.
Re: Making a timer count backwards? -
Elysian` - 14.05.2012
There is the textdraw:
pawn Код:
Textdraw0 = TextDrawCreate(43.000000, 428.000000, "TimeHere");
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.500000, 1.000000);
TextDrawColor(Textdraw0, -1);
TextDrawSetOutline(Textdraw0, 0);
TextDrawSetProportional(Textdraw0, 1);
TextDrawSetShadow(Textdraw0, 1);
How would I make it count backwards on here?
Re: Making a timer count backwards? -
Niko_boy - 15.05.2012
@
Windows32
..> to do that try this <<.
pawn Код:
new string[60];
format(string,sizeof(string),"%d:%d",minute,second);
TextDrawSetString(TextDraw0,string);
Under this..>
Код:
public UpdateMinute()
{
second --;
// here
Re: Making a timer count backwards? -
Libra_PL - 15.05.2012
It won't work perfecly, because if there's 5 minutes and 7 seconds, it'll show "5:7" instead of "5:07"... Try this one:
Код:
new string[60];
if(seconds < 10)
{
format(string,sizeof(string),"%d:0%d",minute,second);
}
else
{
format(string,sizeof(string),"%d:%d",minute,second);
}
TextDrawSetString(TextDraw0,string);
Re: Making a timer count backwards? -
mamorunl - 15.05.2012
That is your only problem? At the end, your time will not run sync because you load a few extra lines before restarting. Put the timer on a repeat instead of recreating it.