drk Posted February 5, 2012 Share Posted February 5, 2012 hey, im creating a random music script. It plays some musics and then stop playing random sounds. Can anyone help ? code: local currentSound = nil local musicURL = { } local musicURL = { [1] = { name='David Guetta - Where Dem Girls At', url='http://199.167.195.178/wdga.mp3' }, [2] = { name='Coldplay - Paradise', url='http://199.167.195.178/pd.mp3' }, [3] = { name='Coldplay - Viva la Vida', url='http://199.167.195.178/vlv.mp3' }, [4] = { name='Ana Malhoa - Danza Kuduro', url='http://199.167.195.178/dk.mp3' }, [5] = { name='Klaas - The Way', url='http://199.167.195.178/tw.mp3' }, [6] = { name='Basshunter - All I ever Wanted', url='http://199.167.195.178/bh-aiew.mp3' }, [7] = { name='Whiz Khalifa - Black and Yellow', url='http://199.167.195.178/wk-bay.mp3' }, [8] = { name='Skrillex - My name is Skrillex', url='http://199.167.195.178/sx-mnis.mp3' }, [9] = { name='Italobrothers - Stamp on the Ground', url='http://199.167.195.178/ib-sotg.mp3' }, [10] = { name='Madcon - Freaky Like Me', url='http://199.167.195.178/mc-flm.mp3' }, [11] = { name='Cut the Music - Greatest Deejay', url='http://199.167.195.178/ctm-gd.mp3' }, --[['http://199.167.195.178/tv.mp3', 'http://199.167.195.178/wttc.mp3', 'http://199.167.195.178/iml.mp3', 'http://199.167.195.178/ctwykm.mp3', 'http://199.167.195.178/e-ksb9rx.mp3', 'http://199.167.195.178/Lights.mp3', 'http://199.167.195.178/nod.mp3', 'http://199.167.195.178/atb-yana.mp3']]-- } addEventHandler('onClientResourceStart',resourceRoot, function() local random = math.random(#musicURL) local name, song = musicURL[random].name, musicURL[random].url currentSound = playSound(song,false); addEventHandler('onClientRender', root, playing) musicName = tostring(name) setTimer( function() removeEventHandler('onClientRender',root,playing) end,10000,1) end) addEventHandler('onClientElementDestroy', root, function() if (isSoundPaused(currentSound) == true) then return end if (source == currentSound) then local random = math.random(#musicURL) local name, song = musicURL[random].name, musicURL[random].url currentSound = playSound(song,false); removeEventHandler('onClientRender',root,playing) addEventHandler('onClientRender', root, playing) musicName = tostring(name) setTimer( function() removeEventHandler('onClientRender',root,playing) end,10000,1) end; end); rand = setTimer( function() if (isSoundPaused(currentSound) == true) then return end if (currentSound == nil) then local random = math.random(#musicURL) local name, song = musicURL[random].name, musicURL[random].url currentSound = playSound(song,false); addEventHandler('onClientRender', root, playing) musicName = tostring(name) setTimer( function() removeEventHandler('onClientRender',root,playing) end,10000,1) end; end,1000,0) Link to comment
Kenix Posted February 5, 2012 Share Posted February 5, 2012 local currentSound = nil local musicURL = { [1] = { name='David Guetta - Where Dem Girls At', url='http://199.167.195.178/wdga.mp3' }, [2] = { name='Coldplay - Paradise', url='http://199.167.195.178/pd.mp3' }, [3] = { name='Coldplay - Viva la Vida', url='http://199.167.195.178/vlv.mp3' }, [4] = { name='Ana Malhoa - Danza Kuduro', url='http://199.167.195.178/dk.mp3' }, [5] = { name='Klaas - The Way', url='http://199.167.195.178/tw.mp3' }, [6] = { name='Basshunter - All I ever Wanted', url='http://199.167.195.178/bh-aiew.mp3' }, [7] = { name='Whiz Khalifa - Black and Yellow', url='http://199.167.195.178/wk-bay.mp3' }, [8] = { name='Skrillex - My name is Skrillex', url='http://199.167.195.178/sx-mnis.mp3' }, [9] = { name='Italobrothers - Stamp on the Ground', url='http://199.167.195.178/ib-sotg.mp3' }, [10] = { name='Madcon - Freaky Like Me', url='http://199.167.195.178/mc-flm.mp3' }, [11] = { name='Cut the Music - Greatest Deejay', url='http://199.167.195.178/ctm-gd.mp3' } --[['http://199.167.195.178/tv.mp3', 'http://199.167.195.178/wttc.mp3', 'http://199.167.195.178/iml.mp3', 'http://199.167.195.178/ctwykm.mp3', 'http://199.167.195.178/e-ksb9rx.mp3', 'http://199.167.195.178/Lights.mp3', 'http://199.167.195.178/nod.mp3', 'http://199.167.195.178/atb-yana.mp3']]-- } addEventHandler('onClientResourceStart',resourceRoot, function( ) local rnd = musicURL[ math.random( #musicURL ) ] local name, song = rnd.name,rnd.url currentSound = playSound( song,false ); addEventHandler( 'onClientRender', root, playing ) musicName = tostring( name ) setTimer( function( ) removeEventHandler( 'onClientRender',root,playing ) end,10000, 1 ) end ) addEventHandler('onClientElementDestroy', root, function( ) if isSoundPaused( currentSound ) then return end if source == currentSound then local rnd = musicURL[ math.random( #musicURL ) ] local name, song = rnd.name,rnd.url currentSound = playSound( song,false ); removeEventHandler( 'onClientRender',root,playing ) addEventHandler( 'onClientRender', root, playing ) musicName = tostring( name ) setTimer( function( ) removeEventHandler( 'onClientRender',root,playing ) end, 10000, 1 ) end; end ); rand = setTimer( function( ) if isSoundPaused( currentSound ) then return end if not currentSound then local rnd = musicURL[ math.random( #musicURL ) ] local name, song = rnd.name,rnd.url currentSound = playSound( song,false ); addEventHandler( 'onClientRender', root, playing ) musicName = tostring( name ) setTimer( function( ) removeEventHandler( 'onClientRender',root,playing ) end, 10000, 1 ) end end, 1000,0 ) Link to comment
drk Posted February 5, 2012 Author Share Posted February 5, 2012 I think it worked D: Edit: I think, but it don't worked 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