Dealman Posted April 23, 2013 Share Posted April 23, 2013 Hello, am working on a script which will keep all map-side music muted, instead of having to mute it every single time a new map is started. I don't know if this is possible, but I thought onClientSoundStarted would be the Event to use for something like this. However, I can't seem to get it to work. I've tried to use the code example given in the Wikipedia, but it doesn't work. The only one that seams to work is onClientSoundStream. Does anyone know if I'm doing anything wrong? And even more so, would something like this even be possible at all? onClientSoundStarted is the only event I can think of which could accomplish something like this. I tried to do some research before posting this, but due to ridiculous limitations to the search I couldn't find anything of use... Any help would be greatly appreciated! Link to comment
Castillo Posted April 23, 2013 Share Posted April 23, 2013 This event is available from 1.4 onwards. Wiki quote: FROM VERSION 1.4 ONWARDS Link to comment
Jaysds1 Posted April 23, 2013 Share Posted April 23, 2013 onClientSoundStarted is triggered by the functions: playSound and SetSoundPaused Link to comment
Dealman Posted April 23, 2013 Author Share Posted April 23, 2013 This event is available from 1.4 onwards.Wiki quote: FROM VERSION 1.4 ONWARDS Ah, but why would such a useful event be delayed until the release of 1.4...? Hell, I don't really see the use of posting it on the Wiki this early since it would confuse newbies like me Thanks for the heads-up, any ideas if this might be possible to accomplish in some other way? Link to comment
PaiN^ Posted April 23, 2013 Share Posted April 23, 2013 onClientSoundStarted is triggered by the functions:playSound and SetSoundPaused * Note : It's setSoundPaused ( with a small 's' in the beginning ) .. + addEvent addEventHandler Link to comment
Dealman Posted April 23, 2013 Author Share Posted April 23, 2013 I know how sound works when it's inside the same resource... What leaves me confused is because this music is started by the map itself. And I don't really see any other way to accomplish what I asked here - without the use of onClientSoundStarted which is to be released with 1.4. So I was hoping someone else might have a clever workaround for the time being. Link to comment
xXMADEXx Posted April 23, 2013 Share Posted April 23, 2013 Maybe "onClientSoundStream" ? Link to comment
DNL291 Posted April 23, 2013 Share Posted April 23, 2013 onClientSoundStarted is triggered by the functions:playSound and SetSoundPaused * Note : It's setSoundPaused ( with a small 's' in the beginning ) .. + addEvent addEventHandler That will not work. Use this in the event you want to: for _,theSound in ipairs(getElementsByType("sound")) do stopSound(theSound) end Link to comment
Dealman Posted April 23, 2013 Author Share Posted April 23, 2013 Thank you, DNL291! Thanks to your example, I managed to come up with this code - which does exactly what I want. The song plays for like a split-second every time a map starts, but I'm sure people can live with that. shouldMusicMute = false function onCommandMuteMusic() if(shouldMusicMute == false) then outputChatBox("DDAS-AutoMuter: You've #FFBBFFmuted#FF88FF all Map Music!", 255, 135, 255, true) for _, theSound in ipairs(getElementsByType("sound")) do setSoundVolume(theSound, 0) end shouldMusicMute = true else outputChatBox("DDAS-AutoMuter: You've #FFBBFFunmuted#FF88FF all Map Music!", 255, 135, 255, true) for _, theSound in ipairs(getElementsByType("sound")) do setSoundVolume(theSound, 1) end shouldMusicMute = false end end addCommandHandler("mutemusic", onCommandMuteMusic, false) function onMapChange() if(shouldMusicMute == true) then for _, theSound in ipairs(getElementsByType("sound")) do setSoundVolume(theSound, 0) end end end addEventHandler("onClientScreenFadedIn", getRootElement(), onMapChange) Should anyone feel the need of such code, feel free to use what I provided above and modify it to your liking. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now