Server Side Exports
These functions should be used in the server script files.
Server-side exports
API for playing audio
Play3DPos(source, uniqueId, position, distance, sound, volume, looped)
# | Argument | Example |
---|---|---|
1 | source * | 1 |
2 | uniqueId * | "uniqueName" |
3 | position * | vector3(123.0, 123.0, 123.0) |
4 | distance | 50.0 |
5 | sound * | "fileName" OR "https://youtu.be/dQw4w9WgXcQ" |
6 | volume | 1.0 |
7 | looped | false |
This export function plays a sound at a specified position.
Play3DEntity(source, entityNetId, distance, sound, volume, looped)
# | Argument | Example |
---|---|---|
1 | source * | 1 |
2 | entityNetId * | NetworkGetNetworkIdFromEntity(PlayerPedId()) |
3 | distance | 50.0 |
4 | sound * | "fileName" OR "https://youtu.be/dQw4w9WgXcQ" |
5 | volume | 1.0 |
6 | 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 (if used) | entity |
url | Source URL of the sound | string |
volume | Current volume (0.0–1.0) | number |
distance | Max audible distance | number |
position | Playback position | vector3 |
loop | Is looped | boolean |
playedAt | Current timestamp (seconds) | number |
destroyOnFinish | Auto-destroy on finish | boolean |
Entity fields appear when using Play3DEntity; position fields when using Play3DPos.
Audio manipulation API
soundVar.modify(source, field, newValue, secondValue)
# | Argument | Example |
---|---|---|
1 | source * | 1 |
2 | field * | "volume" |
3 | newValue * | 1.0 |
4 | secondValue | 500 (fade time in ms) |
This export function modifies a specified sound property.
soundVar.destroy(source)
# | Argument | Example |
---|---|---|
1 | source * | 1 |
This export function destroys the sound element.
soundVar.replay(source)
# | Argument | Example |
---|---|---|
1 | source * | 1 |
This export function replays the sound from the beginning.
Other API functions
getSound(uniqueId)
This export function retrieves the sound object for further operations.
getSoundData(uniqueId, field)
This export function fetches a specific data field (e.g., volume, distance) from the sound object.
Last updated on