Another timer question
Posted: Tue Feb 27, 2007 11:35 am
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??
Can it be done??
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
}
endCode: 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]
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
}
endCode: 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