PlaySFX: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(r6443 Update)
m (Formatting)
Line 41: Line 41:
Returns a [[sound]] element if the sound was successfully created, ''false'' otherwise.
Returns a [[sound]] element if the sound was successfully created, ''false'' otherwise.
}}
}}


==Example==
==Example==

Revision as of 11:02, 23 May 2014

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


[[{{{image}}}|link=|]] Note: There is a tool available which allows you to find bank and sound IDs easily: [sfxBrowser:Download]
Dialog-warning.png Warning: Many players use versions of GTA:SA (especially pirated versions) that have audio files full of zeros so that they can compresses better in their AUDIO\SFX\ folder. (They lack any data)

In case of these invalid audio files, this function returns false

Syntax

element playSFX ( string containerName, int bankId, int soundId [, 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"
  • bankId: The audio bank id
  • soundId: The sound id within the audio bank

Optional Arguments

  • looped: A boolean representing whether the sound will be looped

Returns

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


ADDED/UPDATED IN VERSION 1.4 r6443:

Syntax 2

element playSFX ( string "radio", string radioStation, int trackId [, bool looped = false ] )

Required Arguments

  • radio: The string "radio" (used to differentiate to the first syntax)
  • radioStation: The radio station. Possible values are "Adverts", "Ambience", "Police", "Playback FM", "KROSE", "K-DST", "Cutscene", "Beats", "Bounce FM", "SFUR", "Radio Los Santos", "Radio X", "CSR", "K-JAH", "Master Sounds", "WCTR".
  • trackId : The radio track id within the radio station audio file

Optional Arguments

  • looped: A boolean representing whether the sound will be looped

Returns

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


Example

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