SnoopCat Posted September 2, 2012 Share Posted September 2, 2012 hey guys i have downloaded a radio from the mtasa resource download website and i want to know how i can disable the race map music only when radio player is on , and if the radio player is off then map musica can be activated again local channels = { } local localChannel = 0 local radioSound = nil setRadioChannel( 0 ) local scx, scy = guiGetScreenSize( ) local handled = false local volumee = 100 outputChatBox("Radio systen Online",255,255,255,true) function addNewChannel( radioname, streamurl ) if type( radioname ) == "string" and type( streamurl ) == "string" then table.insert( channels, { [ 1 ] = streamurl, [ 2 ] = radioname } ) end end nincsPrev = false addEventHandler( "onClientPlayerRadioSwitch", root, cancelEvent ) nincsNext = false function drawRadioChannelName( ) if channels[ localChannel ] then local radioName = channels[ localChannel ][ 2 ] or "Radio OFF!" local localChannel2 = localChannel-1 or "Radio OFF!" local localChannel3 = localChannel+1 or "Radio OFF!" if localChannel2 <= 0 then nincsPrev = true else nincsPrev = false prevRadio = channels[ localChannel2 ][ 2 ] end if localChannel3 == #channels+1 then nincsNext = true else nincsNext = false nextRadio = channels[ localChannel3 ][ 2 ] end if radioName then local text = "Radio: "..radioName.."" if nincsPrev == false then text2 = "Prev: "..prevRadio.."" else text2 = "" end if nincsNext == false then text3 = "Next: "..nextRadio.."" else text3 = "" end local fontsize = 1.5 local font="default-bold" local width,height=dxGetTextWidth(text,fontsize,font),dxGetFontHeight(fontsize,font) local width2,height2=dxGetTextWidth(text2,fontsize,font),dxGetFontHeight(fontsize,font) local width3,height3=dxGetTextWidth(text3,fontsize,font),dxGetFontHeight(fontsize,font) szoveg = dxDrawText(text,scx/2-width/2+2,scy-height+2,0,0,tocolor(0,0,0,255),fontsize,font) szoveg2 = dxDrawText(text,scx/2-width/2,scy-height,0,0,tocolor(0,255,0,255),fontsize,font) szoveg3 = dxDrawText(text2,scx/2-width2-width+2,scy-height2+2,0,0,tocolor(0,0,0,255),fontsize,font) szoveg4 = dxDrawText(text2,scx/2-width2-width,scy-height2,0,0,tocolor(50,255,50,255),fontsize,font) szoveg5 = dxDrawText(text3,scx/2+width+2,scy-height3+2,0,0,tocolor(0,0,0,255),fontsize,font) szoveg6 = dxDrawText(text3,scx/2+width,scy-height3,0,0,tocolor(50,255,50,255),fontsize,font) rectangle = dxDrawRectangle(0, scy - height - 10, scx, height+10, tocolor(0, 0, 0, 120), false) end end end function previousradio( ) if volumee ~= 0 then localChannel = localChannel - 1 if localChannel <= 0 then localChannel = 0 end local previousRadio = channels[ localChannel ] if previousRadio then if radioSound then stopSound( radioSound ) end local radioName = previousRadio[ 2 ] if radioName ~= "Radio Off" then if not radioSound then playSoundFrontEnd(47) if isTimer(timerke) then killTimer(timerke) end timerke = setTimer(function() radioSound = playSound( channels[ 2 ][ 1 ], true ) playSoundFrontEnd(48) end,math.random(200,1000),1) else playSoundFrontEnd(47) if isTimer(timerke) then killTimer(timerke) end timerke = setTimer(function() radioSound = playSound( previousRadio[ 1 ], true ) playSoundFrontEnd(48) end,math.random(200,1000),1) end end end if not handled then handled = true addEventHandler( "onClientRender", root, drawRadioChannelName ) setTimer( function( ) handled = false removeEventHandler( "onClientRender", root, drawRadioChannelName ) end, 6000, 1 ) end end end function nextradio( ) if volumee ~= 0 then localChannel = localChannel + 1 if localChannel >= #channels then localChannel = #channels end local previousRadio = channels[ localChannel ] if previousRadio then if radioSound then stopSound( radioSound ) end local radioName = previousRadio[ 2 ] if radioName ~= "Radio Off" then if not radioSound then playSoundFrontEnd(47) if isTimer(timerke) then killTimer(timerke) end timerke = setTimer(function() radioSound = playSound( channels[ 2 ][ 1 ], true ) playSoundFrontEnd(48) end,math.random(200,1000),1) else playSoundFrontEnd(47) if isTimer(timerke) then killTimer(timerke) end timerke = setTimer(function() radioSound = playSound( previousRadio[ 1 ], true ) playSoundFrontEnd(48) end,math.random(200,1000),1) end end end if not handled then handled = true addEventHandler("onClientRender", root, drawRadioChannelName ) setTimer( function( ) handled = false removeEventHandler( "onClientRender", root, drawRadioChannelName ) end, 6000, 1 ) end end end function radio() addNewChannel("TechnoBase.FM","http://dsl.tb-stream.net:80") addNewChannel("HouseTime.FM","http://listen.HouseTime.fm/dsl.pls") addNewChannel("HardBase.FM","http://listen.hardbase.fm/dsl.pls") addNewChannel("TranceBase.FM","http://listen.TranceBase.fm/dsl.pls") addNewChannel("ClubTime.FM","http://listen.ClubTime.fm/dsl.pls") addNewChannel("CoreTime.FM","http://listen.CoreTime.fm/dsl.pls") addNewChannel("MiNiMaL","http://stream.uzic.ch:9010/") addNewChannel("RetroRadio","http://91.120.50.11:8000/listen") addNewChannel("iNSANE","http://newinsane.info/ochi/insane.m3u") addNewChannel("Radio 1","http://195.70.35.172:8000/radio1.mp3.m3u") addNewChannel("Neo * Fm","http://www.xhosting.hu/NeoFM/128_kbs_mp3.m3u") addNewChannel("Rock FM","http://92.48.118.17:9450/listen.pls") addNewChannel("Cool * Fm","http://coolfm.puskas.hu/listen.m3u") addNewChannel("Best FM","http://radyo1.kolayradyo.com:9035") addNewChannel("Coronita|Radio","http://stream.justmusic.fm:8600/just_coronita") addNewChannel("Radio Off","off") bindKey( "mouse_wheel_up", "both", nextradio ) bindKey( "mouse_wheel_down", "both", previousradio ) bindKey( "r", "down", nextradio ) end addEventHandler( "onClientResourceStart", resourceRoot, radio ) function setRadioVolume( volume ) if type( volume ) == "number" then if radioSound and isElement( radioSound ) and radioChannel ~= 0 then setSoundVolume( radioSound, volume ) volumee = volume end end end Link to comment
verona Posted September 2, 2012 Share Posted September 2, 2012 What is a "race map music"? I think you have to edit Race script, not Radio script, because you want disable "race music" when radio is on, not disable radio when "race map music" is on Or if "race map music" is a music in map (in .lua script of map) then you have to edit script of this map 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