drk Posted January 16, 2012 Posted January 16, 2012 Line 107 ( the line of the error ): local random = math.random(1, #musics) #musics is: local musics = { [ 'David Guetta - Where Dem Girls At' ] = 'http://199.167.195.194/wdga.mp3', [ 'Coldplay - Paradise' ] = 'http://199.167.195.194/pd.mp3', [ 'Coldplay - Viva la Vida' ] = 'http://199.167.195.194/vlv.mp3', [ 'Ana Malhoa - Danza Kuduro' ] = 'http://199.167.195.194/dk.mp3', [ 'Klaas - The Way' ] = 'http://199.167.195.194/tw.mp3', [ 'Basshunter - All I ever wanted' ] = 'gfx/music/bh-aiew.mp3', [ 'Whiz Khalifa - Black and Yellow' ] = 'gfx/music/wk-bay.mp3', [ 'Skrillex - My name is Skrillex ( Remix )' ] = 'gfx/music/sx-mnis.mp3', [ 'Italobrothers - Stamp on the Ground' ] = 'gfx/music/ib-sotg.mp3', [ 'Madcon - Freaky like Me' ] = 'gfx/music/mc-flm.mp3', [ 'Cut the Music - Greatest Deejay' ] = 'gfx/music/ctm-gd.mp3', [ 'No Name - Time`s Vortex' ] = 'gfx/music/tv.mp3', [ 'Manian - Welcome to the Club' ] = 'gfx/music/wttc.mp3', [ 'Bon Jovi - It`s my Life' ] = 'gfx/music/iml.mp3', [ 'Example - Changed the Way you Kissed Me' ] = 'gfx/music/ctwykm.mp3', [ 'Example - Kickstart ( Bar 9 Remix )' ] = 'gfx/music/e-ksb9rx.mp3', [ 'Ellie Goulding - Lights ( Remix )' ] = 'http://199.167.195.194/Lights.mp3', [ 'Arkasia - New World Disorder' ] = '', [ 'ATB - You are not Alone ( Remix )' ] = '' } Why I get this error? EPT Team Server Development: 0% Learning C++ | C++ is amazing
drk Posted January 16, 2012 Author Posted January 16, 2012 LOL '-' I will try. Edit: Don't work. Same error but on the argument 1. EPT Team Server Development: 0% Learning C++ | C++ is amazing
FatalTerror Posted January 16, 2012 Posted January 16, 2012 local musics = { [ 'David Guetta - Where Dem Girls At' ] = 'http://199.167.195.194/wdga.mp3', [ 'Coldplay - Paradise' ] = 'http://199.167.195.194/pd.mp3', [ 'Coldplay - Viva la Vida' ] = 'http://199.167.195.194/vlv.mp3', [ 'Ana Malhoa - Danza Kuduro' ] = 'http://199.167.195.194/dk.mp3', [ 'Klaas - The Way' ] = 'http://199.167.195.194/tw.mp3', [ 'Basshunter - All I ever wanted' ] = 'gfx/music/bh-aiew.mp3', [ 'Whiz Khalifa - Black and Yellow' ] = 'gfx/music/wk-bay.mp3', [ 'Skrillex - My name is Skrillex ( Remix )' ] = 'gfx/music/sx-mnis.mp3', [ 'Italobrothers - Stamp on the Ground' ] = 'gfx/music/ib-sotg.mp3', [ 'Madcon - Freaky like Me' ] = 'gfx/music/mc-flm.mp3', [ 'Cut the Music - Greatest Deejay' ] = 'gfx/music/ctm-gd.mp3', [ 'No Name - Time`s Vortex' ] = 'gfx/music/tv.mp3', [ 'Manian - Welcome to the Club' ] = 'gfx/music/wttc.mp3', [ 'Bon Jovi - It`s my Life' ] = 'gfx/music/iml.mp3', [ 'Example - Changed the Way you Kissed Me' ] = 'gfx/music/ctwykm.mp3', [ 'Example - Kickstart ( Bar 9 Remix )' ] = 'gfx/music/e-ksb9rx.mp3', [ 'Ellie Goulding - Lights ( Remix )' ] = 'http://199.167.195.194/Lights.mp3', [ 'Arkasia - New World Disorder' ] = '', [ 'ATB - You are not Alone ( Remix )' ] = '' } local themusic = musics[math.random(0, #musics)] Paid developer. Twitter: @willia_am - http://www.williamdasilva.fr
SDK Posted January 16, 2012 Posted January 16, 2012 Because you changed the indexes of the table, the table should be formatted this way local musics = { [1] = { 'David Guetta - Where Dem Girls At', 'http://199.167.195.194/wdga.mp3'}, [2] = { 'Coldplay - Paradise', 'http://199.167.195.194/pd.mp3'}, [3] = ... } local themusic = musics[math.random(#musics)] local file = themusic[2] local title = themusic[1] Learn Lua - Learn to script - GUI scripting Scripter tools - Find/fix errors yourself(!) Don't pm me for scripting help, keep it for the Scripting subforum!
drk Posted January 16, 2012 Author Posted January 16, 2012 That [1], [2], [3], ... is index, yee? EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted January 16, 2012 Posted January 16, 2012 Yes, it is. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
karlis Posted January 17, 2012 Posted January 17, 2012 #returns length of indexed table only, you may use second indexed table to access random song. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
drk Posted January 18, 2012 Author Posted January 18, 2012 (edited) Hey, now I get this error on line 103: attemp to index field '?'(a nil value) line 113: currentSound = playSound(theSound, true) theSound variable is local theSound = sounds[math.random(2, #randoms)] When the music will change I get this error and the music started plays again =s Edit: Oh, and the #randoms table is local randoms = { 'http://199.167.195.194/wdga.mp3', 'http//199.167.195.194/pd.mp3' } Edited January 18, 2012 by Guest EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted January 18, 2012 Posted January 18, 2012 local theSound = randoms[math.random(#randoms)] San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
drk Posted January 18, 2012 Author Posted January 18, 2012 Ah. I've not seen this I will try Edit: Same error, on line 113. EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted January 18, 2012 Posted January 18, 2012 Post your whole script. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
drk Posted January 18, 2012 Author Posted January 18, 2012 Double click play sound: addEventHandler('onClientGUIDoubleClick', root, function() if source == music_grid then local row, col = guiGridListGetSelectedItem(source) if row and col and row ~= -1 and col ~= -1 then local name = guiGridListGetItemText(source, row, music_grid_column) local song = guiGridListGetItemData(source, row, music_grid_column) if isElement(currentSound) then destroyElement(currentSound) end currentSound = playSound(song, true) guiSetText(music_name, tostring(name)) else if not source then setRandomMusic() end end end end ) Tables: local musics = { [ 'David Guetta - Where Dem Girls At' ] = 'http://199.167.195.194/wdga.mp3', [ 'Coldplay - Paradise' ] = 'http://199.167.195.194/pd.mp3', [ 'Coldplay - Viva la Vida' ] = 'http://199.167.195.194/vlv.mp3', [ 'Ana Malhoa - Danza Kuduro' ] = 'http://199.167.195.194/dk.mp3', [ 'Klaas - The Way' ] = 'http://199.167.195.194/tw.mp3', [ 'Basshunter - All I ever wanted' ] = 'gfx/music/bh-aiew.mp3', [ 'Whiz Khalifa - Black and Yellow' ] = 'gfx/music/wk-bay.mp3', [ 'Skrillex - My name is Skrillex ( Remix )' ] = 'gfx/music/sx-mnis.mp3', [ 'Italobrothers - Stamp on the Ground' ] = 'gfx/music/ib-sotg.mp3', [ 'Madcon - Freaky like Me' ] = 'gfx/music/mc-flm.mp3', [ 'Cut the Music - Greatest Deejay' ] = 'gfx/music/ctm-gd.mp3', [ 'No Name - Time`s Vortex' ] = 'gfx/music/tv.mp3', [ 'Manian - Welcome to the Club' ] = 'gfx/music/wttc.mp3', [ 'Bon Jovi - It`s my Life' ] = 'gfx/music/iml.mp3', [ 'Example - Changed the Way you Kissed Me' ] = 'gfx/music/ctwykm.mp3', [ 'Example - Kickstart ( Bar 9 Remix )' ] = 'gfx/music/e-ksb9rx.mp3', [ 'Ellie Goulding - Lights ( Remix )' ] = 'http://199.167.195.194/Lights.mp3', [ 'Arkasia - New World Disorder' ] = '', [ 'ATB - You are not Alone ( Remix )' ] = '' } local randoms = { 'http://199.167.195.194/wdga.mp3', 'http//199.167.195.194/pd.mp3' } setRandomMusic function: function setRandomMusic () local theSound = randoms[math.random(#randoms)] currentSound = playSound(theSound, true) setTimer(currentSound, 1000, 1) guiSetText(music_name, tostring(name)) end It's not the full code, only a part. EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted January 18, 2012 Posted January 18, 2012 Works perfect.. function setRandomMusic () local theSound = randoms[math.random(#randoms)] currentSound = playSound(theSound, true) guiSetText(music_name, tostring(name)) end I removed that timer because it was useless and wrong used. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
drk Posted January 18, 2012 Author Posted January 18, 2012 LOL Here not works... Edit: But I have to create a timer to when the random music end's starts another, right? And you know why I get the error 'attemp to index field '?'' ?? EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted January 18, 2012 Posted January 18, 2012 I get no error here, maybe is another line? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
drk Posted January 18, 2012 Author Posted January 18, 2012 Line 113: currentSound = playSound(theSound, true) In debugscript appears this line... EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted January 18, 2012 Posted January 18, 2012 Post your WHOLE script, and I mean EVERYTHING. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
drk Posted January 18, 2012 Author Posted January 18, 2012 I will give the code by PM. EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted January 18, 2012 Posted January 18, 2012 Works perfectly, I even executed setRandomMusic() alone and it also works fine. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
drk Posted January 18, 2012 Author Posted January 18, 2012 Try selecting a music on the gridlist, wait for the end and see debugscript EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted January 18, 2012 Posted January 18, 2012 First, the sound will never stop because you set it to loop, second, live streams doesn't has length, so you can't really know when it's over. And third, the script doesn't output any error. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
drk Posted January 19, 2012 Author Posted January 19, 2012 But if live streams don't have length how TG owner has made the random music for the radio of the server clan? '-' EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted January 19, 2012 Posted January 19, 2012 Wiki quote:length: The length of the stream in milliseconds. Always returns 0 for a live stream San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
FatalTerror Posted January 19, 2012 Posted January 19, 2012 I think he create a new event when the sound is stopped, and if it's stopped he set another song Paid developer. Twitter: @willia_am - http://www.williamdasilva.fr
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