From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function is used to either pause or unpause the playback of the specified sound element.

Use a player element to control a players voice with this function.


bool setSoundPaused ( element theSound, bool paused )

OOP Syntax Help! I don't understand this!

Method: sound:setPaused(...)
Variable: .paused
Counterpart: isSoundPaused

Required Arguments

  • theSound: the sound element which you want to pause/unpause.
  • paused: a boolean value representing whether the sound should be paused or not. To pause the sound, use true.


Returns true if the sound element was successfully paused, false otherwise.


This example will allow the user to toggle sounds from paused to playing, and from playing to paused

Click to collapse [-]
theSound = playSound("music/song.mp3", true)
function togglePausedSound()
    if(isSoundPaused(theSound)) then --sound is paused, un-pause it
        setSoundPaused(theSound, false)
    else --sound is not paused, pause it
        setSoundPaused(theSound, true)
addCommandHandler("pausesound", togglePausedSound)


Version Description
1.3.2 Added player element for voice control

See Also