Captain Cody Posted September 21, 2014 Share Posted September 21, 2014 How can i make it so on command I can set the volume and with another command set the distance? And If it wouldnt hurt how would I make it so I can change radio station on command "/setstationbeach 1, 2,3 or 4 addEventHandler( 'onClientResourceStart', resourceRoot, function( ) local uSound = playSound3D( 'http://www.181.fm/asx.php?station=181-eagle', 484.724609375, -1830.3310546875, 5.415961265564) setSoundMaxDistance( uSound, 110 ) end ) the wiki atricals I found I couldn't find a think on how to do this And if its too much Im mostly trying to find out how to change the station Link to comment
Anubhav Posted September 21, 2014 Share Posted September 21, 2014 addEventHandler( 'onClientResourceStart', resourceRoot, function( ) uSound = playSound3D( 'http://www.181.fm/asx.php?station=181-eagle', 484.724609375, -1830.3310546875, 5.415961265564) setSoundMaxDistance( uSound, 110 ) end ) addCommandHandler("setsoundistance", function(command, distance) local distance = tonumber(distance) if not tonumber(tostring(distance)) then return end if uSound then setSoundMaxDistance(uSound, tonumber(tostring(distance)) end end ) Link to comment
Captain Cody Posted September 21, 2014 Author Share Posted September 21, 2014 How would I make it so I can switch what it's playing? Example Url1: Url2: url3 Link to comment
Anubhav Posted September 21, 2014 Share Posted September 21, 2014 addEventHandler( 'onClientResourceStart', resourceRoot, function( ) uSound = playSound3D( 'http://www.181.fm/asx.php?station=181-eagle', 484.724609375, -1830.3310546875, 5.415961265564) setSoundMaxDistance( uSound, 110 ) end ) addCommandHandler("setsoundistance", function(command, distance) local distance = tonumber(distance) if not tonumber(tostring(distance)) then return end if uSound then setSoundMaxDistance(uSound, tonumber(tostring(distance)) end end ) addCommandHandler("setsound", function(command, soundURL) if uSound then stopSound(uSound) end backup = uSound destroyElement(uSound) uSound = nil uSound = playSound3D(tostring(soundURL), 484.724609375, -1830.3310546875, 5.415961265564) if uSound then destroyElement(backup) backup = nil outputChatBox('Sound was successfully changed!') else uSound = nil uSound = backup destroyElement(backup) backup = nil end end ) Link to comment
Captain Cody Posted September 21, 2014 Author Share Posted September 21, 2014 What I mean is there anyway to do it from a list of urls that I set in the lua file? Link to comment
Metall Posted September 21, 2014 Share Posted September 21, 2014 What I mean is there anyway to do it from a list of urls that I set in the lua file? 1. Make a GUI using something like GUIEditor. 2. Create a table looking something like this, urls = { {"www.youradress.com/song.mp3"}, } 3. Get the data from that table, for index, data in ipairs(urls) do url = data[1] -- Do something with that data, ex. outputChatBox(data[1]) -- Outputs the url into the chatbox (not needed). end 4. Set that data into a gridlist or something of your choice using something like this, guiCreateGridList guiGridListAddColumn guiGridListAddRow guiGridListSetItemText Should turn into something like this (not tested, only an example) window = guiCreateWindow(0, 0, 0, 0, "Example", false) gridlist = guiCreateGridList(0, 0, 0, 0, false, window) column = guiGridListAddColumn(gridlist, "URLs", 1) urls = { {"http://www.181.fm/asx.php?station=181-eagle"}, } for index, data in ipairs(urls) do local row = guiGridListAddRow(gridlist) guiGridListSetItemText(gridlist, row, column, index, false, false) end And then ofcourse you would have to get that URL from the gridlist and play it using playSound or playSound3D. Link to comment
Anubhav Posted September 22, 2014 Share Posted September 22, 2014 The help was solved, I made it yesterday. I think cody should've posted it here. Link to comment
Metall Posted September 22, 2014 Share Posted September 22, 2014 The help was solved, I made it yesterday.I think cody should've posted it here. What I mean is there anyway to do it from a list of urls that I set in the lua file? You posted a code where you could choose an URL directly from the command. I posted a little guide how to do it with a GUI and a table. Link to comment
Saml1er Posted September 23, 2014 Share Posted September 23, 2014 @Anubav: You don't need to use tostring if you're converting it into a number. Link to comment
Anubhav Posted September 23, 2014 Share Posted September 23, 2014 @Anubav: You don't need to use tostring if you're converting it into a number. (facepalm). What if a player did: /setsoundistance "5" ! Link to comment
Moderators IIYAMA Posted September 25, 2014 Moderators Share Posted September 25, 2014 @Anubav: You don't need to use tostring if you're converting it into a number. (facepalm). What if a player did: /setsoundistance "5" ! Then it still will be a nil. outputChatBox = outputChatBox or print -- For lua demo utility. outputChatBox(tonumber(tostring('"5"'))) 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