PlaySFX: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
(18 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{client_function}}
__NOTOC__
{{Client function}}
{{New feature/item|3.0134|1.3.4|5731|
{{New feature/item|3.0134|1.3.4|5731|
This function plays a sound from GTA's big sound containers.
This function plays a sound from GTA's big sound containers.
}}


{{Note|There is a tool available which allows you to find bank and sound IDs: https://community.mtasa.com/index.php?p=resources&s=details&id=7549}}
{{Note|There is a tool available which allows you to find bank and sound IDs easily: [[https://community.mtasa.com/index.php?p=resources&s=details&id=7549 sfxBrowser:Download]].}}
{{Warning|Many players use versions of GTA:SA (especially WareZ versions) which haven't any audio files in their ''AUDIO\SFX\'' folder. In case of missing audio files, this function returns ''false''|true}}
{{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''.


}}
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).|true}}


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
sound playSFX ( string containerName, int bankId, int soundId [, looped = false] )
element playSFX ( string containerName, int bankId, int soundId [, bool looped = false ] )
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===
===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"
*'''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
*'''bankId:''' The audio bank id
*'''soundId:''' The sound Id within the audio bank
*'''soundId:''' The sound id within the audio bank


===Optional Arguments===
===Optional Arguments===
*'''looped:''' A [[boolean]] representing whether the sound will be looped
*'''looped:''' A [[boolean]] representing whether the sound will be looped
==Returns==
Returns a [[sound]] element if the sound was successfully created, ''false'' otherwise.


{{New feature/item|3.0140|1.4|6443|
==Syntax 2==
<syntaxhighlight lang="lua">
element playSFX ( string "radio", string radioStation, int trackId [, bool looped = false ] )
</syntaxhighlight>
===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", "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".
*'''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==
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==
Line 34: Line 53:
==See Also==
==See Also==
{{Client_audio_functions}}
{{Client_audio_functions}}
[[hu:playSFX]]

Revision as of 20:34, 19 July 2018

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.

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

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.

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", "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".
  • 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