raynner Posted October 12, 2016 Share Posted October 12, 2016 Good'm creating a tuning shop for my RPG server. most did not want to use files files to decrease the MB script ... so I had the idea of creating music using random using playSound3D URL .. but I have two errors. ERROR 1 = Table does not work. ERROR 2 = He is not changing the interior or the size of the element. can anyone point me a correct direction or point out the error in my script? Client Sid local URLMusics = { {'https://albireo1.sscdn.co/palcomp3/2/a/b/9/equipeinsanos-tribo-da-periferia-mussoumano-convida-6ec60699.mp3'}, {'https://japeto.sscdn.co/palcomp3/a/5/4/a/equipeinsanos-tribodaperiferia-carro-velho-ec4211d7-e7b4a010.mp3'} } function ShowDxMenuStartTuning() addEventHandler("onClientRender", root, DXMenuPrincipal) showCursor(true) PainelMenuPrincipal = true MusicTuning() end addEvent("ShowPainelMenuStartTuning", true) addEventHandler("ShowPainelMenuStartTuning", getRootElement(), ShowDxMenuStartTuning) function MusicTuning() local randomize = math.random ( #URLMusics ) local TuningSound = playSound3D('URLMusics[randomize]',1383,-22,1001,true) setSoundMaxDistance(TuningSound,50) triggerServerEvent("StartSond", root, TuningSound) end Server Sid DIMS___ = 1 function DimensionSond(TuningSound) setElementDimension(TuningSound,DIMS___) setElementInterior(TuningSound,1) setElementPosition(TuningSound,1383,-22,1001) DIMS___ = DIMS___ + 1 end addEvent("StartSond", true) addEventHandler("StartSond", getRootElement(), DimensionSond) Link to comment
Adolfram Posted October 12, 2016 Share Posted October 12, 2016 your usage of tables is wrong, i corrected it for you here: local TuningSound = playSound3D(URLMusics[randomize], 1383, -22, 1001, true) -- you don't need to turn it into a string and it's not how turning a variable/table into a string is done. you should use tostring for that but in your case, table member returns a string value (your url) so you don't need it at all secondly you don't need to set sound's dimension and interior on serverside, and you can't because it's not synced. so you can basically do move your "DimensionSond" script to client side and run it. here's how it should look like: function MusicTuning() local randomize = math.random ( #URLMusics ) local TuningSound = playSound3D(URLMusics[randomize],1383,-22,1001,true) setSoundMaxDistance(TuningSound,50) DimensionSond (TuningSound) end DIMS___ = 1 function DimensionSond(TuningSound) setElementDimension(TuningSound,DIMS___) setElementInterior(TuningSound,1) setElementPosition(TuningSound,1383,-22,1001) DIMS___ = DIMS___ + 1 end in the end, your code should look like: local URLMusics = { {'https://albireo1.sscdn.co/palcomp3/2/a/b/9/equipeinsanos-tribo-da-periferia-mussoumano-convida-6ec60699.mp3'}, {'https://japeto.sscdn.co/palcomp3/a/5/4/a/equipeinsanos-tribodaperiferia-carro-velho-ec4211d7-e7b4a010.mp3'} } function ShowDxMenuStartTuning() addEventHandler("onClientRender", root, DXMenuPrincipal) showCursor(true) PainelMenuPrincipal = true MusicTuning() end addEvent("ShowPainelMenuStartTuning", true) addEventHandler("ShowPainelMenuStartTuning", getRootElement(), ShowDxMenuStartTuning) function MusicTuning() local randomize = math.random ( #URLMusics ) local TuningSound = playSound3D(URLMusics[randomize],1383,-22,1001,true) setSoundMaxDistance(TuningSound,50) DimensionSond (TuningSound) end DIMS___ = 1 function DimensionSond(TuningSound) setElementDimension(TuningSound,DIMS___) setElementInterior(TuningSound,1) setElementPosition(TuningSound,1383,-22,1001) DIMS___ = DIMS___ + 1 end Link to comment
raynner Posted October 12, 2016 Author Share Posted October 12, 2016 25 minutes ago, Adolfram said: in the end, your code should look like: local URLMusics ={{'https://albireo1.sscdn.co/palcomp3/2/a/b/9/equipeinsanos-tribo-da-periferia-mussoumano-convida-6ec60699.mp3'},{'https://japeto.sscdn.co/palcomp3/a/5/4/a/equipeinsanos-tribodaperiferia-carro-velho-ec4211d7-e7b4a010.mp3'}} function ShowDxMenuStartTuning() addEventHandler("onClientRender", root, DXMenuPrincipal) showCursor(true) PainelMenuPrincipal = true MusicTuning() end addEvent("ShowPainelMenuStartTuning", true) addEventHandler("ShowPainelMenuStartTuning", getRootElement(), ShowDxMenuStartTuning) function MusicTuning() local randomize = math.random ( #URLMusics ) local TuningSound = playSound3D(URLMusics[randomize],1383,-22,1001,true) setSoundMaxDistance(TuningSound,50) DimensionSond (TuningSound) end DIMS___ = 1 function DimensionSond(TuningSound) setElementDimension(TuningSound,DIMS___) setElementInterior(TuningSound,1) setElementPosition(TuningSound,1383,-22,1001) DIMS___ = DIMS___ + 1 end Well I did not know that it was now possible to use setElementDimension and setElementInterior in Client Sid .. so no need to do so in a new function ... good yet still I have an error with the table he asks the first argument in playSound3D as a string and .... current code. Client sid local URLMusics ={{'https://albireo1.sscdn.co/palcomp3/2/a/b/9/equipeinsanos-tribo-da-periferia-mussoumano-convida-6ec60699.mp3'}, {'https://japeto.sscdn.co/palcomp3/a/5/4/a/equipeinsanos-tribodaperiferia-carro-velho-ec4211d7-e7b4a010.mp3'} } DIMS___ = 1 function MusicTuning() local randomize = math.random ( #URLMusics ) local TuningSound = playSound3D(URLMusics[randomize],1383,-22,1001,true) --> put a string table as it emits no more mistakes does not work setSoundMaxDistance(TuningSound,50) setElementDimension(TuningSound,DIMS___) setElementInterior(TuningSound,1) setElementPosition(TuningSound,1383,-22,1001) DIMS___ = DIMS___ + 1 end Link to comment
Adolfram Posted October 12, 2016 Share Posted October 12, 2016 right. you should remove {} tags around the URL strings, it should be like local URLMusics = { 'url', 'url' } Link to comment
raynner Posted October 12, 2016 Author Share Posted October 12, 2016 2 minutes ago, Adolfram said: right. you should remove {} tags around the URL strings, it should be like local URLMusics = { 'url', 'url' } hehe We forget that text table is = {'abc', 'abc'} have not tested more this will work for sure my carelessness solved Working perfectly Link to comment
raynner Posted October 14, 2016 Author Share Posted October 14, 2016 (edited) Now from what I could tell when entering 2 or more players he did not play a sound to the second element on only the first to create a table would be necessary to TuningSound Edited October 14, 2016 by raynner Link to comment
koragg Posted October 14, 2016 Share Posted October 14, 2016 Please use english around here so everybody understand you. Link to comment
raynner Posted October 15, 2016 Author Share Posted October 15, 2016 vI have a problem with the script above. Upon entering the garage he plays the music more to get a second or third person does not touch! It would be necessary to create a table or have an Error? sorry I do not know much english 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