Another timer question

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:

Another timer question

Post 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??
«{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 »

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

Post 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?
«{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 »

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

Post 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??
«{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 »

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]


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

Post 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
«{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 »

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

Post 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??
«{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 »

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

Post by SniperWolf »

OK, Thanks. I'll be waiting for it.
«{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 »

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

Post 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?
«{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 »

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

Post 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
«{T§F}»Col.§niperWolf
Visit Clan «{T§F}» at:http://www.clantsf.org
Post Reply