M MY Multiplayer: Wiki
Side
Kind

playSound

Server

Creates a sound with no position in the world that every client plays together. Changes made to it on the server reach everyone.

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

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

Parameters

NameTypeDescription
pathstringPath of a file the resource sends to clients (a <file> in meta.xml). @other/file.mp3 points to another resource.
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 file could not be used (the reason is logged as a warning).

Players who join later hear the sound from where it is now. A sound that does not loop is destroyed by the server when it ends.

Example

addEventHandler("onResourceStart", resourceRoot, function()
    playSound("sounds/event_start.mp3")
end)
Coming from MTAIn MTA, playSound exists on the client only.
NoteThe file must be a client file of the resource, otherwise the function returns false.

See also