How to make a DJ room?

Gravidea

L5: Dapper Member
Apr 17, 2017
227
102
So on a previous thread I had created, I mentioned wondering how I would create a DJ room inside my map. Basically by this I mean, making a room with func_buttons in it that would activate a bunch of ambient_generics that would play music around the whole map. I tossed this idea to the side for a while because I didn't deem it necessary to complete the first version of the map.

Now, the question is... How would I go about this? I'd basically have it so that there are buttons with the song labels on them, then when you press that button is plays the corresponding song. Because this would make wherever the DJ room is on the map a popular spot to fight for however, lots of people will want to play different songs. So basically, I need to find a way to make it so there is a cool down on the buttons. Whenever you press one button, it disables the other buttons so they do not play music overlapping.

Is there a way to do this that would be simple? And what are the outputs that I should use to activate the ambient_generic with the func_buttons? Any help would be appreciated!
 

henke37

aa
Sep 23, 2011
2,075
515
The func_button entity class has a delay before reset value. That's your delay. Then there's the OnPressed and OnOut outputs, those let you know when the button does stuff. And finally there is the Lock and Unlock inputs to prevent people using the button. Apply some wildcards and there you go. Oh, and don't forget to set the Use activates flag, some servers let people use buttons without firing any weapon.
 

Gravidea

L5: Dapper Member
Apr 17, 2017
227
102
So, how should this work then? I'll give an example, and you can tell me if it's right...
I make the texture, then press ctrl+t and turn it into a func_button. I understand that part quite well, but I don't know where to go from there... What should the outputs be? For example, let's say that I have the ambient_generic's name be "City Music" or something like that, how should I go about activating that and also making it so that none of the other buttons can be used for as long as that song plays? I appreciate your explanation, but elaborate as if you're talking to a 10 year old or something, because it's a bit tricky for me to understand everything you explained without looking up a bunch of other tutorials because I'm still trying to get the hang of this.
Sorry for the trouble.
 

henke37

aa
Sep 23, 2011
2,075
515
It's all about I/O. Just a "simple" matter of connecting outputs to inputs. You have the when and you have the what.
 

Nixon

L3: Member
Jan 10, 2017
114
75
actually i have a texture... I made it about two years ago.
Its an animated disco floor
 

Attachments

  • put in materials.zip
    23.9 KB · Views: 249

henke37

aa
Sep 23, 2011
2,075
515
One thing at a time partner. They aren't asking about any disco floor.
 

Da Spud Lord

Occasionally I make maps
aa
Mar 23, 2017
1,339
994
I'll write out a more detailed explanation on what to do. Firstly, I hope you already know how to create outputs; just go to the outputs tab on any entity, click add, and edit the info as necessary.

First, make a point entity with the classname ambient_generic. Set up your ambient_generic with the music file, make sure all of the flags are checked, and give the entity a unique targetname. For the purpose of this tutorial, I'll call it music_1. Duplicate the ambient_generic (shift + drag the entity), and in this new entity, change the music file and targetname. I'll call this one music_2. Now, repeatedly duplicate the entity, changing the targetname and music file each time. We have our sounds set up.

Now, create the brush that will represent the button for music_1 and make it a func_button entity. Give it a name that will be shared with all of your other buttons. I'll call them button_music. The rest of the keyvalues can be left to their defaults. Go to the Flags tab and make sure the "Don't move" flag is checked. Also, select which methods by which you want players to press the button (the "_____ activates" flags). I would recommend damage and use (for servers with the +use command enabled). If you want to filter the type of damage that can be used to press the button (ex only from melee weapons, or only allow players from a certain team), just create and set up a filter entity, then put the filter's targetname in the "Damage Filter" keyvalue. (Note: If you wish to filter by player class, such as spy or engineer, use filter_tf_class, not filter_activator_class!)

Time to make your button actually do stuff. Go to the Outputs tab and give it the following outputs:
My Output|Target Entity|Target Input|Parameter|Delay|Only Once
OnPressed|music_1|PlaySound|<none>|0.00|No
OnPressed|button_music|Lock|<none>|0.00|No
OnPressed|button_music|Unlock|<none>|<length of music>|No
Replace <length of music> in the last output with the length of the music track playing in music_1. Here's what this does: The first output plays the sound from music_1, the ambient_generic associated with this button. The second output locks all buttons, preventing them from being used. The final output will unlock all the buttons after the sound has finished playing, allowing the players to select the next song.

Now duplicate your button (shift + drag). In the new button, change the target entity of the first output to the next ambient_generic, and change the delay of the final output to the length of the music track in the target ambient_generic. Do not change any of the button's keyvalues or flags, not even the targetname! It is okay for multiple entities to have the same targetname; that's how we target all of the buttons with just one output. Simply repeat this process of cloning the button and editing the outputs, and viola! When you compile, your music room should work.
 

Gravidea

L5: Dapper Member
Apr 17, 2017
227
102
That's just the explanation I was looking for. Thanks so much Da Spud Lord. Wish I could have understood it before.
 
Last edited: