Jump to content

Music scirpt help !


Eht1

Recommended Posts

I Try create music script, when you join then need play random music on internet all time when you play game.

I try with this but not work.

function addSound ( link ) 
  
addSound ( "http://www.mysound1.com/sound1" ) 
addSound ( "http://www.mysound1.com/sound2" ) 
  
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() 
        playSound(sounds[math.random(1, addSound)]) 
end 
) 
   

Link is not real this is for example.

 

 

Link to comment
  
function links (link) 
local link1 = ( "http://www.mysound1.com/sound1" ) 
local link2 = ( "http://www.mysound1.com/sound2" ) 
end 
  
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() 
        playSound(sounds[math.random(1, links)]) 
end 
) 
  
  

EDIT: The Handler, starts the music when resource starts, you must change if want music on join.

Link to comment

Not work :?

function links (link) 
local link1 = ( "jutjub.comze.com/Music/Mc%20Hush%20-%20Fired%20Up.mp3" ) 
local link2 = ( "jutjub.comze.com/Music/Rock%20-%20I%20Am%20Rock.mp3" ) 
end 
  
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() 
        playSound(sounds[math.random(1, links)]) 
end 
) 
  

In meta.xml is on client side.

EDIT: I want like when you join music need play all time widauth stop. But random.

Link to comment
  
addEventHandler('onClientPlayerJoin', root, 
function() 
local link1 = ( "http://www.mysound1.com/sound1" ) 
local link2 = ( "http://www.mysound1.com/sound2" ) 
        randomlinks = math.random(link1,link2) 
        playSound ( randomlinks ) 
end 
) 
  
  

Link to comment
  • Scripting Moderators

client:

local sounds = { 
    "http://www.mysound1.com/sound1", 
    "http://www.mysound1.com/sound2" 
} 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() 
    playSound(sounds[math.random(1, #sounds)]) 
end 
) 

Link to comment

if you know the first sound length , then you can set timer after the song is finished to play the next one

  
local sound1 = "http://www.mysound1.com/sound1" 
local sound2 = "http://www.mysound1.com/sound2" 
  
addEventHandler("onClientPlayerJoin", getResourceRootElement(getThisResource()), function() 
    playSound(sound1) 
    local sound1Length = 60 -- in seconds 
    setTimer(playSound,sound1Length*1000,1,sound2) 
end 
) 
  

Link to comment
  
local sound1 = "http://www.mysound1.com/sound1" 
local sound2 = "http://www.mysound1.com/sound2" 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() 
    playSound(sound1) 
    setTimer(playSound,getSoundLength(sound1)*1000,1,sound2) 
end 
) 
  

No need to input the sound length, MTA has functions for these things @ Al3grab

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...