playSFX3D | Multi Theft Auto: Wiki Skip to content

playSFX3D

Client-side
Server-side
Shared

This function plays a sound in the GTA world from GTA's big sound containers.

Tip

There is a tool available which allows you to find bank and sound IDs easily sfxBrowser.

Note

PlaySFX sounds are MTA driven sounds, so MTA volume affects the volume.

Caution

Many players use versions of GTA:SA (especially pirated versions) that have audio files full of zeros so that they can compress better in their AUDIO\SFX\ folder. (They lack any data).

In case of these invalid audio files, this function returns false. It also returns false when trying to play a track deleted in the recent GTA: SA Steam patches (and if the client is using a Steam GTA: SA copy).

Syntax

sound playSFX3D ( string containerName, int/string bankId/radioStation, int soundId/trackId, float x, float y, float z, [ bool looped = false ] )
Required Arguments
  • containerName: The name of the audio container. Possible values are "feet", "genrl", "pain_a", "script", "spc_ea", "spc_fa", "spc_ga", spc_na", "spc_pa", "radio".
  • bankId/radioStation: The audio bank id. If containerName is "radio", then this argument is of type string and specifies the radio station name. Possible values "Adverts", "Ambience", "Police", "Playback FM", "K-Rose", "K-DST", "Cutscene", "Beats", "Bounce FM", "SF-UR", "Radio Los Santos", "Radio X", "CSR 103.9", "K-Jah West", "Master Sounds 98.3", "WCTR".
  • soundId/trackId: The sound id within the audio bank. If containerName is "radio", then this argument specifies the radio track id within the radio station audio file.
  • x: A floating point number representing the X coordinate on the map.
  • y: A floating point number representing the Y coordinate on the map.
  • z: A floating point number representing the Z coordinate on the map.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • looped (default: false): A boolean representing whether the sound will be looped.

Returns

  • sound: sound-element

Returns a sound element if the sound was successfully created, false otherwise.

Code Examples

client

The following example plays a fire alarm sound near you (looped).

local x, y, z = getElementPosition(localPlayer)
if not playSFX3D("script", 7, 1, x + 10, y, z, true) then
outputChatBox("You have to install some missing audio files to hear the sound")
end