setSoundEffect: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<!-- Note Section [A-Z]+ --> " to "")
m (formatting)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


|arma1
|game1= arma1


|1.00
|version1= 1.00
 
|game2= arma2
 
|version2= 1.00
 
|game3= arma2oa
 
|version3= 1.51
 
|game4= tkoh
 
|version4= 1.00
 
|game5= arma3
 
|version5= 0.50


|gr1= Sounds
|gr1= Sounds
Line 11: Line 27:
|gr3= Waypoints
|gr3= Waypoints


| Defines the different sound effects.  
|descr= Defines the different sound effects. To stop any sound, deactivate the trigger (might take up to 0.5 seconds to stop) or delete the trigger (immediate).


* Sound - plays a 2D sound as if [[playSound]] was used from CfgSounds (mission or main config)
|s1= trigger '''setSoundEffect''' [sound, voice, soundEnv, soundDet]
* Voice - 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 - [Triggers only] plays an environmental sound from CfgEnvSounds (mission or main config)
* SoundDet - [Triggers only] creates a dynamic sound object attached to a trigger defined in [[CfgSFX]] (mission or main config)


To stop any sound, deactivate the trigger (might take up to 0.5 sec to stop) or delete the trigger (immediate). <br><br>
|p1= trigger: [[Object]]


Also use <tt>"$NONE$"</tt> to skip the sound (1st item), when there is none to be used (Example 3, 4, 5).
|p2= sound: [[String]] - Plays a 2D sound as if [[playSound]] was used from CfgSounds (mission or main config)
{{Wiki|todo | Remove the note above in Arma3 v2.04, and remove this from examples as simple "" will work then instead ("$NONE$" still supported) }}


| trigger '''setSoundEffect''' [sound, voice, soundEnv, soundDet]
|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


|p1= trigger: [[Object]]
|p4= soundEnv: [[String]] - Plays an environmental sound from CfgEnvSounds (mission or main config)


|p2= [sound, voice, soundEnv, soundDet]: [[Array]] of strings, see description
|p5= soundDet: [[String]] - Creates a dynamic sound object attached to a trigger defined in [[CfgSFX]] (mission or main config)


| [[Nothing]]
|r1= [[Nothing]]


|s2= waypoint '''setSoundEffect''' [sound, voice]
|s2= waypoint '''setSoundEffect''' [sound, voice]
Line 35: Line 47:
|p21= waypoint: [[Array]] - format [[Waypoint]]
|p21= waypoint: [[Array]] - format [[Waypoint]]


|p22= [sound, voice]: [[Array]] of strings, see description
|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]]
|r2= [[Nothing]]
   
   
|x1= <code>_trigger [[setSoundEffect]] ["Alarm", "", "", ""];</code>
|x1= <code>_trigger [[setSoundEffect]] ["Alarm", "", "", ""];</code>
|x2= <code> [_group1,2] [[setSoundEffect]] ["Alarm", ""];</code>
 
|x3= <code>_trigger [[setSoundEffect]] ["$NONE$", "Alarm", "", ""];</code>
|x2= <code>[_group1,2] [[setSoundEffect]] ["Alarm", ""];</code>
|x4= <code>_trigger [[setSoundEffect]] ["$NONE$", "", "BattlefieldExplosions3", ""];</code>
 
|x5= <code>_trigger [[setSoundEffect]] ["$NONE$", "", "", "Owl"];</code>
|x3= <code>_trigger [[setSoundEffect]] ["", "Alarm", "", ""];</code>
 
|x4= <code>_trigger [[setSoundEffect]] ["", "", "BattlefieldExplosions3", ""];</code>
 
|x5= <code>_trigger [[setSoundEffect]] ["", "", "", "Owl"];</code>


|seealso= [[createTrigger]], [[setMusicEffect]], [[setTitleEffect]]
|seealso= [[createTrigger]], [[setMusicEffect]], [[setTitleEffect]]
Line 54: Line 72:
To avoid having to create a dummy sound definition, you can use $NONE$ instead.
To avoid having to create a dummy sound definition, you can use $NONE$ instead.


<code>private "_trigger";
<code>[[private]] "_trigger";
_trigger = createTrigger ["EmptyDetector", position player];
_trigger = [[createTrigger]] ["EmptyDetector", position player];
_trigger setTriggerStatements ["true", "", ""];
_trigger [[setTriggerStatements]] ["true", "", ""];
_trigger setSoundEffect ["$NONE$", "", "BattlefieldExplosions3", ""];
_trigger [[setSoundEffect]] ["$NONE$", "", "BattlefieldExplosions3", ""];
</code>
</code>
<dd class="notedate">Posted on March 7, 2012</dd>
<dd class="notedate">Posted on March 7, 2012</dd>
Line 73: Line 91:
sound[] = {"", 0, 1};
sound[] = {"", 0, 1};
titles[] = {};
titles[] = {};
}; //Dummy sound needed for setSoundEffect command, due to stupid bug in engine.
}; {{cc|Dummy sound needed for [[setSoundEffect]] command, due to bug in engine.}}
};
};</code>
</code>
(code sample above written by 'CarlGustaffa' on the Bohemia Interactive forums.)<br/>
(code sample above written by 'CarlGustaffa' on the Bohemia Interactive forums.)


script.sqf:
script.sqf:
<code>_trigger = createTrigger[ "EmptyDetector" , _position ];
<code>_trigger = [[createTrigger]] [ "EmptyDetector" , _position ];
_trigger setTriggerStatements [ "true" , "" , "" ];
_trigger [[setTriggerStatements]] [ "true" , "" , "" ];
_trigger setSoundEffect[ "NoSound" , "" , "" , "Wind2_EP1" ];
_trigger [[setSoundEffect]] [ "NoSound" , "" , "" , "Wind2_EP1" ];</code>
</code>
</dl>
</dl>
{{GameCategory|ofpe|Scripting Commands}}
{{GameCategory|arma1|Scripting Commands}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}

Revision as of 18:22, 24 May 2021

Hover & click on the images for description

Description

Description:
Defines the different sound effects. To stop any sound, deactivate the trigger (might take up to 0.5 seconds to stop) or delete the trigger (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)
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 ["", "Alarm", "", ""];
Example 4:
_trigger setSoundEffect ["", "", "BattlefieldExplosions3", ""];
Example 5:
_trigger setSoundEffect ["", "", "", "Owl"];

Additional Information

See also:
createTriggersetMusicEffectsetTitleEffect

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
Posted on October 2, 2013
Neokika
To avoid having to create a dummy sound definition, you can use $NONE$ instead. private "_trigger"; _trigger = createTrigger ["EmptyDetector", position player]; _trigger setTriggerStatements ["true", "", ""]; _trigger setSoundEffect ["$NONE$", "", "BattlefieldExplosions3", ""];
Posted on March 7, 2012
old_man_auz
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: class CfgSounds { sounds[] = {}; class NoSound { name = "NoSound"; sound[] = {"", 0, 1}; titles[] = {}; }; // Dummy sound needed for setSoundEffect command, due to bug in engine. }; (code sample above written by 'CarlGustaffa' on the Bohemia Interactive forums.)
script.sqf: _trigger = createTrigger [ "EmptyDetector" , _position ]; _trigger setTriggerStatements [ "true" , "" , "" ]; _trigger setSoundEffect [ "NoSound" , "" , "" , "Wind2_EP1" ];