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)
AddEventHandler("event", function()
local sound = exports["high_3dsounds"]:Play3DPos(
source, -- player source *
"firstSound", -- uniqueId *
vector3(123.0, 123.0, 123.0), -- position *
50.0, -- distance
"https://www.youtube.com/watch?v=dQw4w9WgXcQ", -- sound URL/file name *
1.0, -- volume (0.0–1.0)
true -- looped
)
end)
# | 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)
AddEventHandler("event", function()
local sound = exports["high_3dsounds"]:Play3DEntity(
source, -- player source *
NetworkGetNetworkIdFromEntity(PlayerPedId()), -- entityNetId *
50.0, -- distance
"fileName", -- sound URL/file name *
1.0, -- volume
true -- looped
)
end)
# | 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)
AddEventHandler("event", function()
local src = source
local sound = exports["high_3dsounds"]:Play3DPos(...) -- your args
sound.modify(src, "volume", 1.0) -- change volume
end)
# | 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)
AddEventHandler("event", function()
local src = source
local sound = exports["high_3dsounds"]:Play3DPos(...)
sound.destroy(src)
end)
# | Argument | Example |
---|---|---|
1 | source * | 1 |
This export function destroys the sound element.
soundVar.replay(source)
AddEventHandler("event", function()
local src = source
local sound = exports["high_3dsounds"]:Play3DPos(...)
sound.replay(src)
end)
# | Argument | Example |
---|---|---|
1 | source * | 1 |
This export function replays the sound from the beginning.
Other API functions
getSound(uniqueId)
local sound = exports["high_3dsounds"]:getSound("mySound")
sound.modify("volume", 1.0)
This export function retrieves the sound object for further operations.
getSoundData(uniqueId, field)
local volume = exports["high_3dsounds"]:getSoundData("mySound", "volume")
print("Sound volume: " .. volume)
This export function fetches a specific data field (e.g., volume, distance) from the sound object.
Last updated on