SetSoundSpeed: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(OOP)
Line 15: Line 15:
==Example==  
==Example==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function soundFunc()
function soundSpeed ( Scrolled )
sound = playSound ( "/sounds/jizzy.mp3",true) -- Let's play a sound
   if ( source == element ) then  
setSoundSpeed ( sound, 1.2 ) -- And it will be a little bit faster !
    if ( isElement ( Sound ) ) then
        local ScrollPosition_ = ( guiScrollBarGetScrollPosition ( Scrolled ) / 2 ) / 30
        setSoundSpeed ( Sound, ScrollPosition_ )
    end  
  end
end
end
addCommandHandler("play",soundFunc)
addEventHandler( "onClientGUIScroll", resourceRoot, soundSpeed )
</syntaxhighlight>
</syntaxhighlight>



Revision as of 13:19, 17 February 2015

This function can be used to change the playback speed of the specified sound element.

Syntax

bool setSoundSpeed ( element theSound, float speed )

OOP Syntax Help! I don't understand this!

Method: sound:setSpeed(...)
Variable: .speed
Counterpart: getSoundSpeed


Required Arguments

  • theSound: the sound element which volume you want to modify.
  • speed: a floating point number representing the desired sound playback speed.

Returns

Returns true if the sound element playback speed was successfully changed, false otherwise.

Example

function soundSpeed ( Scrolled )
   if ( source == element ) then  
    if ( isElement ( Sound ) ) then
        local ScrollPosition_ = ( guiScrollBarGetScrollPosition ( Scrolled ) / 2 ) / 30
        setSoundSpeed ( Sound, ScrollPosition_ )
    end  
  end
end
addEventHandler( "onClientGUIScroll", resourceRoot, soundSpeed )

See Also

Shared