M MY Multiplayer: Wiki
Side
Kind

playSound

Client

Plays a sound with no position in the world, on this client only. Fires onClientSoundStarted with the reason play.

Also exists on the server, with its own implementation: playSound

sound|false playSound(string sound [, bool looped = false, bool throttled = true])

Parameters

NameTypeDescription
soundstringA name registered with engineAddSound, the path of a file in the resource (@other/file.mp3 for another resource) or the bytes of an audio file themselves.
loopedboolPlay the sound again from the start when it reaches the end.default false
throttledboolAccepted for MTA compatibility and ignored.default true

Returns

The created sound element, or false if the sound could not be opened.

When a sound that does not loop reaches its end, it fires onClientSoundStopped with finished and the element is destroyed.

Example

local music = playSound("sounds/intro.ogg", true)
setSoundVolume(music, 0.5)
Coming from MTAInternet addresses (http, ftp) are not accepted. Another resource is named with @resource/, not :resource/.

See also