SetSoundPanningEnabled: Difference between revisions
Jump to navigation
Jump to search
m (Added "see also") |
No edit summary |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
{{Client function}} | {{Client function}} | ||
This function toggles the panning of a sound (hearing it closer to the left or right side of the speakers due to the camera position). By default a sound has its panning enabled. | This function toggles the panning of a sound (hearing it closer to the left or right side of the speakers due to the camera position). By default a sound has its panning enabled. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool setSoundPanningEnabled ( element sound, bool enable )</syntaxhighlight> | <syntaxhighlight lang="lua">bool setSoundPanningEnabled ( element sound, bool enable )</syntaxhighlight> | ||
{{New feature/item|3.0141|1.4.0|6987|{{OOP|The method name was incorrect (setPann'''n'''ingEnabled) before version '''1.5.8 r20761'''.|[[sound]]:setPanningEnabled|panningEnabled|isSoundPanningEnabled}}}} | |||
===Required arguments=== | ===Required arguments=== | ||
Line 11: | Line 11: | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the sound is valid | Returns ''true'' if the sound is valid and good arguments were passed, ''false'' if not. | ||
If the sound is not 3D, this function will return ''true'' as well, but [[isSoundPanningEnabled]] will always return ''true'' after this (so it has no effect). | |||
==Example== | ==Example== | ||
This example creates a sound at the center of the map when the resource which cointains it starts and adds a command called /soundpanning, which changes the panning of the sound. | This example creates a sound at the center of the map when the resource which cointains it starts and adds a command called /soundpanning, which changes the panning of the sound. | ||
<syntaxhighlight lang="lua">local panned | <syntaxhighlight lang="lua">local panned = true | ||
local sound = playSFX3D("script", 7, 1, 0, 0, 20, true) | local sound = playSFX3D("script", 7, 1, 0, 0, 20, true) | ||
Line 29: | Line 31: | ||
end | end | ||
addCommandHandler("soundpanning", changePanning)</syntaxhighlight> | addCommandHandler("soundpanning", changePanning)</syntaxhighlight> | ||
==See also== | ==See also== | ||
{{Client_audio_functions}} | {{Client_audio_functions}} | ||
[[hu:setSoundPanningEnabled]] |
Latest revision as of 21:15, 23 September 2021
This function toggles the panning of a sound (hearing it closer to the left or right side of the speakers due to the camera position). By default a sound has its panning enabled.
Syntax
bool setSoundPanningEnabled ( element sound, bool enable )
OOP Syntax Help! I don't understand this!
- Note: The method name was incorrect (setPannningEnabled) before version 1.5.8 r20761.
- Method: sound:setPanningEnabled(...)
- Variable: .panningEnabled
- Counterpart: isSoundPanningEnabled
Required arguments
- sound: a sound element to change the panning of.
- enable: true to enable the panning, false otherwise.
Returns
Returns true if the sound is valid and good arguments were passed, false if not.
If the sound is not 3D, this function will return true as well, but isSoundPanningEnabled will always return true after this (so it has no effect).
Example
This example creates a sound at the center of the map when the resource which cointains it starts and adds a command called /soundpanning, which changes the panning of the sound.
local panned = true local sound = playSFX3D("script", 7, 1, 0, 0, 20, true) function changePanning() if sound then setSoundPanningEnabled(sound, not panned) panned = not panned outputChatBox("Sound panning changed to " .. tostring(panned)) else outputDebugString("Looks that your GTA was ripped.") end end addCommandHandler("soundpanning", changePanning)
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