ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. playSound3D

Function

playSound3D

ClientSound (client)Identical to MTA:SA

Plays a sound at a point in the world. It fades with distance from the camera: full volume up to 5 m, silent from 20 m. It is panned left-right.

Syntax

sound playSound3D(string soundPath, float x, float y, float z [, bool looped = false, bool throttle])

Arguments

soundPathstring
A path in the resource.
xfloat
X position.
yfloat
Y position.
zfloat
Z position.
loopedbool, optional = false
Whether to loop.
throttlebool, optional
Accepted for compatibility with existing scripts, but the game does not use it.

Returns

A sound element or false.

Example

A campfire radio audible from 40 metres.

local radio = playSound3D("audio/radio.mp3", 2495.1, -1687.4, 13.5, true)
setSoundMaxDistance(radio, 40)
setSoundMinDistance(radio, 8)

Notes

A sound can follow a vehicle. attachElements(sound, vehicle) attaches the sound to an element.

See also