setSoundEffect: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Replaced <code> with <sqf>)
(Fix examples)
Line 22: Line 22:
|gr3= Waypoints
|gr3= Waypoints


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


|s1= trigger [[setSoundEffect]] [sound, voice, soundEnv, soundDet]
|s1= trigger [[setSoundEffect]] [sound, voice, soundEnv, soundDet]
Line 28: Line 28:
|p1= trigger: [[Object]]
|p1= trigger: [[Object]]


|p2= sound: [[String]] - Plays a 2D sound as if [[playSound]] was used from CfgSounds (mission or main config)
|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


|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
|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
Line 50: Line 50:
|x1= <sqf>_trigger setSoundEffect ["Alarm", "", "", ""];</sqf>
|x1= <sqf>_trigger setSoundEffect ["Alarm", "", "", ""];</sqf>


|x2= <sqf>[_group1,2] setSoundEffect ["Alarm", ""];</sqf>
|x2= <sqf>[_group1, 2] setSoundEffect ["Alarm", ""];</sqf>


|x3= <sqf>_trigger setSoundEffect ["", "Alarm", "", ""];</sqf>
|x3= <sqf>_trigger setSoundEffect ["$NONE$", "Alarm", "", ""];</sqf>


|x4= <sqf>_trigger setSoundEffect ["", "", "BattlefieldExplosions3", ""];</sqf>
|x4= <sqf>_trigger setSoundEffect ["$NONE$", "", "BattlefieldExplosions3", ""];</sqf>


|x5= <sqf>_trigger setSoundEffect ["", "", "", "Owl"];</sqf>
|x5= <sqf>_trigger setSoundEffect ["$NONE$", "", "", "Owl"];</sqf>


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

Revision as of 15:55, 11 January 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