setSoundEffect: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Text replacement - "(\|[pr][0-9]+ *= *[^- ]*) *- *P([a-gi-z ])" to "$1 - p$2")
 
(67 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


|arma|= Game name
|game1= arma1
|version1= 1.00


|1.00|= Game version
|game2= arma2
____________________________________________________________________________________________
|version2= 1.00


| Defines the different sound effects.  
|game3= arma2oa
|version3= 1.50


* Sound - plays a 2D sound from CfgSounds
|game4= tkoh
* Voice - plays a 3D sound from CfgSounds
|version4= 1.00
* SoundEnv - plays an environmental sound from CfgEnvSounds
* SoundDet (only for triggers) - creates a dynamic sound object attached to a trigger defined in [[CfgSFX]]


To stop any sound, deactivate the trigger (might take up to 0.5 sec to stop) or delete the trigger (immediate). Also use <tt>"$NONE$"</tt> to skip the sound (1st item), when there is none to be used (Example 3, 4, 5). |= Description
|game5= arma3
____________________________________________________________________________________________
|version5= 0.50


| trigger '''setSoundEffect''' [sound, voice, soundEnv, soundDet] |= Syntax
|gr1= Sounds


|p1= trigger: [[Object]] |= Parameter 1
|gr2= Triggers


|p2= [sound, voice, soundEnv, soundDet]: [[Array]] of strings |= Parameter 2
|gr3= Waypoints


| [[Nothing]] |= Return value
|descr= Defines the different sound effects for a trigger or a waypoint. To stop any sound, deactivate the trigger (might take up to 0.5 seconds to stop) or delete the trigger/waypoint (immediate).
____________________________________________________________________________________________


|s2= waypoint '''setSoundEffect''' [sound, voice, soundEnv, soundDet] |= Syntax
|s1= trigger [[setSoundEffect]] [sound, voice, soundEnv, soundDet]


|p21= waypoint: [[Array]] - format [[Waypoint]] |= Parameter 1
|p1= trigger: [[Object]]


|p22= [sound, voice, soundEnv, soundDet]: [[Array]] of strings |= Parameter 2
|p2= sound: [[String]] - plays a 2D sound as if [[playSound]] was used from CfgSounds (mission or main config). Use {{hl|"$NONE$"}} for an empty sound


|r2= [[Nothing]] |= Return value
|p3= voice: [[String]] - attaches a 3D sound from CfgSounds (mission or main config) to the object that activated the trigger and plays it as if [[say3D]] was used
____________________________________________________________________________________________
 
|x1= <code>_trigger [[setSoundEffect]] ["Alarm", "", "", ""];</code> |= Example 1
|x2= <code> [_group1,2] [[setSoundEffect]] ["Alarm", "", "", ""];</code> |= Example 2
|x3= <code>_trigger [[setSoundEffect]] ["$NONE$", "Alarm", "", ""];</code> |= Example 3
|x4= <code>_trigger [[setSoundEffect]] ["$NONE$", "", "BattlefieldFirefight1", ""];</code> |= Example 4
|x5= <code>_trigger [[setSoundEffect]] ["$NONE$", "", "", "Owl"];</code> |= Example 5


____________________________________________________________________________________________
|p4= soundEnv: [[String]] - plays an environmental sound from CfgEnvSounds (mission or main config)


| [[createTrigger]], [[setMusicEffect]] |= See also
|p5= soundDet: [[String]] - creates a dynamic sound object attached to a trigger defined in [[CfgSFX]] (mission or main config)


}}
|r1= [[Nothing]]
 
|s2= waypoint [[setSoundEffect]] [sound, voice]
 
|p21= waypoint: [[Array]] - format [[Waypoint]]
 
|p22= sound: [[String]] - plays a 2D sound as if [[playSound]] was used from CfgSounds (mission or main config)
 
|p23= voice: [[String]] - attaches a 3D sound from CfgSounds (mission or main config) to the object that activated the trigger and plays it as if [[say3D]] was used
 
|r2= [[Nothing]]
 
|x1= <sqf>_trigger setSoundEffect ["Alarm", "", "", ""];</sqf>


<h3 style="display:none">Notes</h3>
|x2= <sqf>[_group1, 2] setSoundEffect ["Alarm", ""];</sqf>
<dl class="command_description">
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on October 2, 2013
<dt class="note">'''[[User:Neokika|Neokika]]'''
<dd class="note">
To avoid having to create a dummy sound definition, you can use $NONE$ instead.


<code>private "_trigger";
|x3= <sqf>_trigger setSoundEffect ["$NONE$", "Alarm", "", ""];</sqf>
_trigger = createTrigger ["EmptyDetector", position player];
_trigger setTriggerStatements ["true", "", ""];
_trigger setSoundEffect ["$NONE$", "", "BattlefieldFirefight1", ""];
</code>
<!-- Note Section END -->
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on March 7, 2012
<dt class="note">'''[[User:old_man_auz|old_man_auz]]'''
<dd class="note">
When using this function, I found that if the parameter '''sound''' was empty, then you would always get a 'Sound not found' error. The following code fixes this problem. You need to create a dummy sound. This is what example 3 is hinting towards.


description.ext:
|x4= <sqf>_trigger setSoundEffect ["$NONE$", "", "BattlefieldExplosions3", ""];</sqf>
<code>class CfgSounds
{
sounds[] = {};
class NoSound
{
name = "NoSound";
sound[] = {"", 0, 1};
titles[] = {};
}; //Dummy sound needed for setSoundEffect command, due to stupid bug in engine.
};
</code>
(code sample above written by 'CarlGustaffa' on the Bohemia Interactive forums.)


script.sqf:
|x5= <sqf>_trigger setSoundEffect ["$NONE$", "", "", "Owl"];</sqf>
<code>_trigger = createTrigger[ "EmptyDetector" , _position ];
_trigger setTriggerStatements [ "true" , "" , "" ];
_trigger setSoundEffect[ "NoSound" , "" , "" , "Wind2_EP1" ];
</code>
<!-- Note Section END -->
</dl>


<h3 style="display:none">Bottom Section</h3>
|seealso= [[createTrigger]] [[setMusicEffect]] [[setTitleEffect]]
[[Category:Scripting Commands|SETSOUNDEFFECT]]
}}
[[Category:Scripting Commands OFP Elite |SETSOUNDEFFECT]]
[[Category:Scripting Commands ArmA|SETSOUNDEFFECT]]
[[Category:Scripting Commands ArmA2|SETSOUNDEFFECT]]
[[Category:Command_Group:_Sounds|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]

Latest revision as of 16:45, 8 November 2023

Hover & click on the images for description

Description

Description:
Defines the different sound effects for a trigger or a waypoint. To stop any sound, deactivate the trigger (might take up to 0.5 seconds to stop) or delete the trigger/waypoint (immediate).
Groups:
SoundsTriggersWaypoints

Syntax

Syntax:
trigger setSoundEffect [sound, voice, soundEnv, soundDet]
Parameters:
trigger: Object
sound: String - plays a 2D sound as if playSound was used from CfgSounds (mission or main config). Use "$NONE$" for an empty sound
voice: String - attaches a 3D sound from CfgSounds (mission or main config) to the object that activated the trigger and plays it as if say3D was used
soundEnv: String - plays an environmental sound from CfgEnvSounds (mission or main config)
soundDet: String - creates a dynamic sound object attached to a trigger defined in CfgSFX (mission or main config)
Return Value:
Nothing

Alternative Syntax

Syntax:
waypoint setSoundEffect [sound, voice]
Parameters:
waypoint: Array - format Waypoint
sound: String - plays a 2D sound as if playSound was used from CfgSounds (mission or main config)
voice: String - attaches a 3D sound from CfgSounds (mission or main config) to the object that activated the trigger and plays it as if say3D was used
Return Value:
Nothing

Examples

Example 1:
_trigger setSoundEffect ["Alarm", "", "", ""];
Example 2:
[_group1, 2] setSoundEffect ["Alarm", ""];
Example 3:
_trigger setSoundEffect ["$NONE$", "Alarm", "", ""];
Example 4:
_trigger setSoundEffect ["$NONE$", "", "BattlefieldExplosions3", ""];
Example 5:
_trigger setSoundEffect ["$NONE$", "", "", "Owl"];

Additional Information

See also:
createTrigger setMusicEffect setTitleEffect

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note