.:HyPeX:. Posted December 23, 2013 Share Posted December 23, 2013 Hello, if i'm making server radio, where maps play their own song, how can i search it and kill it when the radio is on? Thanks HyPeX Link to comment
AndyAndreiH Posted December 23, 2013 Share Posted December 23, 2013 I'm not sure what you mean by "killing" it. Do you mean killing the sound itself? Link to comment
Dealman Posted December 23, 2013 Share Posted December 23, 2013 Assign your playSound with a specific variable. Then get all sound elements when a map is started, and destroy all sound elements that is not yours. Example taken from my Radio; function muteOtherStreams(success, length, streamName) if(guiCheckBoxGetSelected(radioMuteOtherStreams) == true) then if(source ~= nil) and (source ~= radioStream) then stopSound(source) if(guiCheckBoxGetSelected(radioOutputMessage) == true) then outputChatBox("#696969[FAG-Radio]: #841FFFAnother Stream was stopped!", 255, 255, 255, true) end end else if(source ~= nil) and (source ~= radioStream) then if(guiCheckBoxGetSelected(radioSetVolume) == true) then setSoundVolume(source, radioVolume) end end end end addEventHandler("onClientSoundStream", getRootElement(), muteOtherStreams) Link to comment
Driggero Posted December 23, 2013 Share Posted December 23, 2013 addEvent("onClientMapStarting", true) addEventHandler("onClientMapStarting", root, function() for i, v in ipairs(getElementsByType("sound")) do destroyElement(v) end end ) not tested, you may need to wait a few seconds after the map has started. EDIT: Looks like Dealman beat me to it, that should work perfectly Link to comment
.:HyPeX:. Posted December 23, 2013 Author Share Posted December 23, 2013 Not sure if got it right, but nothing happens function muteOtherStreams(success, length, streamName) if source == radio then return end if(guiCheckBoxGetSelected(RadioMuteCheckBox) == true) then if CurrentRadio then if(source ~= nil) and (source ~= CurrentRadio) then stopSound(source) if(guiCheckBoxGetSelected(RadioOutputMuteCheckBox) == true) then outputChatBox("#00aaff[Radio]: #841FFFAnother Stream was stopped!", 255, 255, 255, true) end end end else if not CurrentRadio then if(source ~= nil) and (source ~= CurrentRadio) then if(guiCheckBoxGetSelected(RadioCustomVolume) == true) then RadioVolumeGet = guiGetText( RadioVolumeEditBox ) RadioVolume = string.gsub(RadioVolumeGet, "[^123456789]", "") setSoundVolume(source, RadioVolume) end end else if (source ~= nil) and (source == CurrentRadio) then if(guiCheckBoxGetSelected(RadioCustomVolume) == true) then RadioVolumeGet = guiGetText( RadioVolumeEditBox ) RadioVolume = string.gsub(RadioVolumeGet, "[^123456789]", "") setSoundVolume(source, RadioVolume) end end end end end addEventHandler("onClientSoundStream", getRootElement(), muteOtherStreams) 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