Client-side exports

These functions should be used in the client script files.

API for playing audio

Play3DPos(uniqueId, position, distance, sound, volume, looped)

local sound = exports["high_3dsounds"]:Play3DPos(
    "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
)

Arguments

Can't be empty - *

Argument numberArgument nameExample value

1

uniqueId*

"uniqueName"

2

position*

vector3(123.0, 123.0, 123.0)

3

distance

50.0

4

sound*

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)

local sound = exports["high_3dsounds"]:Play3DEntity(
    NetworkGetNetworkIdFromEntity(PlayerPedId()), -- entity net id
    50.0, -- distance
    "fileName", -- sound URL/file name
    1.0, -- volume
    true -- looped
)

Arguments

Can't be empty - *

Argument numberArgument nameExample value

1

entityNetId*

NetworkGetNetworkIdFromEntity(PlayerPedId())

2

distance

50.0

3

sound*

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

FieldDescriptionType

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)

local sound = exports["high_3dsounds"]:Play3DPos(...) -- Put your own arguments inside
sound.addEventListener("onPlay", function()
    print("Playing " .. sound.id)
end)

Arguments

Can't be empty - *

Argument numberArgument nameExample value

1

event*

"onPlay"

2

callback*

function() return true end

Events

Event nameDescription

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)

local sound = exports["high_3dsounds"]:Play3DPos(...) -- Put your own arguments inside
sound.modify("volume", 1.0)

Arguments

Can't be empty - *

Argument numberArgument nameExample value

1

field*

"volume"

2

newValue*

1.0

3

secondValue

500 Fading time in miliseconds.

Modifiable fields

FieldTypeExample valueExample 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()

local sound = exports["high_3dsounds"]:Play3DPos(...) -- Put your own arguments inside
sound.destroy()

This export function destroys the sound element.

soundVar.replay()

local sound = exports["high_3dsounds"]:Play3DPos(...) -- Put your own arguments inside
sound.replay()

This export function replays the audio 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