Skip to content

chat.sendServerMessage

Sends a line from the server, to everyone or to one player.

Renamed in 0.28 from chat.send; see renamed names.

chat.sendServerMessage(text: string, recipientId?: number | PlayerSnapshot | null, color?: number): void
Name Type Description
text string The message, up to 256 bytes of valid UTF-8 without control characters. {RRGGBB} codes change color within the line.
recipientId number | PlayerSnapshot | null Optional. A session-bound player or current ID; leave it out or null for everyone.
color number Optional. The line’s color, 0xRRGGBB.

Nothing. Text that is not valid is dropped, and so is a message to a player who has left since you got their PlayerSnapshot; see async handlers.

gamemodes/my-mode.ts
import { chat, server } from "nativemp";
server.on("playerConnected", ({ player }) => {
chat.sendServerMessage(`${player.name} joined.`, null, 0xffcc00);
chat.sendServerMessage("{FF0000}Note: {FFFFFF}type /help for commands.", player);
});