# 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.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Server
- **Category**: Sound
- **URL**: https://wiki.mymp.gg/en/playSound3D-server
- **Counterpart**: Also exists on the client, with its own implementation: [playSound3D (Client)](https://wiki.mymp.gg/en/playSound3D-client.md)

## Syntax

```lua
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

```lua
local alarm = playSound3D("sounds/alarm.ogg", 1481.0, -1771.3, 18.8, true)
setSoundMaxDistance(alarm, 60)
```

### Coming from MTA

In MTA, `playSound3D` exists on the client only.

### Note

The file must be a client file of the resource, otherwise the function returns `false`.

## See also

- [playSound (Server)](https://wiki.mymp.gg/en/playSound-server.md): Creates a sound with no position in the world that every client plays together. Changes made to it on the server reach everyone.
- [stopSound (Server)](https://wiki.mymp.gg/en/stopSound-server.md): Stops a sound the server created and destroys the element on every client.
- [setSoundMaxDistance (Shared)](https://wiki.mymp.gg/en/setSoundMaxDistance.md): Sets the distance at which a 3D sound goes silent. The default is 20 m. On the server, the change is sent to every client.
- [playSound3D (Client)](https://wiki.mymp.gg/en/playSound3D-client.md): Plays a sound at a position in the world, on this client only. Its volume falls with distance between setSoundMinDistance (5 m) and setSoundMaxDistance (20 m). Fires onClientSoundStarted with play.
