playSound3D
Server
Creates a sound at a 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: playSound3D
sound|false playSound3D(string path, float x, y, z [, bool looped = false, bool throttled = true])
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | Path of a file the resource sends to clients (a <file> in meta.xml). @other/file.mp3 points to another resource. |
| x, y, z | float | The sound's position in the world, as three numbers or one vec3. |
| looped | bool | Play the sound again from the start when it reaches the end.default false |
| throttled | bool | Accepted 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
local alarm = playSound3D("sounds/alarm.ogg", 1481.0, -1771.3, 18.8, true)
setSoundMaxDistance(alarm, 60)Coming from MTAIn MTA,
playSound3D exists on the client only.NoteThe file must be a client file of the resource, otherwise the function returns
false.