Search docs
Search modules and symbols
Modules

Docs / API / Modules / voice

Voice

Platform

@s2script/sdk/voice

who can hear whom.

2 exports

Import

import { VoiceStats } from "@s2script/sdk/voice";

Author-time types ship in the npm package; the engine injects the runtime at plugin load. Add @s2script/sdk to your plugin's dependencies.

API reference

Generated from the shipped type definitions.

interface
VoiceStats

Hot-path measurement counters returned by Voice.stats.

calls: number
Listen-matrix decisions the engine has asked about.
entries: number
Senders currently carrying a merged rule.
rewrites: number
Times a rule actually silenced a pair. THE effect counter — a rule that never rewrites is not working.
const
Voice

Per-(receiver, sender) voice hearability.

import { Voice } from "@s2script/sdk/voice";
// A dead player is heard only by other dead players.
Voice.setAudibleTo(deadSlot, otherDeadSlots);
// ...and on respawn, hand the slot back to the engine.
Voice.reset(deadSlot);
setAudibleTo(sender: number, receivers: readonly number[]): boolean

This sender is audible ONLY to receivers (0-based slots). An empty array means audible to nobody — distinct from Voice.reset, which removes the rule and lets the engine decide. Rules from multiple plugins AND-merge, so another plugin can only ever narrow yours, never widen it. A rule is dropped automatically when the sender disconnects: slots are recycled, and a rule is about the player who occupied one, not the seat. Returns false — never throws — when the rule was NOT applied: voice control is degraded or its engine hook never installed on this build, sender is outside [0, 64), or any element of receivers is. Note this differs from import("./transmit").Transmit.setVisibleTo, which throws RangeError on a bad slot; check the return value here rather than relying on a throw.

ThrowsTypeError if receivers is not an array.

reset(sender: number): boolean
Drop THIS plugin's rule for sender; other plugins' rules survive and are re-merged. false when you had no rule for that sender.
resetAll(): void
Drop every rule this plugin owns. Unload does this automatically.
stats(): VoiceStats | null
Hot-path counters, or null when the running shim predates this capability.
Back to modules All packages

s2script — Source 2 plugin framework

GitHub