ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. playSFX

Function

playSFX

ClientSound (client)Identical to MTA:SA

Plays a sound from San Andreas' own sound banks (footsteps, weapons, collisions, vehicles, mission sounds) with no position in the world. The game's sound engine plays it, so it follows the game's effects volume.

Syntax

sound playSFX(string audioContainer, int bankIndex, int soundIndex [, bool looped = false])

Arguments

audioContainerstring
The container: "feet", "genrl", "pain_a", "script", "spc_ea", "spc_fa", "spc_ga", "spc_na", "spc_pa".
bankIndexint
The bank number in the container (from 0).
soundIndexint
The sound number in the bank (from 0).
loopedbool, optional = false
Whether to loop.

Returns

A sound element or false (the reason is written to the debug log).

Example

-- strzal z M4 (bank 136 pojemnika genrl to bron)
if isSFXBankLoaded("genrl", 136) then
    playSFX("genrl", 136, 33)
end

Notes

Only a bank the game has loaded right now will play. The game keeps a few dozen banks in memory at once. The genrl banks with weapons, collisions and footsteps are usually loaded, while script and spc_* banks are loaded only during missions. Check with isSFXBankLoaded. The "radio" container is not supported.

It works only for this player and does not go to other players. Compatible with MTA, but bank numbers are from the Definitive Edition.

See also