Modules

Docs / API / Modules / transmit

Transmit

Players & world

@s2script/sdk/transmit

per-client entity visibility filtering (Source2 CheckTransmit). Declarative rules: a plugin says "this entity is visible only to these viewer slots" and the engine-side hook enforces it every snapshot — zero JS runs in the per-client hot path.

2 exports

Import

import { TransmitStats } from "@s2script/sdk/transmit";

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
TransmitStats

Hot-path measurement counters returned by Transmit.stats.

snapshots: number
CheckTransmit invocations observed since load/reset.
entries: number
Live rule entries in the native table.
bitsCleared: number
Total transmit bits cleared since load/reset.
nsLast: number
Nanoseconds spent in the post-hook, last invocation.
nsMax: number
Worst single invocation (ns) since load/reset.
const
Transmit

Declarative per-client entity visibility: hide an entity from some viewers, enforced engine-side each snapshot.

import { Transmit } from "@s2script/sdk/transmit";
// examples/transmit-demo/src/plugin.ts:58 — show `prop` ONLY to one viewer slot
const ok = Transmit.setVisibleTo(prop, [slot]);
setVisibleTo(entity: EntityRef, viewers: readonly number[]): boolean
Replace this plugin's visibility rule for entity: it is transmitted ONLY to the given viewer slots (an empty array = hidden from everyone). Multiple plugins AND-merge — an entity reaches a viewer only if every plugin holding a rule on it allows that viewer. Returns false if the ref is stale or the capability is unavailable/disabled. Throws RangeError on a slot outside [0, 64).
reset(entity: EntityRef): boolean
Remove this plugin's rule for entity (visible to all again, as far as this plugin is concerned). Returns false if the ref is stale or the capability is unavailable.
resetAll(): void
Remove all of this plugin's rules.
stats(): TransmitStats
Hot-path counters for measurement/debugging.
Back to modules All packages

s2script — Source 2 plugin framework

GitHub