Trigger a Sound Help

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Trigger a Sound Help

Post by Gen Cobra »

Alright this must be an easy one although I must say jv the search engine here doesn't work well with me.

How do you trigger a basic .wav file or .mp3 in game?
I'm making an alarm sound triggered by walking through a doorway.
Please help.
Image
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

get the alias of the sound in ubersound.scr first

give the triggger "setthread" "alarm"

in the script, make a thread named alarm.

if the alias of the sound was "alarm" you would type this...

$trigger playsound alarm
-OR-
$trigger loopsound alarm // use stoploopsound to stop...

for mp3's, i dont know if this workz in multiplayer or not...

$player stufftext "tmstop" will stop any previous mp3.
$player stufftext "tmstart sound/music/mymp3.mp3" will play it once
$player stufftext "tmstartloop sound/music/mymp3.mp3" will loop it.
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Post by Gen Cobra »

Alcoholic wrote:get the alias of the sound in ubersound.scr first

give the triggger "setthread" "alarm"

in the script, make a thread named alarm.

if the alias of the sound was "alarm" you would type this...

$trigger playsound alarm
-OR-
$trigger loopsound alarm // use stoploopsound to stop...

for mp3's, i dont know if this workz in multiplayer or not...

$player stufftext "tmstop" will stop any previous mp3.
$player stufftext "tmstart sound/music/mymp3.mp3" will play it once
$player stufftext "tmstartloop sound/music/mymp3.mp3" will loop it.
This must be scripting then not mapping. I wasn't sure. Can you spell it in dumb for me. I have a hard time grasping concepts like that.
Do you mean...

thread alarm
end
alarm:
$trigger playsound alarm
end

Please write it out for I am stupid sometimes with scripting. :shock:
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

No

Post by tltrude »

No, that would make the sound play all the time. The alarm sounds do not normally work in multiplayer. So, you are going to need an ubersound workaround to get it to play.

1. Create a brush with trigger texture in the doorway and turn it into a trigger_multiple (key N, double click on trigger_multiple).

2. Give it the following key/value settings:

Key: setthread
Value: alarm_on

Key: targetname
Value: alarm_trigger

Note: Whenever a player touches the trigger named "alarm_trigger", it will run the thread named "alarm_on" in your script.

3. Add a script_origin to the spot where you want the sound to come from and give it the following key/value.

Key: targetname
Value: alarm_speaker

4. Compile your map.

Now you need to add the thread to your script............

5. Add the following thread to the bottom of your script.

alarm_on:

wait .5
$alarm_speaker loopsound myalarm // loops the sound
$alarm_trigger nottriggerable // turns off the trigger

end

Note: With the above thread there is no way to turn the alarm off. If you only want the sound to play one time (one beep or bell), change it to "playsound". Leave out the line that turns the trigger off, if you want it to play everytime a player trips it. You can also fill the entire room with the trigger, and it will play the sound over and over untill the player leaves the trigger (adjust the wait time).

Of course, none of this will work unless you create a sound alias named "myalarm". Follow the tutorial at .map about making an ubersound workaround.

Good luck!
Tom Trude,

Image
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Post by Gen Cobra »

I was afraid of this. :? Such complication over a simple sound. MP maps are entirely to much fun though to not take the time to do these little things. Thanks for all the help Alcholic and tltrude.
Image
User avatar
mohaa_rox
Field Marshal
Posts: 2760
Joined: Mon Nov 11, 2002 7:05 am
Contact:

Post by mohaa_rox »

u also have to make the alias
Live to map, not map to live.
-mohaa_rox, .map
moderator
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

May I suggest that you make a couple of script_models "model" "static/alarmbell.tik" "targetname" Alarm_bell " and a switch "animate_equipment_alarmswitch" "targetname" "wallalarm"
then you could do

a trigger in the doorway
trigger_multiple Key:setthread Value: alarm_on

alarm_on:
Alarm_bell[1] loopsound alarmbell
$Alarm_bell[2] loopsound alarmbell
$wallalarm anim turnon
end

and a trigger around the wall alarm
trigger_use Key: setthread Value: alarm_off

alarm_off:
$Alarm_bell[1] stoploopsound
$Alarm_bell[2] stoploopsound
$wallalarm anim turnoff
end
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Post by Gen Cobra »

It's a metal detector for an airport so it only needs to just beep momentarily no need for a switch. Im mad that I have to change ubersound for this. All I want to do is use one of the damn sounds that came with the game. :?
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

searching for sounds

Post by tltrude »

Here is how I search for sounds. Most of the sound wav files are located in pak3.pk3 and I have that "unziped" so I can search it. When I find a wav file I like, I right click on it and go to rename. Then I hit Ctrl C to copy the name of it to my Windows clipboard and close everything.

Next, I go to the ubersound script (pak0.pk3), which I already have set up as a text file, and search for the wav file name I have in the clipboard. It may be used in more than one sound alias, so I look for one that works in all multiplayer maps. If I find one that works in mutiplay, I don't need a ubersound work around. And I can always go back to search for another (similar) sound that does.
Tom Trude,

Image
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Re: searching for sounds

Post by Gen Cobra »

tltrude wrote: If I find one that works in mutiplay, I don't need a ubersound work around. And I can always go back to search for another (similar) sound that does.
Does that mean if a sound works in ubersound for multiplayer I don't nead to modify it? Just script the sound like above?
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Yes

Post by tltrude »

Yes, all of the alarm sounds are non-multiplyer, but if all you want is a "beep", you can probably find something that will work.
Tom Trude,

Image
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Post by Gen Cobra »

Can someone please help me figure out this tik. Is this right and does my wav have to be named with the 1 at the end like myalarm1.wav? Plus wtf I thought I didn't have to modify ubersound for this in the tut? Is this all i need put in the correct paths and the addition of the thread in the script?

Code: Select all

TIKI 

setup
{
        path models/fx/dummy
        skelmodel dummy3.skd
}

init
{
        server
        {
                classname ScriptModel
                rendereffects +dontdraw
                notsolid
        }
        client
        {
                settiki none
                aliascache myalarm1 sound/myalarm1.wav 

(...) maps                 "city_nights_airport"
                aliascache myalarm2 sound/myalarm2.wav 

(...) maps                 "city_nights_airport"
        }
}

animations
{
                idle dummy3.skc
}
Image
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Re: No

Post by Gen Cobra »

tltrude wrote: Now you need to add the thread to your script............

5. Add the following thread to the bottom of your script.

alarm_on:

wait .5
$alarm_speaker loopsound myalarm // loops the sound
$alarm_trigger nottriggerable // turns off the trigger

end
Don't I need

Code: Select all

thread alarm_on
first?
Image
Post Reply