Jump to content

PlaySound - Get it


.:HyPeX:.

Recommended Posts

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
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 :P

Link to comment

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...