Jump to content

Set sound for all maps to 50 %


JoZeFSvK

Recommended Posts

Posted

Hey i wanna create when map start set map music to 50% or less this is my code but dont work who know where will problem ? thank you

addEventHandler("onClientMapStarting",getRootElement(), 
function radioFix() 
    if not songOn then 
        setSoundVolume(getRootElement(),0.3) 
        songOn = true 
        setElementData(getLocalPlayer(),"Radio.Channel",tonumber(getRadioChannel())) 
        setRadioChannel(0) 
        addEventHandler("onClientPlayerRadioSwitch",getRootElement(),radioFix) 
    end 
end) 
  

Posted
function radioFix ( ) 
    if ( not songOn ) then 
        for _, sound in ipairs ( getElementsByType ( "sound" ) ) do 
            setSoundVolume ( sound, 0.3 ) 
        end 
        songOn = true 
        setElementData ( localPlayer, "Radio.Channel", tonumber ( getRadioChannel ( ) ) ) 
        setRadioChannel ( 0 ) 
        addEventHandler ( "onClientPlayerRadioSwitch", getRootElement(), radioFix ) 
    end 
end 
addEventHandler ( "onClientMapStarting", root, radioFix ) 

Try it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

That's because "songOn" is set to true for when next map starts.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

ah when i remove songOn on write to false when i dead i will head song on 100% and i dont want this i wanna on all maps and when i death set song volume to 50%

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