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
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.
TuRisMo Posted December 13, 2012 Author Posted December 13, 2012 myonlake solution worked, thanks for your help both
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
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
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 )
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 = ...
Anderl Posted December 15, 2012 Posted December 15, 2012 Are you sure the gridlist text is the file path?
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