Obstacle Course Timer

Post your scripting questions / solutions here

Moderator: Moderators

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

Obstacle Course Timer

Post 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
«{T§F}»Col.§niperWolf
Visit Clan «{T§F}» at:http://www.clantsf.org
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post 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?
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post 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?
«{T§F}»Col.§niperWolf
Visit Clan «{T§F}» at:http://www.clantsf.org
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post 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.
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post 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
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post 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??
«{T§F}»Col.§niperWolf
Visit Clan «{T§F}» at:http://www.clantsf.org
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post 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 ) 
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post 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
«{T§F}»Col.§niperWolf
Visit Clan «{T§F}» at:http://www.clantsf.org
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post 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.
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post 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
«{T§F}»Col.§niperWolf
Visit Clan «{T§F}» at:http://www.clantsf.org
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post 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.
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post 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
«{T§F}»Col.§niperWolf
Visit Clan «{T§F}» at:http://www.clantsf.org
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

Not sure i get the question, But you can add a message/text to any trigger.
Image
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post 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.
«{T§F}»Col.§niperWolf
Visit Clan «{T§F}» at:http://www.clantsf.org
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post 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.
Post Reply