Page 1 of 1
Creating a Timer
Posted: June 15th, 2011, 7:56 pm
by F |Madness| U
I managed to make a timer using loops of i decreasing each time. However, if I use printlnbold, the timer becomes very messy. By this I mean if it starts at 59, it will go down to 58, then flash back to 59, then go down to 57, then flash back to 58, then go down to 56, then flash back to 57 etc. I think this is because the printlnbold messages stay on the screen for a few seconds, they don't get deleted so it is kind of overlapping times. How could I get around this? My code is:
Code: Select all
clock()
{
level timer1();
level timer2();
level timer3();
level timer4();
}
timer1()
{
for(i=59;i>9;i--)
{
iprintlnbold("1:" + i);
wait 1;
}
}
timer2()
{
for(i=9;i>-1;i--)
{
iprintlnbold("1:0" + i);
wait 1;
}
}
timer3()
{
for(i=59;i>9;i--)
{
iprintlnbold("0:" + i);
wait 1;
}
}
timer4()
{
for(i=9;i>-1;i--)
{
iprintlnbold("0:0" + i);
wait 1;
}
}
Re: Creating a Timer
Posted: June 15th, 2011, 8:06 pm
by IzNoGoD
Create a hud element.
Read through the docs or stock scripts on how to do so.
Use settimer(60) or smthing on it.
Re: Creating a Timer
Posted: June 15th, 2011, 8:23 pm
by F |Madness| U
Okay thanks I'll look into it. I also have another large proble, but I'll create a new thread for that.
Re: Creating a Timer
Posted: June 15th, 2011, 8:45 pm
by Rezil
Code: Select all
player.timer = newclienthudelem(player);
player.timer.x = 50;
player.timer.y = 50;
player.timer.allignx = "left";
player.timer.alligny = "top";
player.timer.color = (1, 1, 1);
player.timer settimer(60);
Re: Creating a Timer
Posted: June 15th, 2011, 9:42 pm
by F |Madness| U
Ah thankyou Rezil, I didn't know there were built in timers D:
Re: Creating a Timer
Posted: June 17th, 2011, 12:26 pm
by F |Madness| U
I've ran into a problem with this, I want the timer to start as soon as the map has loaded (before anyone has even connected). And if I use this timer, player is not defined. And if I start the timer when a player connects, then each player will have a seperate timer, whereas I want just one timer where all players see the same time, similar to the match timers in bottom left hand corner. And I'm a nooby at this and can't think what I have to do to make this

Re: Creating a Timer
Posted: June 17th, 2011, 12:52 pm
by IzNoGoD
Rezil wrote:Code: Select all
player.timer = newhudelem();
timer.x = 50;
timer.y = 50;
timer.alignx = "left";
timer.aligny = "top";
timer.color = (1, 1, 1);
timer settimer(60);
Use this...
Re: Creating a Timer
Posted: June 17th, 2011, 8:38 pm
by Drofder2004
IzNoGoD wrote:Rezil wrote:Code: Select all
player.timer = newhudelem();
timer.x = 50;
timer.y = 50;
timer.alignx = "left";
timer.aligny = "top";
timer.color = (1, 1, 1);
timer settimer(60);
Use this...
Change player.timer, to simply "timer".
Re: Creating a Timer
Posted: June 17th, 2011, 11:32 pm
by IzNoGoD
Drofder2004 wrote:IzNoGoD wrote:Rezil wrote:Code: Select all
player.timer = newhudelem();
timer.x = 50;
timer.y = 50;
timer.alignx = "left";
timer.aligny = "top";
timer.color = (1, 1, 1);
timer settimer(60);
Use this...
Change player.timer, to simply "timer".
Overlooked that one..
Thanks for the correction though
Re: Creating a Timer
Posted: June 18th, 2011, 12:37 am
by F |Madness| U
Thanks all of you, I was being a retard for part of my scripting which was also why it wasn't working

Re: Creating a Timer
Posted: June 18th, 2011, 10:22 pm
by F |Madness| U
Okay, really stupid question, but how do I make the timer disappear? I tryed timer destroyelem(); , but for some reason that caused the game to freeze once it got to that line of code. Any suggestions? I'll post code in a sec.
Re: Creating a Timer
Posted: June 18th, 2011, 10:25 pm
by Drofder2004
F |Madness| U wrote:Okay, really stupid question, but how do I make the timer disappear? I tryed timer destroyelem(); , but for some reason that caused the game to freeze once it got to that line of code. Any suggestions? I'll post code in a sec.
"Destroy()" should do the job.
Re: Creating a Timer
Posted: June 18th, 2011, 10:34 pm
by F |Madness| U
Ahhh now it works, thanks once again!