- Documentation
- Client functions
- playSFX3D
Function
playSFX3D
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).
stopSound, setSoundVolume, setSoundSpeed, setElementPosition, attachElements and onClientSoundStopped work. Effects (setSoundEffectEnabled) and seeking work only on files from playSound.
See also
playSFXPlays a sound from San Andreas' own sound banks (footsteps, weapons, collisions, vehicles, mission sounds) with no position in the world. The game's sound engine plays it, so it follows the game's effects volume.isSFXBankLoadedChecks whether the game has a sound bank loaded right now. Only such a bank plays throughplaySFXandplaySFX3D.setElementPositionMoves an element to the given place. On the server it works for any element. On the client it moves your own character (up to 50 m it is a plain move in the same frame andgetElementPositionreturns the new place right away, so it can be called every frame, e.g. for noclip; farther it is a teleport that loads the area), as well as client objects, sounds and collision shapes. An object moved every frame inonClientPreRenderis drawn in its new place in the same frame.attachElementsAttaches an element to another. The attached element moves and rotates together with the one it is attached to. An object attached to a vehicle is carried by the game in the same frame as the vehicle physics, so it stays exactly in place even at high speed and in turns.