Server-side exports

These functions should be used in the server script files.

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
        true -- looped
    )
end)

Arguments

Can't be empty - *

Argument number
Argument name
Example value

1

source*

1

2

uniqueId*

"uniqueName"

3

position*

vector3(123.0, 123.0, 123.0)

4

distance

50.0

6

volume (0.0-1.0)

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()), -- entity net id
        50.0, -- distance
        "fileName", -- sound URL/file name
        1.0, -- volume
        true -- looped
    )
end)

Arguments

Can't be empty - *

Argument number
Argument name
Example value

1

source*

1

2

entityNetId*

NetworkGetNetworkIdFromEntity(PlayerPedId())

3

distance

50.0

5

volume (0.0-1.0)

1.0

6

looped

false

This export function plays a sound on a specified entity.

Returned data in Play3D* function variable

Field
Description
Type

id

Sound unique id / name

string/number

entity

Entity ID

entity

url

The source/URL of the sound

string

volume

Sound volume (0.0-1.0)

number

distance

Max distance of the sound

number

position

Position of the sound player

vector3

loop

Looped or not

boolean

playedAt

Current timestamp of the video

number

destroyOnFinish

Will the sound element be destroyed on finish

boolean

Entity player data (Yellow) Player at a position data (White)

Audio manipulation API

soundVar.modify(source, field, newValue, secondValue)

AddEventHandler("event", function()
    local src = source
    local sound = exports["high_3dsounds"]:Play3DPos(...) -- Put your own arguments inside
    sound.modify(src, "volume", 1.0)
end)

Arguments

Can't be empty - *

Argument number
Argument name
Example value

1

source*

1

2

field*

"volume"

3

newValue*

1.0

4

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 specified sound value.

soundVar.destroy(source)

AddEventHandler("event", function()
    local src = source
    local sound = exports["high_3dsounds"]:Play3DPos(...) -- Put your own arguments inside
    sound.destroy(src)
end)

Arguments

Can't be empty - *

Argument number
Argument name
Example value

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(...) -- Put your own arguments inside
    sound.replay(src)
end)

Arguments

Can't be empty - *

Argument number
Argument name
Example value

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 gets the sound object.

getSoundData(uniqueId, field)

local volume = exports["high_3dsounds"]:getSoundData("mySound", "volume")
print("Sound volume: " .. volume)

This export function gets a specified data field of the sound object.

Last updated