IsSoundPanningEnabled: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|4.0140|1.3.0|4162| This function gets the panning state from a sound element. }} ==Syntax== <syntaxhighlight lang="lua"> bool isSoundP...")
 
mNo edit summary
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
{{New feature/item|4.0140|1.3.0|4162|
{{New feature/item|3.0130|1.3.0|4162|
This function gets the panning state from a [[sound]] [[element]].
This function checks whether panning is enabled in a [[sound]] [[element]] or not.
}}
}}
{{Tip|Although this function works in no-3D sounds (those created by [[playSound]]), it only makes sense to use it with 3D sounds (created by [[playSound3D]]). Please refer to [[setSoundPanningEnabled]] for a explanation of what this property does.}}


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool isSoundPanningEnabled ( element theSound )
bool isSoundPanningEnabled ( element theSound )
</syntaxhighlight>
===Example Function===
<syntaxhighlight lang="lua">
function testCall()
local sound = playSound("xy.mp3")
local soundPanning = isSoundPanningEnabled(sound)
end
</syntaxhighlight>
</syntaxhighlight>
{{New feature/item|3.0141|1.4.0|6987|{{OOP||[[sound]]:isPanningEnabled|panningEnabled|setSoundPanningEnabled}}}}


===Required Arguments===  
===Required Arguments===  
*'''theSound :''' A valid sound element.
*'''theSound :''' A valid [[sound]] [[element]].


===Returns===
===Returns===
Returns ''true'' whether the sound swings, ''false'' if it does not.
Returns ''true'' if the sound is valid and it has panning enabled, ''false'' if it does not or is not valid.
 
==Example==
This example plays a ''xy.mp3'' file in the root folder of the resource which contains it at the center of the map, and proves that by default a sound enables panning by outputting the result of this function to the chatbox right after creating it. Then it disables the panning of the sound.
 
<syntaxhighlight lang="lua">
local function testPanning()
    -- Create the sound and output the panning property state
    local sound = playSound3D("xy.mp3", 0, 0, 0)
    outputChatBox("By default, the sound has its panning " .. (isSoundPanningEnabled(sound) and "enabled" or "disabled"))
    -- Disable the panning and ouput a fact
    setSoundPanningEnabled(sound, false)
    outputChatBox("The sound panning was disabled, so it won't annoy you when the camera it's in a side anymore!", 0, 255, 0)
end
addEventHandler("onClientResourceStart", resourceRoot, testPanning)
</syntaxhighlight>


==Requirements==
==Requirements==
Line 29: Line 38:
==See Also==
==See Also==
{{Client_audio_functions}}
{{Client_audio_functions}}
[[Category:Needs Example]]
 
[[hu:isSoundPanningEnabled]]
[[ar:isSoundPanningEnabled]]
[[pt-br:isSoundPanningEnabled]]

Latest revision as of 00:24, 18 August 2021

This function checks whether panning is enabled in a sound element or not.

[[{{{image}}}|link=|]] Tip: Although this function works in no-3D sounds (those created by playSound), it only makes sense to use it with 3D sounds (created by playSound3D). Please refer to setSoundPanningEnabled for a explanation of what this property does.

Syntax

bool isSoundPanningEnabled ( element theSound )

OOP Syntax Help! I don't understand this!

Method: sound:isPanningEnabled(...)
Variable: .panningEnabled
Counterpart: setSoundPanningEnabled

Required Arguments

Returns

Returns true if the sound is valid and it has panning enabled, false if it does not or is not valid.

Example

This example plays a xy.mp3 file in the root folder of the resource which contains it at the center of the map, and proves that by default a sound enables panning by outputting the result of this function to the chatbox right after creating it. Then it disables the panning of the sound.

local function testPanning()
    -- Create the sound and output the panning property state
    local sound = playSound3D("xy.mp3", 0, 0, 0)
    outputChatBox("By default, the sound has its panning " .. (isSoundPanningEnabled(sound) and "enabled" or "disabled"))
    -- Disable the panning and ouput a fact
    setSoundPanningEnabled(sound, false)
    outputChatBox("The sound panning was disabled, so it won't annoy you when the camera it's in a side anymore!", 0, 255, 0)
end
addEventHandler("onClientResourceStart", resourceRoot, testPanning)

Requirements

Minimum server version n/a
Minimum client version 1.3.0-9.04162

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.3.0-9.04162" />

See Also