krYshuT Posted January 9, 2011 Share Posted January 9, 2011 Hello, So I saw this map with MP3 song in it. I wonder, if there is a way to set it to not-play on beginning of the map. It can be turned off with M, but it's boring for most people hearing it again on each start, so I'd like to set it to never play on start, but people can turn it on back with M. Here's the script: local sound addEventHandler('onClientResourceStart', resourceRoot, function () outputChatBox("Press M to toggle between music / radio") sound = playSound("song.mp3",false) end ) local toggle = false bindKey("m","down", function() if toggle then setSoundVolume(sound,0) toggle = false else setSoundVolume(sound,1) toggle = true end end ) The line "local toggle = false" was originally with true value and I thought it might fix it, but it didn't. The song still plays on start. Link to comment
Castillo Posted January 9, 2011 Share Posted January 9, 2011 local sound addEventHandler('onClientResourceStart', resourceRoot, function () outputChatBox("Press M to toggle between music / radio") sound = playSound("song.mp3",false) end ) local toggle = false bindKey("m","down", function() if toggle == false then setSoundVolume(sound,1) toggle = true elseif toggle == true then setSoundVolume(sound,0) toggle = false end end ) P.S: Use LUA tags next time. Link to comment
krYshuT Posted January 9, 2011 Author Share Posted January 9, 2011 I already found another way, but thanks I just added "setSoundVolume(sound, 0)" and it works the same way. 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