PlaySound(string)

From NWN Lexicon
Jump to: navigation, search

Plays a sound on the client machine.

void PlaySound(
    string sSoundName
);

Parameters

sSoundName
The name of the sound to play.


Description

Play the wav sound resource named sSoundName.


Remarks

PlaySound() returns immediately. it does not wait for the sound to finish playing. If you want to play a sound using a trigger, then look at the SoundObjectPlay() function, as PlaySound() requires an object to work.

This function can play only mono sounds (ie not ambient music or the like).

Triggers cannot play sounds.

A quick thing; creating an object (eg a placeable) and using ExecuteScript to PlaySound on it, doesn't work unless the command is delayed eg; DelayCommand(0.0, PlaySound("sound")); - this is why AssignCommand on the created object doesn't work well either, apart from the fact placeables and AssignCommand have an arduous history at best.


Known Bugs

This might not be an actual bug, but though PlaySound() isn't an action (you don't get the little yellow square on the screen), if you assign a PlaySound() to someone, it will wait for their current action queue to finish before playing. This may be fixed by DelayCommand - see above for details - but needs testing.


Version

1.61


Example

// Placed in the OnUsed event of the an object, for example a gong. The following script will cause a gong ring to sound.
 
void main()
{
    PlaySound("as_cv_gongring2");
}


See Also

functions:  SoundObjectPlay

 author: Tom Cassiotis, editor: Lilac Soul, additional contributor(s): Lilac Soul