PlaySFX: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{client_function}} This function plays a sound from GTA's big sound containers. ==Syntax== <syntaxhighlight lang="lua"> sound playSFX ( string containerName, int bankId, int soundId [, looped...")
 
No edit summary
Line 1: Line 1:
{{client_function}}
{{client_function}}
{{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}}
{{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}}
}}


==Syntax==
==Syntax==
Line 19: Line 25:


==Example==
==Example==
The following example plays a firealarm sound (looped).
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Todo
if not playSFX("script", 7, 1, true) then
    outputChatBox("You have to install some missing audio files to hear the sound")
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Client_audio_functions}}
{{Client_audio_functions}}

Revision as of 18:19, 21 August 2013

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


[[{{{image}}}|link=|]] Note: {{{1}}}
Dialog-warning.png 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

Syntax

sound playSFX ( string containerName, int bankId, int soundId [, 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.

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