Jump to content

[not too important]Radio wont play on speaker click playSound3D


kewizzle

Recommended Posts

Client.lua

heres my script

local speaker = createObject(2232, -657.90002441406, 944.90002441406, 12, 0, 0, 255)
local url = "http://208.85.242.69:9622/listen.pls" 

function playMusic(button)
	if (button) == "left" then
		local sound = playSound3D(url, -657.90002441406, 944.90002441406, 12) 
	else
		stopSound(sound)
	end
end
addEventHandler( "onClientClick", speaker, playMusic )

 

Link to comment

Try this one:
 

function playMusic(button, state, _, _, _, _, _, clickedElement)
	if button == "left" and state == "down" and clickedElement == speaker then
		sound = playSound3D(url, -657.90002441406, 944.90002441406, 12) 
	else
		stopSound(sound)
	end
end
addEventHandler("onClientClick", getRootElement(), playMusic)
Edited by NeXuS™
Link to comment

it only works if im holding the left click button now.

1 hour ago, NeXuS™ said:

Try this one:
 


function playMusic(button, state, _, _, _, _, _, clickedElement)
	if button == "left" and state == "down" and clickedElement == speaker then
		sound = playSound3D(url, -657.90002441406, 944.90002441406, 12) 
	else
		stopSound(sound)
	end
end
addEventHandler("onClientClick", getRootElement(), playMusic)

this works but then i right click the speaker the radio keeps playing

function playMusic(button, state, _, _, _, _, _, clickedElement)
	if button == "left" and clickedElement == speaker then
		sound = playSound3D(url, -657.90002441406, 944.90002441406, 12) 
	else 
		stopSound(sound)
	end
end
addEventHandler("onClientClick", getRootElement(), playMusic)

 

Link to comment
function playMusic(button, state, _, _, _, _, _, clickedElement)
	if button == "left" and state == "down" and clickedElement == speaker then
		if isElement(sound) then
			stopSound(sound)
		else
			sound = playSound3D(url, -657.90002441406, 944.90002441406, 12)
		end
	end
end
addEventHandler("onClientClick", getRootElement(), playMusic)

 

  • Like 1
Link to comment
1 hour ago, NeXuS™ said:

function playMusic(button, state, _, _, _, _, _, clickedElement)
	if button == "left" and state == "down" and clickedElement == speaker then
		if isElement(sound) then
			stopSound(sound)
		else
			sound = playSound3D(url, -657.90002441406, 944.90002441406, 12)
		end
	end
end
addEventHandler("onClientClick", getRootElement(), playMusic)

 

works thanks.

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