Page 1 of 2

Another timer question

Posted: Tue Feb 27, 2007 11:35 am
by SniperWolf
Looking to make a timer that counts down from 2 minutes to 0. I'm looking to see how many targets a player can shoot in a certain time.

Can it be done??

Posted: Tue Feb 27, 2007 12:40 pm
by ViPER
We could do a thing with the stop watch - and I recomend 1 min. thats what the stop watch will start at max.

The tracking of hits for individual players is tricky. need to make an array - the hard thing is tracking the players if they leave the server, etc. if not done properly players end up with other players scores or worse the server crash. I could start it but I would need a seasoned scripter to help finish it. lol

Posted: Tue Feb 27, 2007 1:47 pm
by SniperWolf
Well tracking the targets we don't have to worry about really. The Instructors of the Boot Camp can count them physically.

Is it possible to use the timer for round based or obj maps? From the top right corner of the hud?

Or can we run a 1 minute stop watch back to back(to make 2 minute)then have it sound an alarm?

Posted: Tue Feb 27, 2007 11:06 pm
by ViPER
Well here is my stab at what you want. All this does is watches the player who uses the trigger. It gives the player a stop watch on the left middle screen. It messages the player and the server that the clock started. after one minute the watch starts counting down. then at the end of minute two it says times up.

The timer is deactivated if the player dies, drops to spec or leaves the server.

Code: Select all

main local.origin:



 local.trigger = spawn trigger_use
 local.trigger model "static/corona_orange.tik" 
 local.trigger.origin = local.origin
 local.trigger.scale = .8
 local.trigger light 1 0 0 50
 local.trigger setthread do_random
 local.trigger show
 level.target_time = 120
end


do_random:
 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:

   iprintln "Clock Started"
   self iprint ("Start Shooting!") 1
   
   local.result = self waitthread scan_player level.target_time
   if(local.result != left)
    {
    self.inuse = 0
    }


end



scan_player local.time:
 local.result = ok
 local.team = self.dmteam
 self stopwatch local.time
 local.count = 0
 while(1)
  {
  if(self == NULL)
   {
   local.result = left
   end local.result
   }
  else
   {
   if(self.dmteam != local.team || !isalive self)
    {
    self stopwatch 0
    end local.result
    }
   else
    {
    local.count++
    if((local.count / 10) >= local.time)
     {
     self stopwatch 0

   self iprint ("Time is up!") 1
   
   iprintln "Clock Stopped"

     end local.result
     }
    }
   }
  wait 0.1
  }
end

Posted: Wed Feb 28, 2007 1:01 am
by SniperWolf
Looks like it will work out great. Can't wait to test it out, just need to where this go??

After level prespawn or do I save it as a timer script & put it in global??

Posted: Wed Feb 28, 2007 1:24 am
by ViPER
either.

in map script after prespawn (change it from main to something like stopwatchtimer)

Code: Select all

local.o = (x y z)
thread stopwatchtimer local.o
[code]

or name it and put it in global folder

[code]
exec global/stopwatchtimer.scr (x y z)
[code]



Posted: Wed Feb 28, 2007 11:46 am
by SniperWolf
OK, got a chance to test it. Works Great but i think 2 minutes is way to long, LoL. But I know where to change that :D

Also, can I made a buzzer sound when the time is up??

I have a feeling that the new recruits won't be paying much attention to the stop watch:D

Thanks AGAIN Viper

Posted: Wed Feb 28, 2007 8:34 pm
by ViPER
Here you go...

Code: Select all

main local.origin:

local.master = spawn ScriptMaster
local.master aliascache m6l3c_alarm sound/mechanics/Mec_Alarm_05.wav soundparms 1.0 0.0 1.0 0.0 160 1200 auto loaded maps "m dm moh obj train"



 local.trigger = spawn trigger_use targetname starttimer
 local.trigger model "static/corona_orange.tik" 
 local.trigger.origin = local.origin
 local.trigger.scale = .8
 local.trigger light 1 0 0 50
 local.trigger setthread do_random
 local.trigger show
 level.target_time = 60
end


do_random:
 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:

   iprintln "Clock Started"
   self iprint ("Start Shooting!") 1
   
   local.result = self waitthread scan_player level.target_time
   if(local.result != left)
    {
    self.inuse = 0
    }


end



scan_player local.time:
 local.result = ok
 local.team = self.dmteam
 self stopwatch local.time
 local.count = 0
 while(1)
  {
  if(self == NULL)
   {
   local.result = left
   end local.result
   }
  else
   {
   if(self.dmteam != local.team || !isalive self)
    {
    self stopwatch 0
    end local.result
    }
   else
    {
    local.count++
    if((local.count / 10) >= local.time)
     {
     self stopwatch 0

   self iprint ("Time is up!") 1
   
   iprintln "Clock Stopped"

   $starttimer playsound m6l3c_alarm

     end local.result
     }
    }
   }
  wait 0.1
  }
end

Posted: Thu Mar 01, 2007 4:46 am
by SniperWolf
Buzzer doesn't work :(

BTW, I test it in SH will that make a difference?

OK after testing it in AA the buzzer does work BUT my Clan uses SH.

Any way to get it to work in SH??

Posted: Thu Mar 01, 2007 6:36 am
by ViPER
hmmmm I use SH and it works for me. I also use a modded ubersound.

we need to make an ubersound file for your map and the alias cache master thing should probably be placed at the top of you map script just after main.

ill make you an ubersound file and post it.

Posted: Thu Mar 01, 2007 12:18 pm
by SniperWolf
OK, Thanks. I'll be waiting for it.

Posted: Thu Mar 01, 2007 11:46 pm
by ViPER
name this something like traininguber and put it in a folder named ubersound and pak it with your map.

That's it. I think that should do it.

Code: Select all

//========================================================================================
// UBERSOUND FILE
//========================================================================================
// aliascache(alias) <aliasname> <soundfile> soundparms <basevol> <volmod> <basepitch> <pitchmod> <minDist> <maxDist> <channel> loaded(streamed) maps "<mapstring>"
//========================================================================================
// MIN DIST AND MAX DIST:  Sound has a linear fall-off rate from minDist to maxDist.  If the player is within minDist, sound is at full volume.  16 Units = 1 Foot.
//========================================================================================
// Sound channel priorities:
//0 - auto - This is considered the lowest audio channel priority. It always plays if possible (hardware audio channel available) and they don't override previously played sounds. If no channels are available, the sound will just not play. This is best used for things that do not have a particular entity or character related to them (like bullet hit sounds), or are not overly important sound (like shell casing landing sounds or footsteps).
//1 - body - these are sounds made by a characters body. These include sounds like impact sounds (from falling & landing hard) and equipment movement jingles.
//2 - item - These are sounds made by items on a character, or that represent some sort of item related sound. These would include sounds made by any misc items carried by a character like papers or binorulars, but could also be used as a second weapon sound channel if it is required for a weapon to play two different sounds at the same time. This is also the channel that should be used for weapon reload sound to prevent them from cutting off long firing sounds.
//3 - weaponidle - is for constant sound made by weapons or possibly the character itself. An example from Quake3 would be the rail gun hum, but I can't think of any examples from MoH.
//4 - voice - These are vocal sounds made by a character such as pain, death, and yelling during combat. This is effectively a lower priority dialog channel for general use throughout the majority of the game.
//5 - local - This plays a sound that is considered to be "local" to the player. Meaning, it does not do 3D spatialization on the sound. It does adjust the volume of the sound according to distance though. This is best used for playing sounds that should sound omni-directional like rain or lightning.
//6 - weapon - These are the sound that are made by the characters' weapons. These include the firing sounds, but not reloading sounds.
//7 - dialog_secondary - This is a secondary backup dialog channel. Good for use with lower priority dialog such as idle chatter between characters, as it's considered to be lower priority than regular dialog. This should only include spoken dialog that will have subtitle text.
//8 - dialog - This is the primary sould channel for playing character dialog. This should only include spoken dialog that will have subtitle text.
//9 - menu - This is the sound channel for menu sounds to play on.
//========================================================================================

settiki none

aliascache m6l3c_alarm sound/mechanics/Mec_Alarm_05.wav soundparms 0.9 0.0 1.0 0.0 150 7000 item loaded maps "t2l1 t2l2 "

end

Posted: Sat Mar 03, 2007 3:54 am
by SniperWolf
Save it as .txt file?? Also, I don't have the map in a .pk3 yet. I test it from with in the main folder. So does that mean I should have a ubersound folder in my main folder for it to work??

I saved it as bootcampuber in a ubersound folder in my main folder. Tested & still no buzzer.

Any Ideas?

Posted: Sat Mar 03, 2007 6:29 am
by ViPER
time to make your pk3. lol - but you can still put your bsp in maps folder for testing.

the ubersound is a scr not txt

Posted: Sat Mar 03, 2007 6:43 am
by SniperWolf
ok tested again from a .pk3. Still nothing. I'm lost know.

Here's a couple pics of inside my .pk3.

1st Opening .pk3
Image

Inside Ubersound Folder within .pk3
Image