Hello Today u will Learn How to add music to your map !
How it works ? - When Map starts The music goes u can stopt it with Button
Ok let's Start !
make a new text document and add .lua at the end and add this line in the meta.XML -
Quote from:
<script src="nameofthescript.lua"
And Add this -
Quote from:
<file src="yoursongname" />
Next-
Add This script to your created notepad !
Quote from:
function startMusic()
setRadioChannel(0)
song = playSound("music.mp3",true)
outputChatBox("Toggle music on/off using B important:Custom map cannot be played 2 time in a row")
end
function makeRadioStayOff()
setRadioChannel(0)
cancelEvent()
end
function toggleSong()
if not songOff then
setSoundVolume(song,0)
songOff = true
removeEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff)
else
setSoundVolume(song,1)
songOff = false
setRadioChannel(0)
addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff)
end
end
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),startMusic)
addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff)
addEventHandler("onClientPlayerVehicleEnter",getRootElement(),makeRadioStayOff)
addCommandHandler("musicmusic",toggleSong)
bindKey("b","down","musicmusic")
addEventHandler("onClientResourceStop",getResourceRootElement(getThisResource()),startMusic)
song = playSound("music.mp3",true) - Replace music.mp3 with your song
Add your song to Map folder ! . P.S Music name must named as in the script !
The End