Mimimiguel Posted July 23, 2011 Share Posted July 23, 2011 Hello, today I was trying to make a radio gui using gui buttons and streams for the sound, I tested the streams before putting them here and it worked perfectly. I think that the problem resides on the event because the first text warning isnt shown... Here it is the code, I cant find the error: GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Window[1] = guiCreateWindow(249,100,315,390,"Radio",false) guiSetVisible( GUIEditor_Window[1], false ) GUIEditor_Button[1] = guiCreateButton(23,65,116,51,"Escuchar/parar Salvaje FM",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(182,65,116,51,"Escuchar/parar Los40 Principales",false,GUIEditor_Window[1]) GUIEditor_Button[3] = guiCreateButton(24,140,116,51,"Escuchar/parar Cadena Dial",false,GUIEditor_Window[1]) GUIEditor_Button[4] = guiCreateButton(183,253,116,50,"Escuchar/parar Cadena Ser",false,GUIEditor_Window[1]) GUIEditor_Label[1] = guiCreateLabel(116,23,157,31,"Música:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],0,200,50) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) guiSetFont(GUIEditor_Label[1],"sa-header") GUIEditor_Label[2] = guiCreateLabel(115,207,157,31,"Noticias:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[2],0, 50, 200) guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false) guiSetFont(GUIEditor_Label[2],"sa-header") GUIEditor_Button[5] = guiCreateButton(24,253,116,50,"Escuchar/parar RNE",false,GUIEditor_Window[1]) GUIEditor_Button[6] = guiCreateButton(94,358,128,23,"Guardar radio",false,GUIEditor_Window[1]) GUIEditor_Button[7] = guiCreateButton(183,139,116,51,"Escuchar/parar Hit FM",false,GUIEditor_Window[1]) function toggleRadioGui( player ) if guiGetVisible( GUIEditor_Window[1] ) == false then showCursor( true, true ) guiSetVisible( GUIEditor_Window[1], true ) else showCursor( false, false ) guiSetVisible( GUIEditor_Window[1], false ) end end addCommandHandler("radio", toggleRadioGui) addEventHandler( "OnClientGuiClick", getLocalPlayer(), function( radio, state, x, y ) outputChatBox( "Aqui hemos llegado" ) -- first text message if source == GUIEditor_Button[1] then if getElementData( getLocalPlayer(), "radio" ) == false then -- si no esta con una radio encendida, ponemos la radio / if it isnt turned on, it is suposed to turn it on, else turn it off sound = playSound( "http://salvajefm.com/modules/mod_ngs_shoutcast/singleplaylist.php?ip=94.75.209.28&port=8188&format=ASX", false ) setElementData( getLocalPlayer(), "radio", true ) outputChatBox( "Estas escuchando salvaje fm" ) else stopSound( sound ) setElementData( getLocalPlayer(), "radio", false ) end elseif source == GUIEditor_Button[2] then if getElementData( getLocalPlayer(), "radio") == false then sound = playSound( "http://194.169.201.177:8085/live3.mp3", false ) setElementData( getLocalPlayer(), "radio", true ) else stopSound( sound ) setElementData( getLocalPlayer(), "radio", false ) end elseif source == GUIEditor_Button[3] then if getElementData( getLocalPlayer(), "radio") == false then sound = playSound("http://194.169.201.177:8085/liveDial.mp3", false ) setElementData( getLocalPlayer(), "radio", true ) else stopSound( sound ) setElementData( getLocalPlayer(), "radio", false ) end elseif source == GUIEditor_Button[4] then if getElementData( getLocalPlayer(), "radio") == false then sound = playSound("http://194.169.201.177:8085/liveser.mp3", false ) setElementData( getLocalPlayer(), "radio", true ) else stopSound( sound ) setElementData( getLocalPlayer(), "radio", false ) end elseif source == GUIEditor_Button[5] then if getElementData( getLocalPlayer(), "radio") == false then sound = playSound("http://rtve.stream.flumotion.com/rtve/radio1.mp3.m3u", false ) setElementData( getLocalPlayer(), "radio", true ) else stopSound( sound ) setElementData( getLocalPlayer(), "radio", false ) end elseif source == GUIEditor_Button[6] then toggleRadioGui() elseif source == GUIEditor_Button[7] then if getElementData( getLocalPlayer(), "radio") == false then sound = playSound("http://streaming.tst.es/stcasx/va90winlive2001/play.asx", false ) setElementData( getLocalPlayer(), "radio", true ) else stopSound( sound ) setElementData( getLocalPlayer(), "radio", false ) end end end ) Thanks in advice! Link to comment
#Paper Posted July 23, 2011 Share Posted July 23, 2011 GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Window[1] = guiCreateWindow(249,100,315,390,"Radio",false) guiSetVisible( GUIEditor_Window[1], false ) GUIEditor_Button[1] = guiCreateButton(23,65,116,51,"Escuchar/parar Salvaje FM",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(182,65,116,51,"Escuchar/parar Los40 Principales",false,GUIEditor_Window[1]) GUIEditor_Button[3] = guiCreateButton(24,140,116,51,"Escuchar/parar Cadena Dial",false,GUIEditor_Window[1]) GUIEditor_Button[4] = guiCreateButton(183,253,116,50,"Escuchar/parar Cadena Ser",false,GUIEditor_Window[1]) GUIEditor_Label[1] = guiCreateLabel(116,23,157,31,"Música:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],0,200,50) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) guiSetFont(GUIEditor_Label[1],"sa-header") GUIEditor_Label[2] = guiCreateLabel(115,207,157,31,"Noticias:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[2],0, 50, 200) guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false) guiSetFont(GUIEditor_Label[2],"sa-header") GUIEditor_Button[5] = guiCreateButton(24,253,116,50,"Escuchar/parar RNE",false,GUIEditor_Window[1]) GUIEditor_Button[6] = guiCreateButton(94,358,128,23,"Guardar radio",false,GUIEditor_Window[1]) GUIEditor_Button[7] = guiCreateButton(183,139,116,51,"Escuchar/parar Hit FM",false,GUIEditor_Window[1]) function toggleRadioGui( player ) if guiGetVisible( GUIEditor_Window[1] ) == false then showCursor( true, true ) guiSetVisible( GUIEditor_Window[1], true ) else showCursor( false, false ) guiSetVisible( GUIEditor_Window[1], false ) end end addCommandHandler("radio", toggleRadioGui) function onClick ( radio, state, x, y ) outputChatBox( "Aqui hemos llegado" ) -- first text message if source == GUIEditor_Button[1] then if getElementData( getLocalPlayer(), "radio" ) == false then -- si no esta con una radio encendida, ponemos la radio / if it isnt turned on, it is suposed to turn it on, else turn it off sound = playSound( "http://salvajefm.com/modules/mod_ngs_shoutcast/singleplaylist.php?ip=94.75.209.28&port=8188&format=ASX", false ) setElementData( getLocalPlayer(), "radio", true ) outputChatBox( "Estas escuchando salvaje fm" ) else stopSound( sound ) setElementData( getLocalPlayer(), "radio", false ) end elseif source == GUIEditor_Button[2] then if getElementData( getLocalPlayer(), "radio") == false then sound = playSound( "http://194.169.201.177:8085/live3.mp3", false ) setElementData( getLocalPlayer(), "radio", true ) else stopSound( sound ) setElementData( getLocalPlayer(), "radio", false ) end elseif source == GUIEditor_Button[3] then if getElementData( getLocalPlayer(), "radio") == false then sound = playSound("http://194.169.201.177:8085/liveDial.mp3", false ) setElementData( getLocalPlayer(), "radio", true ) else stopSound( sound ) setElementData( getLocalPlayer(), "radio", false ) end elseif source == GUIEditor_Button[4] then if getElementData( getLocalPlayer(), "radio") == false then sound = playSound("http://194.169.201.177:8085/liveser.mp3", false ) setElementData( getLocalPlayer(), "radio", true ) else stopSound( sound ) setElementData( getLocalPlayer(), "radio", false ) end elseif source == GUIEditor_Button[5] then if getElementData( getLocalPlayer(), "radio") == false then sound = playSound("http://rtve.stream.flumotion.com/rtve/radio1.mp3.m3u", false ) setElementData( getLocalPlayer(), "radio", true ) else stopSound( sound ) setElementData( getLocalPlayer(), "radio", false ) end elseif source == GUIEditor_Button[6] then toggleRadioGui() elseif source == GUIEditor_Button[7] then if getElementData( getLocalPlayer(), "radio") == false then sound = playSound("http://streaming.tst.es/stcasx/va90winlive2001/play.asx", false ) setElementData( getLocalPlayer(), "radio", true ) else stopSound( sound ) setElementData( getLocalPlayer(), "radio", false ) end end end addEventHandler( "onClientGUIClick", GUIEditor_Button[1], onClick) addEventHandler( "onClientGUIClick", GUIEditor_Button[2], onClick) addEventHandler( "onClientGUIClick", GUIEditor_Button[3], onClick) addEventHandler( "onClientGUIClick", GUIEditor_Button[4], onClick) addEventHandler( "onClientGUIClick", GUIEditor_Button[5], onClick) addEventHandler( "onClientGUIClick", GUIEditor_Button[6], onClick) addEventHandler( "onClientGUIClick", GUIEditor_Button[7], onClick) try this Link to comment
Mimimiguel Posted July 23, 2011 Author Share Posted July 23, 2011 it works perfectly, thanks! gaved you credits you can close this topic Link to comment
Castillo Posted July 23, 2011 Share Posted July 23, 2011 addEventHandler( "onClientGUIClick", GUIEditor_Button[1], onClick) addEventHandler( "onClientGUIClick", GUIEditor_Button[2], onClick) addEventHandler( "onClientGUIClick", GUIEditor_Button[3], onClick) addEventHandler( "onClientGUIClick", GUIEditor_Button[4], onClick) addEventHandler( "onClientGUIClick", GUIEditor_Button[5], onClick) addEventHandler( "onClientGUIClick", GUIEditor_Button[6], onClick) addEventHandler( "onClientGUIClick", GUIEditor_Button[7], onClick) Why you used all these...? with just one it would work as you are using 'elseif'. Link to comment
#Paper Posted July 23, 2011 Share Posted July 23, 2011 so i can use addEventHandler( "onClientGUIClick", getResourceRootElement(getThisResource()), onClick) ??? Link to comment
Castillo Posted July 23, 2011 Share Posted July 23, 2011 Yes, not sure about: getResourceRootElement(getThisResource()) but well, I use just root element. 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