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:

Post by SniperWolf »

I already mapped in triggers for the grenade range. Not sure if I can use the
local.player stufftext the way I have it mapped. With that said, here is my grenade range script. It just a part of my map script.

Code: Select all

//Grenade Point Text & Lights//

thread grenade_topleft_triggered

grenade_topleft_triggered:
  iprintln "Great Throw!!! You Scored 5 Points."
  $topleft_red hide
  $topleft_green show

wait 10

  $topleft_red show
  $topleft_green hide

end

thread grenade_topcenter_triggered

grenade_topcenter_triggered:
  iprintln "Nice Toss!!! You Scored 3 Points."
  $topmiddle_red hide
  $topmiddle_green show

wait 10

  $topmiddle_red show
  $topmiddle_green hide

end

thread grenade_topright_triggered

grenade_topright_triggered:
  iprintln "Way To Go!!! You Scored 2 Points."
  $topright_red hide
  $topright_green show

wait 10

  $topright_red show
  $topright_green hide

end

thread grenade_bottomleft_triggered

grenade_bottomleft_triggered:
  iprintln "Good Job!!! You Scored 3 Points."
  $bottomleft_red hide
  $bottomleft_green show

wait 10

  $bottomleft_red show
  $bottomleft_green hide

end

thread grenade_bottomcenter_triggered

grenade_bottomcenter_triggered:
  iprintln "Good Toss!!! You Scored 1 Point."
  $bottommiddle_red hide
  $bottommiddle_green show

wait 10

  $bottommiddle_red show
  $bottommiddle_green hide

end

thread grenade_bottomright_triggered

grenade_bottomright_triggered:
  iprintln "Excellent Job!!! You Scored 1 Point."
  $bottomright_red hide
  $bottomright_green show

wait 10

  $bottomright_red show
  $bottomright_green hide

end
Let me know what I would have to do to make it work with local.player stufftext.

Thanks Again!
«{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 »

Post the whole script.
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 »

Haven't really read the whole topic, but I'm guessing you just want to print the message just to one player. If so, you can do the following:

Code: Select all

grenade_bottomright_triggered:
  parm.owner iprint "Excellent Job!!! You Scored 1 Point."
  self nottriggerable
  $bottomright_red hide
  $bottomright_green show

wait 10

  self triggerable
  $bottomright_red show
  $bottomright_green hide

end
for each of the trigger threads. Parm.owner is the owner of the last projectile that fired a trigger (i.e. the player who scored). Iprint is a Player class command to print a message to a specific player only. Also, note the self triggerable and self nottriggerable lines. The first one deactivates the trigger, the other activates it back. This is to prevent the trigger from going off all the time until the grenade explodes.

Hope this helps. ;)
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post by ViPER »

Rookie One.pl wrote:I'm guessing you just want to print the message just to one player.
He wants it broadcast right of compass -

There might be more to do , not sure without seeing the whole picture but try this.

Code: Select all

grenade_topleft_triggered: 

local.player = parm.other
local.player stufftext "say Great Throw!!! I Scored 5 Points."

  $topleft_red hide 
  $topleft_green show 

wait 10 

  $topleft_red show 
  $topleft_green hide 

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

Post by SniperWolf »

Viper's right Rookie. I want to be sure that all players see the text to the right of the compass, especially the Boot Camp Instructor so they can keep score. If you want I can post some screenies of the different stages of the grenade range. The same trigger that activates the text also hides & shows the green & red lights, but I'm sure you can tell by the script :D I'm posting my entire map script so you can look at it Viper. Also you mentioned earlier in the topic something about not using the orbs, How is that done??? My Lead Boot Camp Instructor would like to remove the orbs if possible. Here's my script:

Code: Select all

//TEST
// ARCHITECTURE: ?{T?F}?SniperWolf 
// SCRIPTING: ?{T?F}?SniperWolf  

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "  Ceremony" 
setcvar "g_obj_alliedtext2" "     &   "
setcvar "g_obj_alliedtext3" " Boot Camp"
setcvar "g_obj_axistext1" "      Map"
setcvar "g_obj_axistext2" "       By:"
setcvar "g_obj_axistext3" "?{T?F}??niperWolf"

setcvar "g_scoreboardpic" "none" 

level waitTill prespawn

//*** Precache Dm Stuff
exec global/DMprecache.scr
exec global/timer.scr ( -4566.86 -4268.45 2.13) ( -6282.37 -4652.40 2.12 )
exec global/timer.scr ( -1637.35 -6099.85 2.13 ) ( -834.33 -6169.11 2.13 )

level.script = maps/dm/test.scr 
//minefield script//
exec global/minefield.scr::minefield_setup

level waittill spawn

//GRENADE RANGE///

//Hide Green Lights//

$topleft_green hide
$topmiddle_green hide
$topright_green hide
$bottomleft_green hide
$bottommiddle_green hide
$bottomright_green hide

waitthread smgtargets_setup
waitthread mgtargets_setup
thread smgtargets_run
thread mgtargets_run

level waittill roundstart

//Grenade Range Enter Text//

thread enter_grenade_triggered

enter_grenade_triggered:
   iprintln "Welcome To The Grenade Range Soldier!"

wait 1

   iprintln "Here We Test Your Grenade Throwing Skills."

end

//Grenade Point Text & Lights//

thread grenade_topleft_triggered

grenade_topleft_triggered:
  iprintln "Great Throw!!! You Scored 5 Points."
  $topleft_red hide
  $topleft_green show

wait 10

  $topleft_red show
  $topleft_green hide

end

thread grenade_topcenter_triggered

grenade_topcenter_triggered:
  iprintln "Nice Toss!!! You Scored 3 Points."
  $topmiddle_red hide
  $topmiddle_green show

wait 10

  $topmiddle_red show
  $topmiddle_green hide

end

thread grenade_topright_triggered

grenade_topright_triggered:
  iprintln "Way To Go!!! You Scored 2 Points."
  $topright_red hide
  $topright_green show

wait 10

  $topright_red show
  $topright_green hide

end

thread grenade_bottomleft_triggered

grenade_bottomleft_triggered:
  iprintln "Good Job!!! You Scored 3 Points."
  $bottomleft_red hide
  $bottomleft_green show

wait 10

  $bottomleft_red show
  $bottomleft_green hide

end

thread grenade_bottomcenter_triggered

grenade_bottomcenter_triggered:
  iprintln "Good Toss!!! You Scored 1 Point."
  $bottommiddle_red hide
  $bottommiddle_green show

wait 10

  $bottommiddle_red show
  $bottommiddle_green hide

end

thread grenade_bottomright_triggered

grenade_bottomright_triggered:
  iprintln "Excellent Job!!! You Scored 1 Point."
  $bottomright_red hide
  $bottomright_green show

wait 10

  $bottomright_red show
  $bottomright_green hide

end

// Rifle Range //

//Enter Text//

thread enter_rifle_triggered

enter_rifle_triggered:
  iprintln "Welcome To The Rifle Range Soldier!"

wait 1

   iprintln "Here We Test Your Rifle Skills."

end

// Sniper Range //

//Enter Text//

thread enter_sniper_triggered

enter_sniper_triggered:
  iprintln "Welcome To The Sniper Range Soldier!"

wait 1
  
  iprintln "Here We Test Your Sniper Rifle Skills."

end

// MG42 Range //

//Enter Text//

thread enter_mg42_triggered

enter_mg42_triggered:
  iprintln "Welcome To The MG-42 Range Soldier!"

wait 1

   iprintln "Here We Test Your Skills Under Fire."

end
// SMG Range //

//Enter Text//

thread enter_smg_triggered

enter_smg_triggered:
   iprintln "Welcome To The SMG Range Soldier!"

wait 1

   iprintln "Here We Test Your SMG Skills."

end

//SMG Pop-Up Targets//

smgtargets_setup:
	for( local.i = 1; local.i <= 6; local.i++ )
	{
		$( "smgtarget" + local.i ) notsolid
		$( "smgtarget" + local.i ) hide
	}
end

smgtargets_run:

        local.last = 0 
	while (1)
	{
		//choose what target will appear
		local.smgpopup = ((randomint (6)) + 1)

                if(local.smgpopup == local.last)
                continue

                local.last = local.smgpopup
                
                switch (local.smgpopup)
		{
		case 1:
			level.smgtarget = spawn func_crate model $smgtarget1.brushmodel origin $smgtarget1.origin
			level.smgtarget health 20
			break
		case 2:
			level.smgtarget = spawn func_crate model $smgtarget2.brushmodel origin $smgtarget2.origin
			level.smgtarget health 20
			break
		case 3:
			level.smgtarget = spawn func_crate model $smgtarget3.brushmodel origin $smgtarget3.origin
			level.smgtarget health 20
			break
		case 4:
			level.smgtarget = spawn func_crate model $smgtarget4.brushmodel origin $smgtarget4.origin
			level.smgtarget health 20
			break
		case 5:
			level.smgtarget = spawn func_crate model $smgtarget5.brushmodel origin $smgtarget5.origin
			level.smgtarget health 20
			break
		case 6:
			level.smgtarget = spawn func_crate model $smgtarget6.brushmodel origin $smgtarget6.origin
			level.smgtarget health 20
			break
		
		}
		level.smgtarget waittill death
		wait 1
	}

end

// MG Range //

//Enter & Exit Text//

thread enter_mg_triggered

enter_mg_triggered:
   iprintln "Welcome To The MG Range Soldier!"

wait 1

   iprintln "Here We Test Your MG Skills."

end


//MG Pop-Up Targets//

mgtargets_setup:
	for( local.i = 1; local.i <= 6; local.i++ )
	{
		$( "mgtarget" + local.i ) notsolid
		$( "mgtarget" + local.i ) hide
	}
end

mgtargets_run:
	while (1)
	{
		//choose what target will appear
		local.mgpopup = ((randomint (6)) + 1)
		
		switch (local.mgpopup)
		{
		case 1:
			level.mgtarget = spawn func_crate model $mgtarget1.brushmodel origin $mgtarget1.origin
			level.mgtarget health 20
			break
		case 2:
			level.mgtarget = spawn func_crate model $mgtarget2.brushmodel origin $mgtarget2.origin
			level.mgtarget health 20
			break
		case 3:
			level.mgtarget = spawn func_crate model $mgtarget3.brushmodel origin $mgtarget3.origin
			level.mgtarget health 20
			break
		case 4:
			level.mgtarget = spawn func_crate model $mgtarget4.brushmodel origin $mgtarget4.origin
			level.mgtarget health 20
			break
		case 5:
			level.mgtarget = spawn func_crate model $mgtarget5.brushmodel origin $mgtarget5.origin
			level.mgtarget health 20
			break
		case 6:
			level.mgtarget = spawn func_crate model $mgtarget6.brushmodel origin $mgtarget6.origin
			level.mgtarget health 20
			break
		
		}
		level.mgtarget waittill death
		wait 1
	}

end
Hope that helps. And I'll give the other options a try Guys. Viper, let me know if you want screen shots of the nade range.

TYVM Guys.
«{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 »

OK - try my previous post to broadcast the nade hits, that should would work.

I see you execute the nade range after roundstart.... This means it will work when an objective round is started ?

for the orbs remove or comment out either or both of these lines. Same goes for the light

Code: Select all

 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 
Also, I see you execute the timer script twice. There are two courses? I realized later that i think that script will only work for multiple players one course at a time. That can be fixed by duplicating the script and making unique level.vars. let me know if thats what you need. That way we can make it say " I FINISHED COURSE ONE IN 56.9 SECONDS" or " I FINISHED COURSE TWO IN 82.9 SECONDS"
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post by SniperWolf »

Viper, I tried your code for the nade range, it didn't work.

As for the timer twice, I was playing around to see if I could use it in different parts of the map. We have a range for every weapon except for bazooka & shotgun(our clan doesn't use them). And we time all ranges except for the grenade range. So I spawned another set of start & finish triggers to see if it would work to time the rifle range, it did BTW :) but I guess if I had level.vars. for each range I could make it say something like: "I finished The Rifle Range In 10.0 Seconds"

Back to the drawing board for the nade rank I guess. But if I read your explanation on IprintIn then the way I have the text for the nade range scripted would be seem by all, correct??
«{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 »

List all the obstacle courses.

on the nade range does the iprintln work at all?
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

iprintln will only print to the server's window in multiplayer unless you loop and send it to all clients.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post by ViPER »

Yes, the proper question is - Is the grenade hit thread working at all?
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 »

I explained the method of catching the grenade owner (Elgan helped me once to develop it - if it wasn't for his suggestion to use parm.owner, this method would still be unknown) in my previous post. Parm.other will not work here.

Also, you do want the nottriggerable/triggerable lines, otherwise you'll be spammed by messages.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post by SniperWolf »

Yes the IprintIn works for the grenade range, but i dont know if it is seen by all player because I'm testing it by myself. The way it works is when the nade passes through the trigger , it prints the text. The nade does not have to explode to trigger the trigger.

As for the ranges I have:

A Rifle Range
A Sniper Rifle Range
A SMG Range
A MG Range
A MG-42 Range
A Grenade Range (not timed)
«{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 »

SniperWolf wrote: The nade does not have to explode to trigger the trigger.
Ah. That might be why, im not sure. I do know the parm.other will detect a players damage to a trigger - ive done it. But the trigger will also pickup other damage, not just nades. Which means you would have to take away everything in the area. I don't know about parm.owner - maybe Rookie will help you more on that.

I will look at the mutiple course thing and post something soon.
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post by ViPER »

Some one may have a better way - and its not tested but I think this will work for multiple players running multiple courses.

execute one for each course like this

Code: Select all

exec global/timer.scr (your start coords) (your end coords) "obstacle name" 

Code: Select all

//timer
//<TWL>Viper

main local.start local.stop local.name:
 local.trigger = spawn trigger targetname ("start_" + local.name)
 local.trigger.origin = ( local.start )
 local.trigger setsize ( -50 -50 -50 ) ( 50 50 50 )

 thread setup local.start local.stop local.name

end

setup local.start local.stop local.name:

$("start_" + local.name) waittill trigger 

$("start_" + local.name) remove

thread main local.start local.stop local.name

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

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

trigger_end local.number local.stop:

 local.trigger = spawn trigger targetname ("end_" + local.number)
 local.trigger.origin = ( local.stop )
 local.trigger setsize ( -50 -50 -50 ) ( 50 50 50 )
 local.trigger waittill trigger
end

scan_player local.number local.name:

 local.result = ok
 local.team = self.dmteam
 local.count = 0.0
    self iprint ( "Clock Started" ) 1
    self stufftext ("say STARTING " + local.name )

 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 " + local.name + " IN " + local.count + " SECONDS" )
     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 »

The new script works fine Viper..... Well at least when I tested it myself. I haven't tested it with another person running 1 range while I run another. But the script you posted last puts the text and everything up. THANKS!! I'll try & set-up my router so I can have my son help me test it & see if it keeps track of 2 people on 2 different ranges at the same time.

Will keep you posted.
«{T§F}»Col.§niperWolf
Visit Clan «{T§F}» at:http://www.clantsf.org
Post Reply