Client Side Exports
These functions should be used in the client script files.
Client-side exports
API for playing audio
Play3DPos(uniqueId, position, distance, sound, volume, looped)
Arguments
Can't be empty – *
Argument number | Argument name | Example value |
---|---|---|
1 | uniqueId* | "uniqueName" |
2 | position* | vector3(123.0, 123.0, 123.0) |
3 | distance | 50.0 |
4 | sound* | "fileName" OR [YouTube URL](https://www.youtube.com/watch?v=dQw4w9WgXcQ) |
5 | volume (0.0–1.0) | 1.0 |
6 | looped | false |
This export function plays a sound at a specified position.
Play3DEntity(entityNetId, distance, sound, volume, looped)
Arguments
Can't be empty – *
Argument number | Argument name | Example value |
---|---|---|
1 | entityNetId* | NetworkGetNetworkIdFromEntity(PlayerPedId()) |
2 | distance | 50.0 |
3 | sound* | "fileName" OR [YouTube URL](https://www.youtube.com/watch?v=dQw4w9WgXcQ) |
4 | volume (0.0–1.0) | 1.0 |
5 | looped | false |
This export function plays a sound on a specified entity.
Returned data from Play3D*
functions
Field | Description | Type |
---|---|---|
id | Sound unique id / name | string/number |
entity | Entity ID | entity |
url | The source/URL of the sound | string |
playing | Is the sound playing & loaded | boolean |
volume | Sound volume (0.0–1.0) | number |
distance | Max distance of the sound | number |
position | Position of the sound player | vector3 |
vehicle | Is entity a vehicle | boolean |
loop | Looped or not | boolean |
timeStamp | Current timestamp of the video | number |
duration | Audio duration in seconds | number |
destroyOnFinish | Will the sound element be destroyed on finish | boolean |
isConvertible | If entity is a vehicle, is it a convertible | boolean |
vehicleClass | If entity is a vehicle, returns its class | number |
doorCount | If entity is a vehicle, returns its door count | number |
Fields highlighted in yellow represent player-related data.
Audio manipulation API
soundVar.addEventListener(event, callback)
Arguments
Can't be empty – *
Argument number | Argument name | Example value |
---|---|---|
1 | event* | "onPlay" |
2 | callback* | function() return true end |
Events
Event name | Description |
---|---|
onPlay | Triggered when the sound is fully loaded and starts playing. |
onFinished | Triggered when the sound finishes playing. |
onCreated | Triggered right after the sound is created. |
onPause | Triggered when the sound gets paused. |
onResume | Triggered when the sound gets resumed. |
This export function adds event listeners to the audio element.
soundVar.modify(field, newValue, secondValue)
Arguments
Can't be empty – *
Argument number | Argument name | Example value |
---|---|---|
1 | field* | "volume" |
2 | newValue* | 1.0 |
3 | secondValue | 500 (fade time in ms) |
Modifiable fields
Field | Type | Description |
---|---|---|
volume | number (0.0–1.0) | Volume level (fade time optional) |
distance | number | Maximum audible distance |
position | vector3 | Sound position |
loop | boolean | Looping toggle |
timeStamp | number (seconds) | Seek position |
destroyOnFinish | boolean | Auto-destroy toggle |
This export function modifies the given sound value.
soundVar.destroy()
This export function destroys the sound element.
soundVar.replay()
This export function replays the audio from the beginning.
Other API functions
getSound(uniqueId)
This export function retrieves the sound object.
getSoundData(uniqueId, field)
This export function fetches a specific data field from the sound object.
Last updated on