Sound

Category: Effects
Since engine version: 4.6.5.0 CP (extended in 4.9.5.0 CE)

Description

Plays a sound. The specified sound file has to be available in the group Sound.c4g, in the active scenario file, or in any loaded object definition. The audibility of object local sounds will depend on the position of the object relative to the visible viewports.

Syntax

bool Sound (string szSound, bool fGlobal, object pObj, int iVolume, int iPlayer, int iLoopCount, bool fMultiple, int iCustomFalloffDistance);

Parameters

szSound:
Name of the sound effect (without .wav ending)
fGlobal:
[opt] Specifies wether the sound is played globally, i.e. independently of the object position always with the same loudness.
pObj:
[opt] Object which is to play back the specified sound. Can be 0 in local calls. The object's visible position relative to a player's viewport is responsible for audible volume.
iVolume:
[opt] 0-100: volume for playback of the sound. A volume value of 0 means playback at full volume (default).
iPlayer:
[opt] Player number of the player for which the sound is to be played, increased by 1. In network games, the sound will thus no be audible for the other players. Notice: the player number to be specified has to be increased by 1 since the number 0 is already used for the default (audible for all players)!
iLoopCount:
[opt] Increases or decreases the number of sounds running in a continuous loop. Value +1 will play this sound indefinitely until it is stopped by calling this function again with value -1. Value 0 will play the sound once normally.
fMultiple:
If true, the same sound may be played multiple times at the same time.
iCustomFalloffDistance:
Determines how fast the volume decreases depending on the distance.

Example

Sound("Applause", 0, FindObject(HUT2), 50);
Plays an 'applause' sound next to the first found wooden hut at half volume.
See also: Music, SoundLevel
Sven2, August 2002