Page 1 of 4

Obstacle Course Timer

Posted: Mon Dec 11, 2006 12:55 am
by SniperWolf
Was wondering if it possible for SH to keep track of how long a player is inside a trigger??

I figure if i make a huge trigger over my Obstacle Course, I could have SH start a clock when the y enter it & stop it when they exit it.

Is this possible at all??

And if I can get that to work, is there a way to display the time on screen after they exit the trigger??

Any help would be GREATLY APPRECIATED :D

Posted: Mon Dec 11, 2006 2:12 am
by ViPER
more than one player at a time? you want to track each player and how long or as long as any player is in the trigger?

Posted: Mon Dec 11, 2006 2:30 am
by SniperWolf
If possible 2 at a time. We usually have 2 players run it side by side.

But if we can only do one at a time then i guess thats how we have to do it.

I'll settle for getting it to work for 1 player right now.

It would be max 2 players in the trigger at anyone time. We are trying to get how long it takes each player to run our Obstacle Course. So I guess it would work if it started when the player enters the trigger, keeps track of him while he is in the trigger & stops when he exits the trigger.

Any ideas Viper?

Posted: Mon Dec 11, 2006 6:17 am
by ViPER
I would suggest a use trigger

maybe a use to start and a use to stop would be doable.

A trigger all would be much more complicated i think.

Posted: Mon Dec 11, 2006 8:16 am
by ViPER
**UPDATED CODE to COUNT IN TENTHS**

try this and see if you like it. It's not tested but should track an individual time for each of multiple players.

Will tell each player under compass that the clock is started and each 10th of a second and when the clock is stopped.

Will broadcast to all the finish time for each.

execute from map after prespawn like this

Code: Select all

exec global/timer.scr ( your start coords) ( your finish coords )
Use one or more

name this timer.scr and put it in global

Code: Select all

//timer
//<TWL>Viper

main local.start level.stop:
 local.trigger = spawn trigger
 local.trigger model "static/corona_reg.tik" 
 local.trigger.origin = ( local.start )
 local.trigger setsize ( -50 -50 -50 ) ( 50 50 50 )
 local.trigger.angles = ( 0 0 0 )
 local.trigger.scale = 2.0
 local.trigger light 0 1 0 150
 local.trigger setthread do_start
 local.trigger show
end

do_start:
 self nottriggerable
 local.player = parm.other
 if(local.player.inuse)
  {
  self triggerable
  end
  }
 else
  {
  local.player.inuse = 1
  local.player thread doit
  }
 self triggerable
end

doit:
 local.number = randomint 999999999
 thread trigger_end local.number
   local.result = self waitthread scan_player local.number
   if(local.result != left)
    {
    self.inuse = 0
    self iprint ( "Clock Stopped" ) 1
    $("end_" + local.number) remove
    }
end

trigger_end local.number:
 local.trigger = spawn trigger targetname ("end_" + local.number)
 local.trigger model "static/corona_reg.tik" 
 local.trigger.origin = ( level.stop )
 local.trigger setsize ( -50 -50 -50 ) ( 50 50 50 )
 local.trigger.angles = ( 0 0 0 )
 local.trigger.scale = 2.0
 local.trigger light 1 0 0 150
 local.trigger show
 local.trigger waittill trigger
end

scan_player local.number:
 local.result = ok
 local.team = self.dmteam
 local.count = 0.0
    self iprint ( "Clock Started" ) 1
 while(1)
  {
  if(self == NULL)
   {
   local.result = left
   end local.result
   }
  else
   {
   if(self.dmteam != local.team || !isalive self)
    {
    end local.result
    }
   else
    {
    local.count += 0.1
    self iprint ( local.count  )
    if( ("end_" + local.number) istouching self )
     {
     self stufftext ("say I FINISHED AND MY TIME IS " + local.count )
     end local.result
     }
    }
   }
  wait 0.1
  }
end

Posted: Mon Dec 11, 2006 11:22 pm
by SniperWolf
Thanks for the quick reply Viper.

Just 1 question though, Is the code above for me to spawn a trigger or me mapping it in???

I have a trigger_multiple already mapped into the map. Can I use your code with that trigger??

Posted: Tue Dec 12, 2006 1:30 am
by ViPER
you dont need it in your map just this -
execute from map after prespawn like this

Code: Select all

exec global/timer.scr ( your start coords) ( your finish coords ) 

Posted: Tue Dec 12, 2006 12:54 pm
by SniperWolf
Viper,

I took a couple of screen shots of the Staring Line & Finishing Line of the Obstacle Course. So I'll have to go into the game, use"coord" in console to get the start & stop coords. But I want it to activate anywhere in between the 2 brick posts(see screenies). Will I have to use 1 script or multiple scripts?

Starting Line:
Image

Finishing Line:
Image

Posted: Tue Dec 12, 2006 6:31 pm
by ViPER
Your map looks nice. Is it done?

You only need to execute the timer script once. Get the coords betwen the posts and its good to go. Do you have a map script yet?

the script spawns an orb and a green light at the start and an orb and green red light at the finish. you may want to remove those.

Also when the triggers are placed you may want to resize them.

Posted: Tue Dec 12, 2006 8:04 pm
by SniperWolf
No its not done yet :(

Yes I have a map script, would you like to see it???

I'll get some coords & try it out.

I'll keep you posted

Posted: Tue Dec 12, 2006 10:41 pm
by ViPER
I look forward to seeing your map when it's done. :D

I will look at your map script if you have any problems getting it or the timer working.

Posted: Wed Dec 13, 2006 1:52 pm
by SniperWolf
THANKS ALOT Viper!!! :D

It works great!! Here are some screenies for you.

Starting Line:
Image

Clock Itself:
Image

Finish Line:
Image

Finishing Text:
Image


One other question for you. I made a grenade range in my Boot Camp map as well. I already have it so when the grenade goes into a opening it prints the point value on the left side under the compass. What I want to know is:

Can I make it print like the text for the Obstacle Course??

Again thanks Viper...Its Greatly Appreciated :D

Posted: Wed Dec 13, 2006 2:12 pm
by Green Beret
Not sure i get the question, But you can add a message/text to any trigger.

Posted: Wed Dec 13, 2006 2:58 pm
by SniperWolf
I thought I could, but right now the text for my grenade range prints on the left side under the compass, I want it to print like it does in the Finishing Text screenshot above. Was wondering how to do that.

Posted: Wed Dec 13, 2006 6:30 pm
by ViPER
Your map looks like alot of fun - Almost done?

SniperWolf wrote: Can I make it print like the text for the Obstacle Course??
local.player iprint ("this prints to local player under compass in yellow")

local.player iprint ("this prints to local player under compass in white with click") 1

iprintln "this broadcasts to all players under the compass in yellow"

iprintlnbold "this broadcasts to all players under the compass in white with click"

local.player stufftext ("say " + "this broadcasts to all players right of compass")

the last one is what you want. post your script if its not working for you.