Jump to content

[HELP] Radio / mapSong Script


Zivrok

Recommended Posts

Hello there, hope you doing well , so i was wondering where's the problem in my script , ( my goal is to start radio and stop map music /  stop radio map music start )

here's my codes *

Client side

 

--script By Zivrok--//


function startMusic()
    setRadioChannel(1)
    tfcsong = playSound("http://listen.181fm.com/181-energy98_128k.mp3",true)
	
end

function makeRadioStayOff()
    setRadioChannel(1)
    cancelEvent()
end

function toggleSong()
    if not songOff then
	    setSoundVolume(tfcsong,0)
		songOff = true
		removeEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff)
	else
	    setSoundVolume(tfcsong,1)
		songOff = false
		setRadioChannel(1)
		addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff)
	end
end

addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),startMusic)
addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff)
addEventHandler("onClientPlayerVehicleEnter",getRootElement(),makeRadioStayOff)
addCommandHandler("radio",toggleSong)
bindKey("j","down","radio")

------------------

Server side

function stopmapmusic ()
if tfcsong = true then
  setSoundVolume(song,0)
else 

 setSoundVolume(song,1)
end
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),stopmapmusic)

i hope i'll find help soon , thank you

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