Jump to content

Muting Sound


'LinKin

Recommended Posts

Hello,

I've a GUI. Some checkbox to toggle on/off the sounds in-game. (For example when someone dies I play a .mp3)

So, I was wondering how to toggle them off.. Maybe setting it's volume to 0 ?

For example this situation:

I'm playing a 1min long sound, at the beginning the player has it's checkbox unselected, so the sound will not be heard by him. But in the middle of the sound (sec 30) he selects this checkbox. So he would be hearing the sound at sec 30.

I'm thinking about working with the volume.. hm, but maybe is there any other way?

Thanks.

Link to comment

Just start music sometime, f.e. onClientResourceStart and set his volume to 0. And put in your script such a thing

local checkbox = (...) 
local sound = playSound (...) 
setSoundVolume ( sound, 0 ) 
  
addEventHandler ( "onClientGUIClick", checkbox, 
    function ( ) 
        if ( guiCheckBoxGetSelected ( checkbox ) ) then 
            setSoundVolume ( sound, 1 ) 
        else 
            setSoundVolume ( sound, 0 ) 
        end 
    end, 
false ) 

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