Jump to content

Song in map


krYshuT

Recommended Posts

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

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