Page tree
Skip to end of metadata
Go to start of metadata


Introduced in

Version:1.00

Description

Description:Creates a sound source of the given type. To stop the sound, delete the created sound object, using deleteVehicle.

Syntax

Syntax:createSoundSource [type, position, markers, radius]
Parameters:
  • type: String or Config-2 - Either the sound name, as listed in CfgVehicles (see Vehicle Configuration in the VBS Developer Reference), or, in V3.6+, the configuration path of the sound.
  • position: Position-2 - Placement position.
  • markers: Array - If the markers array contains several marker names, then one of them is randomly chosen. The sound source is placed inside a circle with this position as its center, and placement as its radius. If the array is empty, the the defined position is used.
  • radius : Number - The sound is generated in this radius around the specified position.
Return Value:Object - Created sound object.

Examples

Examples:
_snd = createSoundSource ["LittleDog", player modelToWorld [0,10,0], [], 0]
_snd = createSoundSource [configFile>>"cfgvehicles">>"LittleDog", player modelToWorld [0,10,0], [], 0];

Additional Information

See also: setSoundSourceAmbient, setSoundSourceAmplitude, setSoundSourceDistance, playSound, say, playMusic, CfgSFX (see Class CfgSFX in the VBS Developer Reference)
Multiplayer:
Problems:

Notes







Posted on Feb 23, 2012
Kronzky


If a sound doesn't exist in CfgVehicles (which is a requirement for use as a sound source), but is defined in CfgSFX, then the needed sound can be added to CfgVehicles during runtime, via the following code:
// name of existing CfgSFX class that is used
_sound = "AlarmBellSfx"; 
// name of new class that's created
_newClass = format["SFX_%1",_sound]; 

// add the new class (inherited from base class "Sound")
_newSound = (configFile>>"CfgVehicles") addClass [_newClass,"Sound"]; 

// define the sound source
_newSound addValue ["sound", _sound];