Difference between revisions of "SetSoundEffectEnabled"

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with '__NOTOC__ {{Client function}} Used to enable or disable specific sound effects. ==Syntax== <syntaxhighlight lang="lua">int setSoundEffectEnabled ( element sound, string effectName, bool togg…')
 
(added player element which will affect player voice)
 
(11 intermediate revisions by 9 users not shown)
Line 1: Line 1:
 
__NOTOC__  
 
__NOTOC__  
 
{{Client function}}
 
{{Client function}}
Used to enable or disable specific sound effects.
+
Used to enable or disable specific [[sound]] effects.
 
+
{{New feature/item|3.0132|1.3.2||
 +
Use a [[player]] element to control a players voice with this function.
 +
}}
 
==Syntax==  
 
==Syntax==  
<syntaxhighlight lang="lua">int setSoundEffectEnabled ( element sound, string effectName, bool toggle )</syntaxhighlight>  
+
<syntaxhighlight lang="lua">bool setSoundEffectEnabled ( element theSound/thePlayer, string effectName, bool bEnable )</syntaxhighlight>  
 
+
{{OOP||[[sound]]:setEffectEnabled}}
 
===Required Arguments===  
 
===Required Arguments===  
*'''sound:''' a [[sound]] element.
+
*'''sound:''' a [[sound]] element or a [[player]] element which will affect the [[Resource:Voice|voice]] broadcast.
 
*'''effectName:''' the effect you want to enable or disable
 
*'''effectName:''' the effect you want to enable or disable
 
{{Sound_Effects}}
 
{{Sound_Effects}}
*'''toggle:''' ''true'' if you want to enable the effect, ''false'' if you want to disable it.
+
*'''bEnable:''' ''true'' if you want to enable the effect, ''false'' if you want to disable it.
  
 
===Returns===
 
===Returns===
Line 16: Line 18:
  
 
==Example==  
 
==Example==  
<syntaxhighlight lang="lua">
+
This example creates a sound and set's the flanger sound effect enabled.
-- TODO
+
<syntaxhighlight lang="lua">addCommandHandler("flanger",function(cmd,enabled)
 +
if(isElement(waterSplashes))then
 +
setSoundEffectEnabled(waterSplashes,cmd,enabled)
 +
else
 +
waterSplashes = playSound("splashes.mp3",true)
 +
setSoundEffectEnabled(waterSplashes,cmd,enabled)
 +
end
 +
end,true) --set it case sensitive as we are going to get the command name and use it in the setSoundEffectEnabled
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
==Changelog==
 +
{{ChangelogHeader}}
 +
{{ChangelogItem|1.3.2|Added player element for voice control}}
  
 
==See Also==
 
==See Also==
 
{{Client_audio_functions}}
 
{{Client_audio_functions}}
  
[[Category:Needs_Example]]
+
[[hu:setSoundEffectEnabled]]
 +
[[ar:setSoundEffectEnabled]]
 +
[[RO:setSoundEffectEnabled]]

Latest revision as of 07:45, 29 December 2019

Used to enable or disable specific sound effects. Use a player element to control a players voice with this function.

Syntax

bool setSoundEffectEnabled ( element theSound/thePlayer, string effectName, bool bEnable )

OOP Syntax Help! I don't understand this!

Method: sound:setEffectEnabled(...)

Required Arguments

  • sound: a sound element or a player element which will affect the voice broadcast.
  • effectName: the effect you want to enable or disable
  • gargle
  • compressor
  • echo
  • i3dl2reverb
  • distortion
  • chorus
  • parameq
  • reverb
  • flanger
  • bEnable: true if you want to enable the effect, false if you want to disable it.

Returns

Returns true if the effect was set successfully, false otherwise.

Example

This example creates a sound and set's the flanger sound effect enabled.

addCommandHandler("flanger",function(cmd,enabled)
	if(isElement(waterSplashes))then
		setSoundEffectEnabled(waterSplashes,cmd,enabled)
	else
		waterSplashes = playSound("splashes.mp3",true)
		setSoundEffectEnabled(waterSplashes,cmd,enabled)
	end
end,true) --set it case sensitive as we are going to get the command name and use it in the setSoundEffectEnabled

Changelog

Version Description
1.3.2 Added player element for voice control

See Also

BETA: FROM VERSION 1.5.8 r20785 ONWARDS
BETA: FROM VERSION 1.5.8 r20785 ONWARDS