Trigger a Sound Help
Moderator: Moderators
Trigger a Sound Help
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.
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.

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.
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.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.
Do you mean...
thread alarm
end
alarm:
$trigger playsound alarm
end
Please write it out for I am stupid sometimes with scripting.

No
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!
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!
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
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
searching for sounds
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.
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.
Re: searching for sounds
Does that mean if a sound works in ubersound for multiplayer I don't nead to modify it? Just script the sound like above?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.

Yes
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.
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
}

Re: No
Don't I needtltrude 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
Code: Select all
thread alarm_on

