Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!
Moderator: Core Staff
-
Opel
- CJ Fan
- Posts: 188
- Joined: September 15th, 2008, 12:28 pm
- Location: Scotland
Post
by Opel » May 2nd, 2010, 8:46 pm
Hey guys im wondering if it is possible to pause the timer i made so the person can see thier time when the press frag button. This is the code i use to destroy it so if it is possible how would i change it? If you dont get me here is a video.
http://www.xfire.com/video/29ad18/
Code: Select all
TimerButtonstop()
{
self endon("disconnect");
self endon("killed_player");
self endon("joined_spectators");
for(;;)
{
if( self fragButtonPressed() && self isOnGround() )
{
self thread removetimer();
wait 1;
}
wait 0.05;
}
}
removetimer()
{
self endon("disconnect");
self endon("killed_player");
self endon("joined_spectators");
self.timer destroy();
}
-
Drofder2004
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Post
by Drofder2004 » May 3rd, 2010, 2:33 am
where is the code for your timer?
All you are currently doing is destroying it (which looking at your code is going to cause "undefined object" errors.
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
-
Opel
- CJ Fan
- Posts: 188
- Joined: September 15th, 2008, 12:28 pm
- Location: Scotland
Post
by Opel » May 3rd, 2010, 8:08 am
here is the full script. some of it when out of line
Code: Select all
TimerButton()
{
self endon("disconnect");
self endon("killed_player");
self endon("joined_spectators");
check1 = false;
for(;;)
{
if( self useButtonPressed() && self isOnGround() )
{
check1 = true;
wait 0.5;
}
if( check1 && self attackButtonPressed() )
{
self thread timerstart();
wait 1;
check1 = false;
}
wait 0.05;
check1 = false;
}
}
TimerButtonstop()
{
self endon("disconnect");
self endon("killed_player");
self endon("joined_spectators");
for(;;)
{
if( self fragButtonPressed() && self isOnGround() )
{
self thread removetimer();
wait 1;
}
wait 0.05;
}
}
removetimer()
{
self endon("disconnect");
self endon("killed_player");
self endon("joined_spectators");
self.timer destroy();
}
timerstart()
{
self endon("disconnect");
self endon("killed_player");
self endon("joined_spectators");
self endon("stop_timer");
self.timer = newHudElem(self);
self.timer.alignX = "center";
self.timer.alignY = "middle";
self.timer.horzAlign = "center";
self.timer.vertAlign = "top";
self.timer.y = 100;
self.timer.fontScale = 1.6;
self.timer.color = (0.8, 1.0, 0.8);
self.timer.font = "objective";
self.timer.glowColor = (0.3, 0.6, 0.3);
self.timer.glowAlpha = 1;
//self.timer SetPulseFX( 30, 900000, 700 );//something, decay start, decay duration
self.timer.hidewheninmenu = true;
self.timer.label = &"Time ";
self.timer SetTenthsTimerUp( 1 );
}
-
Drofder2004
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Post
by Drofder2004 » May 4th, 2010, 12:24 pm
I personally would change your method of doing it and creating your own timer.
Code: Select all
self endon("end_time")
self.timer = 0;
time = 0.1;
while(1)
{
wait time;
self.timer += time;
}
Use that is the value of a HUD element and then, when doing a 'self notify' you will stop the counter and the time will be kept on the elem until you destroy that.
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
-
Opel
- CJ Fan
- Posts: 188
- Joined: September 15th, 2008, 12:28 pm
- Location: Scotland
Post
by Opel » May 10th, 2010, 4:07 pm
Thanks mate. Just had time to try it and it works great
Users browsing this forum: No registered users and 1 guest