SetSoundPanningEnabled: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Added "see also")
Line 16: Line 16:
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 29:
end
end
addCommandHandler("soundpanning", changePanning)</syntaxhighlight>
addCommandHandler("soundpanning", changePanning)</syntaxhighlight>
==See also==
==See also==
{{Client_audio_functions}}
{{Client_audio_functions}}

Revision as of 10:26, 25 May 2014

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 )

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, is 3D and good arguments were passed, false if not.

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