PlaySFX: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m (→Example: Added another example, showcasing the "radio" syntax.) |
||
Line 50: | Line 50: | ||
outputChatBox("You have to install some missing audio files to hear the sound") | outputChatBox("You have to install some missing audio files to hear the sound") | ||
end | end | ||
</syntaxhighlight> | |||
This example spawns Big Smoke in his Crack Palace and plays one of his screams followed by the mission accomplished sound when he's killed. | |||
<syntaxhighlight lang="lua"> | |||
local bigsmoke = createPed(311,2550.53, -1284.81, 1060.98, 270) | |||
setElementInterior(bigsmoke, 2) | |||
function smokeDied() | |||
playSFX("spc_na", 32, 34) | |||
setTimer(playSFX, 1000, 1, "radio", "Beats", 9) | |||
end | |||
addEventHandler("onClientPedWasted", bigsmoke, smokeDied) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 06:05, 11 March 2023
This function plays a sound from GTA's big sound containers.
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
This example spawns Big Smoke in his Crack Palace and plays one of his screams followed by the mission accomplished sound when he's killed.
local bigsmoke = createPed(311,2550.53, -1284.81, 1060.98, 270) setElementInterior(bigsmoke, 2) function smokeDied() playSFX("spc_na", 32, 34) setTimer(playSFX, 1000, 1, "radio", "Beats", 9) end addEventHandler("onClientPedWasted", bigsmoke, smokeDied)
See Also
- getRadioChannel
- getRadioChannelName
- getSFXStatus
- getSoundBPM
- getSoundBufferLength
- getSoundEffectParameters
- getSoundEffects
- getSoundFFTData
- getSoundLength
- getSoundLevelData
- getSoundMaxDistance
- getSoundMetaTags
- getSoundMinDistance
- getSoundPan
- getSoundPosition
- getSoundProperties
- getSoundSpeed
- getSoundVolume
- getSoundWaveData
- isSoundLooped
- isSoundPanningEnabled
- isSoundPaused
- playSFX3D
- playSFX
- playSound3D
- playSound
- setRadioChannel
- setSoundEffectEnabled
- setSoundEffectParameter
- setSoundLooped
- setSoundMaxDistance
- setSoundMinDistance
- setSoundPan
- setSoundPanningEnabled
- setSoundPaused
- setSoundPosition
- setSoundProperties
- setSoundSpeed
- setSoundVolume
- stopSound
- Shared
- playSoundFrontEnd