playSFX
This function plays a sound from GTA's big sound containers.
There is a tool available which allows you to find bank and sound IDs easily sfxBrowser.
PlaySFX sounds are MTA driven sounds, so MTA volume affects the volume.
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 playSFX ( string containerName, int/string bankId/radioStation, int soundId/trackId, [ 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.
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
The following example plays a firealarm sound (looped).
if not playSFX("script", 7, 1, true) then outputChatBox("You have to install some missing audio files to hear the sound")end
See Also
Audio Functions
- getRadioChannelName
- getRadioChannel
- getSoundBPM
- getSFXStatus
- getSoundBufferLength
- getSoundEffectParameters
- getSoundEffects
- getSoundFFTData
- getSoundLevelData
- getSoundLength
- getSoundMetaTags
- getSoundMaxDistance
- getSoundMinDistance
- getSoundPan
- getSoundPosition
- getSoundProperties
- getSoundSpeed
- getSoundVolume
- getSoundWaveData
- isSoundLooped
- isSoundPanningEnabled
- isSoundPaused
- playSFX
- playSFX3D
- playSound
- playSound3D
- setRadioChannel
- setSoundEffectEnabled
- setSoundEffectParameter
- setSoundMaxDistance
- setSoundLooped
- setSoundMinDistance
- setSoundPan
- setSoundPanningEnabled
- setSoundPaused
- setSoundPosition
- setSoundProperties
- setSoundSpeed
- setSoundVolume
- stopSound