Newbie Posted March 22, 2015 Share Posted March 22, 2015 addEvent("1s",true) addEventHandler("1s",getRootElement(), function () local sound = playSound("data/files/better.ogg") setSoundVolume(sound, 1) end) is it possible to mute other sounds while playing this ? Link to comment
Mr.unpredictable. Posted March 22, 2015 Share Posted March 22, 2015 https://wiki.multitheftauto.com/wiki/StopSound or you change the volume of other sounds https://wiki.multitheftauto.com/wiki/setSoundVolume Link to comment
Newbie Posted March 22, 2015 Author Share Posted March 22, 2015 The thing is that i have to mute map songs or custom radio. Somehow.. StopSound Wouldn't do this i think Link to comment
dewu Posted March 22, 2015 Share Posted March 22, 2015 To mute radio: function makeRadioStayOff() setRadioChannel(0) cancelEvent() end addEventHandler("onClientPlayerVehicleEnter", getRootElement(), makeRadioStayOff) addEventHandler("onClientPlayerRadioSwitch", getRootElement(), makeRadioStayOff) Link to comment
Newbie Posted March 22, 2015 Author Share Posted March 22, 2015 To mute radio: function makeRadioStayOff() setRadioChannel(0) cancelEvent() end addEventHandler("onClientPlayerVehicleEnter", getRootElement(), makeRadioStayOff) addEventHandler("onClientPlayerRadioSwitch", getRootElement(), makeRadioStayOff) Thanks for your help, but that's a radio made by .pls streams So, okay. Here's my sound (this should hear loudest) addEvent("15s",true) addEventHandler("15s",getRootElement(), function () local sound1 = playSound("data/files/wreckingball.ogg") setSoundVolume(sound1, 1) end) And theres way to make him loudest, set all other sounds volume to 0.5 and keep my sounds as 1. function muteSounds () for i, sound in ipairs(getElementsByType("sound")) do setSoundVolume(sound, 0.5) if sound == sound1 then setSoundVolume(sound1, 1) end end end addEventHandler("onClientResourceStart", root, function () setTimer(muteSounds, 50, 0) --To make sure that the sound is already playing end) It seems to be playing my sound at 0.5 Link to comment
Newbie Posted March 22, 2015 Author Share Posted March 22, 2015 For those who don't understand what im trying to do: i need to play this: local sound1 = playSound("data/files/wreckingball.ogg") louder than any other server sounds. Link to comment
Addlibs Posted March 22, 2015 Share Posted March 22, 2015 local previousVolumes = {} function muteSounds(except, eVol, oVol) --sound except — Which sound should stay un-muted --float eVol — Volume of the 'except,' how loud the un-muted sound should be --float oVol — How loud should all other sounds be (this should be lower than eVol, in your case) for k, v in ipairs(getElementsByType("sound")) do previousVolumes[v] = getSoundVolume(v) --Remember the previous volume so that you can return it when done if v == except then setSoundVolume(v, eVol) else setSoundVolume(v, oVol) end end end function unmuteSounds() for k, v in pairs(previousVolumes) do if isElement(k) then --Check if the sound element still exists setSoundVolume(k, v) --Reset the sound back to normal end end previousVolumes = {} --Reset the table end Link to comment
Newbie Posted March 22, 2015 Author Share Posted March 22, 2015 Thanks Tasty! I've did it in my way, tested,working fine: addEvent("15s",true) addEventHandler("15s",getRootElement(), function () for i, sound in ipairs(getElementsByType("sound")) do setSoundVolume(sound, 0.1) local sound1 = playSound("data/files/wreckingball.ogg") setSoundVolume(sound1, 1) local soundLength = getSoundLength(sound1) setTimer(unmuteSounds, soundLength*1000, 1) end end) ----- function unmuteSounds () for i, sound in ipairs(getElementsByType("sound")) do setSoundVolume(sound, 1) end end Link to comment
xeon17 Posted March 22, 2015 Share Posted March 22, 2015 No need for this hukus-pukus,simply use this: addEventHandler("onClientResourceStart",resourceRoot, function () setWorldSoundEnabled ( root,false ) setAmbientSoundEnabled( "general", false ) end) Link to comment
Addlibs Posted March 22, 2015 Share Posted March 22, 2015 He wanted to mute MTA sound elements (custom radio through .pls) whilst something else plays. Link to comment
xeon17 Posted March 22, 2015 Share Posted March 22, 2015 He wanted to mute MTA sound elements (custom radio through .pls) whilst something else plays. The thing is that i have to mute map songs or custom radio. Somehow.. StopSound Wouldn't do this i think Well , if i understood good he want to mute MTA/GTA map/background sounds Link to comment
Addlibs Posted March 22, 2015 Share Posted March 22, 2015 The thing is that i have to mute map songs [map songs as in songs played by race map files or similar] or custom radio. Somehow.. StopSound Wouldn't do this i think Thanks for your help, but that's a radio made by .pls streams louder than any other server sounds. Link to comment
xeon17 Posted March 22, 2015 Share Posted March 22, 2015 Ahh , sorry I haven't saw that. 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