For the complete documentation index, see llms.txt. This page is also available as Markdown.

Client

Manipulate the sound

Play

local soundId = exports['mx-surround']:Play(soundId, url, coords, loop, volume, panner)

This export is a synchronous function, which means that this code returns a soundId to you. And if sound is not created, it returns false

Parameters

  • soundId?: string

    • If not provided, will be created automatically

  • url: string

  • coords?: vector3

    • If not provided, its means that the sound is not dynamic. So player can hear it from everywhere

  • loop?: boolean

  • volume?: number

    • Override default volume (even if sound profile is enabled) (0.0 | 1.0)

  • panner?: PannerNode

Returns

  • soundId | false


Play Async

This is the same as a normal play export. The only difference is that it is async. So there is no return value


Attach To Entity

Parameters

  • soundId: string

  • networkId: number


Detach From Entity

Parameters

  • soundId: string


Attach To Player

If you are going to attach to a player, you can of course use the attachEntity. But you should definitely use this. Because if the player gets in the car, the script detects it with this export and filters the sound.

Parameters

  • soundId: string

  • playerId: number


Detach From Player

Parameters

  • soundId: string


Stop

The difference from Pause export is this: If you are playing a song on spotify or youtube, it completely deletes the player so that there is no player in the dom. This is very important for optimization

Parameters

  • soundId: string


Pause

Parameters

  • soundId: string


Resume

Parameters

  • soundId: string


Destroy

Parameters

  • soundId: string


Destroy All


Repeat

Parameters

  • soundId: string


Add Filter

Parameters

  • soundId: string

  • type: string

  • filter: {frequency: number, Q: number, gain:number}


Remove Filter

Parameters

  • soundId: string


On Loop

Fires each time a looping sound wraps back to the start.

Parameters

  • soundId: string | number

  • fn: function


Register Deafening Sound

Register a loud event so it rings the listener's ears. Explosions already do this on their own; use it for anything else loud enough to deserve it.

Requires Config.Environment.Deafening.

Parameters

  • coords: vector3

    • Where the blast happened. Distance to the listener is taken into account

  • volume: number

    • Rough loudness on the game's own scale — an explosion is about 16.0


Set Duck Scene

Pull music and ambience down while something more important is happening. Phone calls, the pause menu and death already do this; use it for your own systems.

Several scenes can be active at once and the most aggressive one wins.

Parameters

  • name: string

    • Your own id, so several systems can duck at the same time without fighting

  • apply: number

    • 0.0 - 1.0, how hard this scene ducks. 0.0 clears the scene

  • options?: table

    • floor?: number — gain at full apply. Default 0.25

    • rate?: number — how fast it ramps in and out. Default 2.0


Clear Duck Scene

Ends a scene started with setDuckScene.

Parameters

  • name: string


To better manage sounds, see these three section

SetGetHandlers

Last updated