Jump to content

onclientguiclick play sound


greenops011

Recommended Posts

Posted (edited)

So, I'm working on doing some scripting with the MDC in the oG open source scripts. what I'm trying to do is when the person clicks on a button, spacer.png

say, search database, it will play a sound effect, like https://on.soundcloud.com/ZygMG

 

just wondering how I would go about doing that?

Edited by greenops011
updated soundcloud link
Posted

Hi, by using playSound inside onClientGUIClick event handler for this specific button.

You'll have add your music to the resource and then find the part where this GUI window is scripted to add playSound function inside the existing event handler.

Posted
18 hours ago, Mkl said:

Hi, by using playSound inside onClientGUIClick event handler for this specific button.

You'll have add your music to the resource and then find the part where this GUI window is scripted to add playSound function inside the existing event handler.

So, would something like this work?

 

window.dialog.closeButton = guiCreateButton( 10, 60, width - 20, 40, "Close", false, window.dialog.window )
	addEventHandler( "onClientGUIClick", window.dialog.closeButton,
		function ()
			guiSetVisible( window.dialog.window, false )
			destroyElement( window.dialog.window )
			window.dialog = { }
    	    local sound = playSound("tap.wav")
            setSoundVolume(sound, 0.5)
		end
	, false )
end

 

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