Jump to content

[HELP] PlaySound3D


[M]ister

Recommended Posts

Hello I want to create a table with musics, When a song ends, another begins, but I do not know how I could be doing this, I created the following script below (don't work)

local randoms = { 
    'http://1in.kz/s/music/1313125085_one-direction-what-makes-you-beautiful.mp3', 
    'http://promodj.com/source/3080390/Eiffel_65_Blue_DJ_Pasha_Lee_DJ_Vitaco_remix.mp3' 
} 
     
function setRandomMusic () 
    local theSound = randoms[math.random(#randoms)] 
end 
setTimer(setRandomMusic, 10000, 1) 
  
function setMusicPlay () 
    local sound = playSound3D(theSound, -2631, 1377, 7, true) 
    setSoundVolume(sound, 1.0) 
    setSoundMaxDistance(sound, 50) 
end 
addEventHandler( "onClientResourceStart", getRootElement( ), setMusicPlay) 

Link to comment
local randoms = { 
    'http://1in.kz/s/music/1313125085_one-direction-what-makes-you-beautiful.mp3', 
    'http://promodj.com/source/3080390/Eiffel_65_Blue_DJ_Pasha_Lee_DJ_Vitaco_remix.mp3' 
} 
    
function setRandomMusic() 
    if isElement(sound) then destroyElement(sound) end 
    sound = playSound3D(randoms[math.random(#randoms)], -2631, 1377, 7, true) 
    setSoundVolume(sound, 1.0) 
    setSoundMaxDistance(sound, 50) 
end 
setTimer(setRandomMusic, 10000, 1) 
addEventHandler("onClientResourceStart", resourceRoot, setRandomMusic) 

Link to comment

Try this:

local randoms = { 
    'http://1in.kz/s/music/1313125085_one-direction-what-makes-you-beautiful.mp3', 
    'http://promodj.com/source/3080390/Eiffel_65_Blue_DJ_Pasha_Lee_DJ_Vitaco_remix.mp3' 
} 
    
function setRandomMusic() 
    if isElement(sound) then destroyElement(sound) end 
    index = #randoms > (index or 0) and (index or 0) + 1 or 1 
    sound = playSound3D(randoms[index], -2631, 1377, 7, true) 
    setSoundVolume(sound, 1.0) 
    setSoundMaxDistance(sound, 50) 
end 
addEventHandler("onClientResourceStart", resourceRoot, setRandomMusic) 
  
addEventHandler("onClientSoundStream", root, 
function(suc, length) 
    if suc and length > 0 then 
        setTimer(setRandomMusic, length*1000, 1) 
    else 
        setRandomMusic() 
    end 
end) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...