ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. playSFX3D

Function

playSFX3D

ClientSound (client)Identical to MTA:SA

Plays a sound from the game's banks at a point in the world. The game's sound engine handles fading with distance and panning.

Syntax

sound playSFX3D(string audioContainer, int bankIndex, int soundIndex, float x, float y, float z [, bool looped = false])

Arguments

audioContainerstring
The container, as in playSFX.
bankIndexint
The bank number in the container.
soundIndexint
The sound number in the bank.
xfloat
X position.
yfloat
Y position.
zfloat
Z position.
loopedbool, optional = false
Whether to loop.

Returns

A sound element or false.

Example

local x, y, z = getElementPosition(localPlayer)
local sound = playSFX3D("genrl", 32, 1, x + 5, y, z)
if sound then setSoundVolume(sound, 0.6) end

Notes

Only a bank loaded in the game right now will play (isSFXBankLoaded).

See also