Scripting/Server/Functions/PlaySFX

(v0.5-rc2+) Plays one of the stock game sounds of audio/SFX.SDT for every player - or, with player.PlaySFX(...) (same arguments), for one player. soundID is the index of the sample in SFX.SDT counted from 0 (the number in LU/sfx/sfxNNNNN.wav, see CUSTOM_SFX.md; a replacement file of the server is played when there is one). volume is 0..127 (127 = full; the player's own sound effects volume still applies). Without a position the sound is heard in the player's ears; with pos (a Vector, or x, y, z) it is positional: it comes from that point of the world (left / right follows the camera) and fades out over distance metres (default 50). Returns true when the packet was sent. PC and Android.

Syntax

PlaySFX(soundID [, volume = 127 [, Vector pos | x, y, z, distance]])

Arguments

Returns

true / false

Example

function onPlayerCommand( player, cmd, params )
{
	if ( cmd == "bang" )
	{
		// the pistol shot of the stock game (SFX.SDT sample 67), heard by everybody within 80 m of the player
		PlaySFX( 67, 127, player.Pos, 80.0 );
	}
	else if ( cmd == "ding" )
		player.PlaySFX( 67, 80 );          // only this player, in his ears
}

Notes

Example: PlaySFX( 67, 100, Vector( 1000.0, -870.0, 15.0 ), 80.0 ); / player.PlaySFX( 67 );

Section: Audio streams, object editor and object picker (v0.3)

Categories: Server functions | Audio streams, object editor and object picker (v0.3)