Search docs
Search modules and symbols
Modules

Docs / API / Modules / chat

Chat

Admin & chat

@s2script/sdk/chat

print messages to player chat.

1 export

Import

import { Chat } from "@s2script/sdk/chat";

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.

const
Chat

Print messages to player chat (SayText2), with a caller-owned Chat.color prefix.

import { Chat } from "@s2script/sdk/chat";
Chat.toAll("[Vote] Result: " + winner);
Chat.toSlot(slot, "Usage:
color: string
An opaque prefix prepended to every chat message (NOT rcon/console replies). Color is content the caller owns (SourceMod-parity), so the engine-generic layer never picks one. A game/plugin sets this to a color control byte — e.g. Chat.color = ChatColors.Green from @s2script/cs2. "" = no prefix. A message may also embed its own colors mid-string. You do NOT need a leading space for color to render: every chat line is auto-prefixed with an invisible zero-width space (U+200B) so a Source 2 chat box doesn't swallow the message's first color byte. Just write Chat.toSlot(slot, ChatColors.Green + "hi") — the green lands. (Idempotent: a line you already lead with a space or a ZWSP is passed through unchanged.)
toSlot(slot: number, message: string): void
Print to the chat of the client in slot (0-based).
toAll(message: string): void
Print to every live player's chat.
Back to modules All packages

s2script — Source 2 plugin framework

GitHub