JoZeFSvK Posted April 15, 2013 Share Posted April 15, 2013 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) Link to comment
Castillo Posted April 15, 2013 Share Posted April 15, 2013 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. Link to comment
JoZeFSvK Posted April 16, 2013 Author Share Posted April 16, 2013 i try your code but it work for 1 times when i play next map then dont work like onClientMapStarting dont work Link to comment
Castillo Posted April 17, 2013 Share Posted April 17, 2013 That's because "songOn" is set to true for when next map starts. Link to comment
JoZeFSvK Posted April 17, 2013 Author Share Posted April 17, 2013 hmm i write to false but when player death he hears "100%" but when map start he hears 50% Link to comment
Pe/\/duluM Posted April 20, 2013 Share Posted April 20, 2013 A bit of coding knowledge and you would know, that if you just remove the "songOn" variable check and set, it should actually work for every map. Link to comment
JoZeFSvK Posted April 20, 2013 Author Share Posted April 20, 2013 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% 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