local Music = false

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function()
    Music = playSound("music.mp3", true)
    setRadioChannel(0)
end)

addEventHandler("onClientPlayerRadioSwitch", getRootElement(), function()
    if getRadioChannel() > 0 then
        setRadioChannel(0)
    end
    cancelEvent()
end)

addEventHandler("onClientPlayerVehicleEnter", getRootElement(), function()
    setRadioChannel(0)
    cancelEvent()
end)

addCommandHandler("music", function()
    if Music then
        if getSoundVolume(Music) == 0 then
            setSoundVolume(Music, 1)
        elseif getSoundVolume(Music) == 1 then
            setSoundVolume(Music, 0)
        end
    end
end)
bindKey("m", "down", "music")