GetSoundSpeed

From Multi Theft Auto: Wiki
Revision as of 16:00, 21 December 2021 by Srslyyyy (talk | contribs) (Improve example.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function is used to return the playback speed of the specified sound element.

Syntax

float getSoundSpeed ( element theSound )

OOP Syntax Help! I don't understand this!

Method: sound:getSpeed(...)
Variable: .speed
Counterpart: setSoundSpeed


Required Arguments

  • theSound: the sound element which playback speed you want to return.

Returns

Returns an float value indicating the playback speed of the sound element. Default sound playback speed is 1.0.

Example

Click to collapse [-]
Client
function outputSpeed(soundName) 
    if soundName then
        local soundElement = playSound("sounds/"..soundName..".mp3") -- Play the sound from the sounds folder

        setSoundSpeed(soundElement, 0.5) -- Set the sound speed to 50%

        local soundSpeed = getSoundSpeed(soundElement) -- Get current sound speed

        outputChatBox("Sound speed: "..soundSpeed) -- Output the sound speed
    end
end
addCommandHandler("soundspeed", outputSpeed)

See Also