Skip to content
M2O Scripting APIScripting reference
Runtime classServer APIGenerated

Sound

Defined in: server/api.d.ts:2022

Replicated positional sound source that every nearby client plays through the game’s own mixer.

new Sound(id): Sound

Defined in: server/api.d.ts:2027

Creates a script wrapper for an existing sound with this ID; use Sound.create() to place one.

number

Network entity identifier.

Sound

Entity.constructor

destroy(): void

Defined in: server/api.d.ts:2073

Stops this sound and removes it from every client.

void


setEnabled(enabled): void

Defined in: server/api.d.ts:2115

Sets whether this sound is currently playing. Re-enabling restarts it.

boolean

True to play, false to fall silent without destroying the sound.

void


setInnerRadius(innerRadius): void

Defined in: server/api.d.ts:2103

Sets the distance inside which no falloff is applied; the sound restarts.

number

Distance in world units within which the sound plays at full volume; must be smaller than the radius.

void


setLoop(loop): void

Defined in: server/api.d.ts:2109

Sets whether this sound repeats.

boolean

True to repeat forever, false to play the wave once.

void


setPitch(pitch): void

Defined in: server/api.d.ts:2091

Sets the playback rate; the sound restarts, because the rate is fixed when the voice is built.

number

Playback rate multiplier from 0.25 to 4, where 1 is the recorded pitch.

void


setRadius(radius): void

Defined in: server/api.d.ts:2097

Sets how far this sound carries; the sound restarts.

number

Distance in world units beyond which the sound is inaudible; must be greater than 0 and at most 500.

void


setVirtualWorld(world): void

Defined in: server/api.d.ts:4154

Moves this entity into another virtual world.

number

Virtual-world identifier used to partition replication and visibility.

void

Entity.setVirtualWorld


setVisibleTo(player): void

Defined in: server/api.d.ts:4160

Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.

Entity | null

Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.

void

Entity.setVisibleTo


setVolume(volume): void

Defined in: server/api.d.ts:2085

Sets how loud this sound is, without restarting it.

number

Linear gain from 0 to 2, where 1 is the recorded level.

void


setWave(wave): void

Defined in: server/api.d.ts:2079

Sets which wave this sound plays; the sound restarts on every client that has it.

string

Name of a wave in the game’s sound archives, such as “Ambienty/ambi_noc1”.

void


toString(): string

Defined in: server/api.d.ts:2068

Returns a readable representation of this sound.

string

The sound’s ID, wave and reach formatted for logging or debugging.

Entity.toString


static create(x, y, z, wave, radius?, volume?, virtualWorld?): Sound

Defined in: server/api.d.ts:2128

Places a looping sound that plays until it is destroyed. A wave the client does not have is silent there.

number

World-space X coordinate of the sound.

number

World-space Y coordinate of the sound.

number

World-space Z coordinate of the sound.

string

Name of a wave in the game’s sound archives, such as “Ambienty/ambi_noc1”.

number

Optional distance in world units beyond which the sound is inaudible; defaults to 25.

number

Optional linear gain from 0 to 2; defaults to 1.

number

Optional virtual-world ID used for visibility filtering.

Sound

The newly created sound handle.


static play(x, y, z, wave, radius?, volume?, pitch?): void

Defined in: server/api.d.ts:2140

Plays a wave once at a position on every client. Nothing is replicated, so it cannot be stopped or moved.

number

World-space X coordinate to play at.

number

World-space Y coordinate to play at.

number

World-space Z coordinate to play at.

string

Name of a wave in the game’s sound archives.

number

Optional distance in world units beyond which it is inaudible; defaults to 25.

number

Optional linear gain from 0 to 2; defaults to 1.

number

Optional playback rate multiplier from 0.25 to 4; defaults to 1.

void


static playForPlayer(player, x, y, z, wave, radius?, volume?, pitch?): void

Defined in: server/api.d.ts:2153

Plays a wave once at a position, for one player only.

Player

The player who should hear it.

number

World-space X coordinate to play at.

number

World-space Y coordinate to play at.

number

World-space Z coordinate to play at.

string

Name of a wave in the game’s sound archives.

number

Optional distance in world units beyond which it is inaudible; defaults to 25.

number

Optional linear gain from 0 to 2; defaults to 1.

number

Optional playback rate multiplier from 0.25 to 4; defaults to 1.

void


static stopAll(): number

Defined in: server/api.d.ts:2159

Destroys every placed sound. One-shots already on their way are unaffected.

number

The number of sounds that were destroyed.

readonly enabled: boolean

Defined in: server/api.d.ts:2062

Whether the sound is currently playing.


readonly id: number

Defined in: server/api.d.ts:4122

Immutable network entity identifier.

Entity.id


readonly innerRadius: number

Defined in: server/api.d.ts:2052

Distance in world units within which the sound plays at full volume.


readonly loop: boolean

Defined in: server/api.d.ts:2057

Whether the sound repeats.


readonly pitch: number

Defined in: server/api.d.ts:2042

Playback rate multiplier, where 1 is the recorded pitch.


position: Vector3

Defined in: server/api.d.ts:4132

Authoritative world-space position; assignment forces replicated state.

Entity.position


readonly radius: number

Defined in: server/api.d.ts:2047

Distance in world units beyond which the sound is inaudible.


rotation: Vector3 | Quaternion

Defined in: server/api.d.ts:4137

Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.

Entity.rotation


readonly state: StateBag

Defined in: server/api.d.ts:4142

Arbitrary key/value state carried by this entity. The server writes it and every client that can see the entity receives it; see StateBag.

Entity.state


readonly virtualWorld: number

Defined in: server/api.d.ts:4127

Current virtual-world identifier.

Entity.virtualWorld


readonly volume: number

Defined in: server/api.d.ts:2037

Linear gain, where 1 is the recorded level.


readonly wave: string

Defined in: server/api.d.ts:2032

Name of the wave this sound plays.