Jump to content

help with music on my server


MatiasRuff

Recommended Posts

So you already have a song?

If you do, here's a simple tutorial:

First, you need to put the song into your resource. Then, add it to your meta.xml which should be located into your resource. You can do that by placing this code between the tags.

  
<file src="music.mp3" /> 
  

Then, create a new clientside script and add an event handler. For example, we will use onClientResourceStart: This will be triggered when the resource starts, or you join the server.

  
addEventHandler ( "onClientResourceStart", getResourceRootElement ( getThisResource ( ) ), startSound ) 
  

There we added the event, which will only be triggered if THAT resource starts. If it's get triggered, this event will trigger the function startSound (), so lets make that now.

  
function startSound ( ) -- Adding the function 
    playSound ( "music.mp3", true )  
    -- "music.mp3": the path to your music. This is the same path that you defined in meta.xml. 
    -- true: This will represent if the music will be repeated after it has been ended. True for "yes", false for "no". 
end -- Ending the function ofcourse  
  

So, that's all you need to know for a beginner. It's all about adding the music to your meta.xml, and using playSound wherever you want.

You could also use the iPod, which is downloadable on the community. This doesn't need any script experience :P

Download.

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