stop the stopwatch

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

stop the stopwatch

Post by ViPER »

I want the stopwatch to run as long as one or more team members is in the trigger. I want it to break if they all leave the trigger or if an opossing team player enters the trigger?

Also -

while(1) the stopwatch keeps starting over every frame unless player leaves the trigger, how do i get just one trigger event per teams initial activation of the trigger?

Code: Select all

timer local.o local.sa local.sb local.m:

local.stopwtrg = spawn Trigger_multiple
local.stopwtrg.origin = ( local.o )
local.stopwtrg setsize ( local.sa ) ( local.sb )
local.stopwtrg targetname stopwtrg
local.stopwtrg setthread stopwtimer local.m

stopwtimer local.m:

while(1)
{
	$stopwtrg waittill trigger
	parm.other stopwatch local.m
}
end
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

the only thing is only one player can see your stopwatch . This will work for the way you have it .
stopwtimer local.m:

while(1)
{
$stopwtrg waittill trigger
local.player = parm.other
local.team = local.player.dmteam
local.player stopwatch local.m

level.team_check = 1
level.time_check = 1

thread team_check local.team
thread time_check local.m

while(level.team_check == 1 && level.time_check == 1) // wait while both are true
waitframe
}
end

team_check local.team:

while(level.time_check == 1) // loop while timer is running or untill team check fails
{
local.check = 0

for(local.i=0;local.i <= $player.size;local.i++)
{
if ($player[local.i] istouching $stopwtrg && $player[local.i].dmteam == local.team)
local.check = 1
}

if(local.check == 0) // team check fails
{
level.team_check = 0
end
}

waitframe

}

end

time_check local.m:

for(local.time = local.m;local.time > 0;local.time--)
{
if(level.team_check == 0)
goto end_timer // if team check fails goto label ending the time check

wait 1
}

end_timer: // this is a label inside a thread

level.time_check = 0

end
Image
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post by ViPER »

TY bdbodger, i've been fooling around with this stopwatch so long I was about to scrap the idea. There is a problem with my script however, I'll try to get it working and if i cant in the next couple days ill post the whole thing.
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

text

Post by tltrude »

You could also use hud draw to print the timer on everyones screen.

This was used to print countdown and health of a missle.

Code: Select all

	level waittill spawn

	level.misslehealth = 100 // percent
	level.missle_health = 8000  // trigger's health in the map.
	level.win_points = 300 // countdown in seconds.
	level.counter = level.win_points

//----------------------------------------------------------->
//   active scoreboard
//----------------------------------------------------------->

print_points:

	while (1) 
	{ 
	waitthread hudprint ("Countdown: " + (level.counter) + " seconds" + "\n" + "Missile health: " + (level.misslehealth) + " percent" ) .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
Tom Trude,

Image
User avatar
«{T§F}»Puckeye
Private
Posts: 7
Joined: Sun Sep 03, 2006 3:51 am
Location: Joliette, Québec, Canada
Contact:

Post by «{T§F}»Puckeye »

Could you tell me how huddrawm works?

I mean I know I could just copy and paste but I like to understand what the numbers are doing and sometimes trial and error just doesn't give all the answers... :)
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Post by tltrude »

huddraw_rect 187 140 -84 50 50 // size on the screen
//the last four numbers are pixcles for the sides of a rectangle (box where things will be drawn).

huddraw_color 187 local.r local.g local.b // color of the text
//the last three variables (.75 .65 .1) are RGB numbers from the the thread above.

huddraw_font 187 "facfont-20" //game font to use

huddraw_string 187 local.nstring //string to print
//the variable is set in the thread above.

huddraw_align 187 left bottom // general location on the screen to place the box.

huddraw_alpha 187 1 // 1 means the background of the box is see-through.


That's all I can remember for now. There are more huddraw things that can be set.
Last edited by tltrude on Sun Sep 03, 2006 10:19 am, edited 1 time in total.
Tom Trude,

Image
User avatar
«{T§F}»Puckeye
Private
Posts: 7
Joined: Sun Sep 03, 2006 3:51 am
Location: Joliette, Québec, Canada
Contact:

Post by «{T§F}»Puckeye »

Thanks :)

What's the 187?

Some kind of ID for the huddraw position?
Brigadier General Puckeye
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

187

Post by tltrude »

Yes, I think so. It doesn't seem to matter what ID number is used, as long as it doesn't conflict with other huddraw IDs used in the game.
Tom Trude,

Image
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

Yeah, Tom's very right. :) It's the element number in an array of 256 (from 0 to 255). If you use the same ID for 2 different things, one of them is going to be overwritten.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Post Reply