TuRisMo Posted December 13, 2012 Posted December 13, 2012 I want to play the music URL from the gridlist item, but when I click on the button it does not work local music = guiGridListGetItemText ( gridlist1, guiGridListGetSelectedItem ( gridlist1 ), column1 ) function playTheSound ( ) sound = playSound (music) setSoundVolume (sound, 1.0) outputChatBox ( " Started Playing " ..music ) end addEventHandler ( "onClientGUIClick", button2, playTheSound, false ) function stopTheSound ( ) stopSound(sound) outputChatBox ( music.. "Stoped" ) end addEventHandler ( "onClientGUIClick", button3, stopTheSound, false )
Jaysds1 Posted December 13, 2012 Posted December 13, 2012 (edited) try this: local sound = nil --define the var global function playTheSound ( ) local music = guiGridListGetItemText ( gridlist1, guiGridListGetSelectedItem ( gridlist1 ), column1 ) --column1 isn't defined sound = playSound (music) setSoundVolume (sound, 1.0) outputChatBox ( " Started Playing " ..music ) end addEventHandler ( "onClientGUIClick", button2, playTheSound, false ) function stopTheSound ( ) stopSound(sound) outputChatBox ( music.. "Stopped" ) end addEventHandler ( "onClientGUIClick", button3, stopTheSound, false ) and if this doesn't work, then I would need to see the full script Edited December 13, 2012 by Guest My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
myonlake Posted December 13, 2012 Posted December 13, 2012 Ugh... you need to put the guiGridListGetItem function in the "playTheSound" function you have. Otherwise it would load the gridlist select before you have clicked anything and should already show up an error in /debugscript 3. So just put it in there and maybe it should work, as far as I can see. If I helped you, please click the like button on the right Thanks!
TuRisMo Posted December 13, 2012 Author Posted December 13, 2012 myonlake solution worked, thanks for your help both
Jaysds1 Posted December 13, 2012 Posted December 13, 2012 np My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
myonlake Posted December 13, 2012 Posted December 13, 2012 You're welcome. If I helped you, please click the like button on the right Thanks!
TuRisMo Posted December 13, 2012 Author Posted December 13, 2012 (edited) I want help in something else, how to check if the sound is over? I mean, I am going to make a checkbox for "Enabling Replay" when the song is over. so it would be like that function replay() if ( --the song is over) then if ( guiCheckBoxGetSelected(checkbox1) ) then startSound( sound ) end end end Edited December 13, 2012 by Guest
manve1 Posted December 13, 2012 Posted December 13, 2012 this is an example ((not sure if works)) : if ( not sound ) then local sound = playSound(music) end Looking for tutorials or information? check out: www.simpleask.co.uk
myonlake Posted December 14, 2012 Posted December 14, 2012 this is an example ((not sure if works)) : if ( not sound ) then local sound = playSound(music) end Nope. Use isElement function. isElement If I helped you, please click the like button on the right Thanks!
myonlake Posted December 14, 2012 Posted December 14, 2012 You're welcome again. If I helped you, please click the like button on the right Thanks!
TuRisMo Posted December 14, 2012 Author Posted December 14, 2012 I couldn't find out how to use the ifElement correctly with audios
Castillo Posted December 14, 2012 Posted December 14, 2012 You do it like with any other element. isElement ( sound ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
myonlake Posted December 15, 2012 Posted December 15, 2012 Make sure the sound isn't a local variable, it has to be a global. So instead of.. local sound = ... .. do.. sound = ... If I helped you, please click the like button on the right Thanks!
Anderl Posted December 15, 2012 Posted December 15, 2012 Are you sure the gridlist text is the file path? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
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