Scripting a timer

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Scripting a timer

Post 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
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

Use a trigger to start the timer, And another to stop it?
Of coarse with setthreads.
Image
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post 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.
Ophisâ„¢
Colonel
Posts: 461
Joined: Sun Mar 12, 2006 2:30 pm
Location: England, Manchester
Contact:

Post 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..
Image[ Formerly Known As Snakeâ„¢ ]
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post 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?
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

timer

Post 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.
Tom Trude,

Image
Post Reply