Page 1 of 1

Scripting a timer

Posted: Sat Sep 02, 2006 12:19 pm
by SniperWolf
In my training map I also have an Obstacle Course. Was wonder if there was a way to script/map in a timer so that it starts when you start it & stops when you finish???

If so is it possible to use the timer that the game uses for RB map(top left corner)???

Thanks in advance

Posted: Sat Sep 02, 2006 2:44 pm
by Green Beret
Use a trigger to start the timer, And another to stop it?
Of coarse with setthreads.

Posted: Sat Sep 02, 2006 10:57 pm
by SniperWolf
Thanks Green Beret.

i figured that but what would i have to do to get the clock??

anyone know the command(s)???

Also would everyone on the map see it or just the person that activates the trigger?? would be great if everyone could see it.

Posted: Sun Sep 03, 2006 1:40 am
by Ophisâ„¢
if you use the stop watch that is usaed for bombs, i would have thurt everyone could see it? i dont know this answer..

Posted: Sun Sep 03, 2006 4:10 am
by SniperWolf
I have been on server where it tells you how long you stayed alive in seconds. Does anyone know that script or how it was done?

timer

Posted: Sun Sep 03, 2006 4:35 am
by tltrude
Here is one you can try -- I'm not sure it will work. The trigger should be a trigger_multiple that goes from the start line to the finish line. give it these key /values.

Key: targetname
Value: obsticle_trigger

Key: setthread
Value: counter

Code: Select all

main:
	level waitTill prespawn

	level.counter = 0

	level waitTill spawn
	thread print_time

end


//----------------------------------------------------------->
//   active timer
//----------------------------------------------------------->

print_time:

	while (1) 
	{ 
	waitthread hudprint ("Time Count: " + (level.counter) + " seconds") .75 .65 .1  // three numbers are for color (gold)
	} 
 	waitframe
end

hudprint local.nstring local.r local.g local.b:

	huddraw_rect 187 140 -84 50 50 
	huddraw_color 187 local.r local.g local.b 
	huddraw_font 187 "facfont-20" 
	huddraw_string 187 local.nstring 
	huddraw_align 187 left bottom 
	huddraw_alpha 187 1

	wait .5 //refresh time 

end

counter:
	local.runner = parm.other
	while (1)
	{
		level.counter = level.counter + 1
		wait 1
		if (!local.runner istouching $obsticle_trigger) //checks to see if the player has left the trigger
			{
			thread global/message_print.scr::message "TIME!" NIL 4 // stays on screen for 4 seconds
			break
			}
	}
	wait 10
	level.counter = 0
end
The time display will not work for more than one player at a time. So, players will have to wait for the time to reset to 0 before the next guy goes.