Stopping ambient_generics for one person?

Bloodroke

L1: Registered
Jul 30, 2013
29
8
I have been making a remake of a popular DJ map for TF2 for quite a while now, and while I was able to make many cool things in the map, and learn almost every aspect of Hammer in my time doing so, one thing has evaded my perception; how would I make a button that stops all music playing ambient_generics for only the activator?

You see, players on the servers I am making the map for constantly complained about the music playing on the old one (it is a club, there is supposed to be music...) And always wished there was a way to stop the music. The music plays throughout the whole map because I prefer it that way.

I thought of using a point_server command to enable cheats for a split second, along with a point_client command to use StopSound, but that method seems sloppy, and if someone had the ability, they could abuse the split second of cheats with noclip, Buddha, or even crash the server by spawning Merasmus.

Is there some easier way to have a music stopper button to stop the music for only the activator?
 

Egan

aa
Feb 14, 2010
1,375
1,721
Using point_servercommand to activate cheats to send client commands to players? EEEek. Yeah dont do that.

You could instead use a trigger that spans across the entire map named something like SoundscapeT1_Aud (track1), set it to start disabled, and also filter it to people not matching the DJ (find out how to do pretty much that here). Then also make another map-wide trigger named something like SoundscapeT1_DJ, starts disabled, that is filtered to only the DJ. Then on both of those add an output like: OnUser1 !self Disable

Then make an env_soundscape named soundscape_track1 and set the Soundscape keyvalue to MapName.Track1

To create that soundscape, copy this and paste it into a text file named soundscapes_mapname.txt (also include version number) and don't forget to pack the txt file into the map as well at the end.
"MapName.Track1"
{
"dsp" "1"

"playlooping"
{
"volume" ".25"
"pitch" "100"
"wave" "music/track1.wav"
}
}

You will then need to activate the soundscape trigger somehow (I assume you are using a DJ panel with a bunch of func_buttons? Hopefully so cause that's what I'm gonna write up about). So make a func_button named DJButton_T1_All

OnPressed SoundscapeT1_* Enable (enable both soundscape triggers)
OnPressed soundscape_track1 Enable (enable the soundscape)
OnPressed SoundscapeT2_* FireUser1 (turn off any other soundscape trigger if you have any)
etc

So far what should happen is both the players and the DJ will be associated with the soundscape and both will hear whatever music/track1.wav is on loop (you can set it to not loop by editing the soundscript, lrnmoreabout that here). Now what you can do is make some other button that stops it playing for just the DJ, func_button named DJButton_T1_AudOnly OnPressed SoundscapeT1_DJ Disable

So it's stopped playing for the DJ, but you might still hear it because the track1 soundscape might still be set as your player's soundscape. So you'll need to make another env_soundscape for just the DJ with a small radius so it just surrounds him named BlankSoundscape, set the soundscape to something like tf2.respawn_room, starts disabled, and make the DJButton_T1_AudOnly also then enable BlankSoundscape. So now the stop playing for DJ button disables the trigger for Track1 for him and enables the trigger for blank soundscape for him. You'll need to disable the blank soundscape before you play any song for everyone again, can just set every DJ-start-for-everyone button to BlankSoundscape Disable.


You can then repeat the process making a new MapName.Track in the soundscape txt file, new buttons for DJButton_T_All and DJButton_T_AudOnly, set to FireUser1 on all other Soundscape_T_*, and enable SoundScape_T(numberhere)_*, also enable the env_soundscape for that specific track.


I haven't tested any of this, but I've played around with soundscapes a bunch so it might. If you need help with the triggerable soundscapes Ravidge made a tutorial (with vmf) that shows how to do them here. If you need help with the soundscape txt file, check the bottom of the soundscripts page on VDC, if you need help with filtered to only the audience/DJ triggers check the posts I made here, if you need help with FireUser1 check this page on the VDC. I'll check back later to see if you need any help or if I'm completely wrong.

Edit: Oh, I think I just figured out what you meant, that you have a "stop playing this song for me button" and it does what it's labelled as? (shoulda been more clear on that if that's the case). But you could, instead of making all this DJ separate entity crap, just have the buttons dictate what soundscape trigger across the map is enabled, along with what soundscape entity is enabled, and disable all other track soundscapes. Now, if my assumptions are correct, when a player's soundscape is set, he will keep the soundscape no matter where he goes until you change his soundscape somehow else. So you could also have the buttons on the DJ panel, after a delay, disable the trigger of the current soundscape that is playing. And then also have a separate button somewhere else as your "stop playing" button, and then just have a tiny radius env_soundscape on top of it, that gets enabled by the button and disabled shortly after. (tf2.respawn_room). So that way, the-player-who-hit-stop's soundscape will be set to tf2.respawn_room while everyone else's soundscape will remain as MapName.Track1.
 
Last edited:

Bloodroke

L1: Registered
Jul 30, 2013
29
8
Ah, thank you. Your edited portion was exactly what I needed!

Sorry if I wasn't clear. :( I did only want a button that disables whatever song is playing for only the person who hit the button, and not everyone on the map. Your edit suggestion is perfect and should work ideally! Although I didn't want to have to use soundscapes, it seems like the best idea.

I feel bad now for making you type all of that first section. :(