Client-side exports
These functions should be used in the client script files.
API for playing audio
Play3DPos(uniqueId, position, distance, sound, volume, looped)
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 "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)
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 "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 in Play3D*
function variable
Play3D*
function variableField | 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 it's class | number |
doorCount | If entity is a vehicle, returns it's door count | number |
Entity player data (Yellow) Player at a position data (White)
Audio manipulation API
soundVar.addEventListener(event, callback)
soundVar.addEventListener(event, callback)
Arguments
Can't be empty - *
Argument number | Argument name | Example value |
---|---|---|
1 | event* | "onPlay" |
2 | callback* |
|
Events
Event name | Description |
---|---|
onPlay | Gets triggered when the sound is fully loaded and starts playing. |
onFinished | Gets triggered when the sound finishes playing. |
onCreated | Gets triggered right after the sound is created. |
onPause | Gets triggered when the sound gets paused (most often with a function) |
onResume | nGets triggered when the sound gets resumed (most often with a function) |
This export function adds event listeners to the audio element.
soundVar.modify(field, newValue, secondValue)
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 Fading time in miliseconds. |
Modifiable fields
Field | Type | Example value | Example second value |
---|---|---|---|
volume | number (0.0-1.0) | 1.0 | 500 Fading time in miliseconds. |
distance | number | 50.0 | None |
position | vector3 | vector3(123.0, 123.0, 123.0) | None |
loop | boolean | true | None |
timeStamp | number (seconds) | 60 | None |
destroyOnFinish | boolean | true | None |
This export function modifies the given sound value.
soundVar.destroy()
soundVar.destroy()
This export function destroys the sound element.
soundVar.replay()
soundVar.replay()
This export function replays the audio from the beginning.
Other API functions
getSound(uniqueId)
getSound(uniqueId)
This export function gets the sound object.
getSoundData(uniqueId, field)
getSoundData(uniqueId, field)
This export function gets a specified data field of the sound object.
Last updated