Jump to content

Switching Radio stations.


Karuzo

Recommended Posts

Hey Guys,

i have a radio panel with a few radio stations , ok , so what's the problem ?

If i click on one radio station and than to another it plays the sound of the firt radio station too.

So how can i handle this ?

Code :

addEventHandler("onClientGUIClick", root, 
        function () 
            if ( source == Radyobutton1 ) then 
                sound1 = playSound( "****", false ) 
            elseif ( source == Radyobutton2 ) then 
                sound2 = playSound( "**", false ) 
            elseif ( source == Radyobutton3 ) then 
                sound3 = playSound( "***", false ) 
            elseif ( source == Radyobutton4 ) then 
                sound4 = playSound( "****", false ) 
            elseif ( source == radkapat ) then 
                if isElement(sound1) then destroyElement(sound1) end 
                if isElement(sound2) then destroyElement(sound2) end 
                if isElement(sound3) then destroyElement(sound3) end 
                if isElement(sound4) then destroyElement(sound4) end 
            end 
        end 
    ) 

-KRZO.

Edited by Guest
Link to comment
Hey Guys,

i have a radio panel with a few radio stations , ok , so what's the problem ?

If i click on one radio station and than to another it plays the sound of the firt radio station too.

So how can i handle this ?

Code :

addEventHandler("onClientGUIClick", root,

function ()

if ( source == Radyobutton1 ) then

sound1 = playSound( "****", false )

elseif ( source == Radyobutton2 ) then

sound2 = playSound( "**", false )

elseif ( source == Radyobutton3 ) then

sound3 = playSound( "***", false )

elseif ( source == Radyobutton4 ) then

sound4 = playSound( "****", false )

elseif ( source == radkapat ) then

if isElement(sound1) then destroyElement(sound1) end

if isElement(sound2) then destroyElement(sound2) end

if isElement(sound3) then destroyElement(sound3) end

if isElement(sound4) then destroyElement(sound4) end

end

end

)

-KRZO.

I'm not sure how to stop sounds. If its done by destroyElement, then you just have to add something like this:

  
elseif ( source == Radyobutton3 ) then 
   sound3 = playSound( "***", false ) 
   if isElement(sound1) then destroyElement(sound1) end 
   if isElement(sound2) then destroyElement(sound2) end 
   if isElement(sound4) then destroyElement(sound4) end 
  
  
  

Link to comment
addEventHandler("onClientGUIClick", root, function () 
  
     
  
    if ( source == Radyobutton1 ) then 
        if isElement(sound) then stopSound(sound) end 
        sound = playSound( "****", false ) 
    elseif ( source == Radyobutton2 ) then 
        if isElement(sound) then stopSound(sound) end 
        sound = playSound( "**", false ) 
    elseif ( source == Radyobutton3 ) then 
        if isElement(sound) then stopSound(sound) end 
        sound = playSound( "***", false ) 
    elseif ( source == Radyobutton4 ) then 
        if isElement(sound) then stopSound(sound) end 
        sound = playSound( "****", false ) 
    elseif ( source == radkapat ) then 
        if isElement(sound) then  
            stopSound(sound)  
        end 
    end 
  
end) 

Edited by Guest
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...