Skip to content

chat.sendServerMessageNearby

Sends a line to every player in one virtual world whose listenPosition is within a radius. That is where the player is, unless the gamemode moved it: a camera, spectate or freecam started with listenAtView, or players.setListenPosition. A spectator or freecam player without either hears where they started watching.

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

chat.sendServerMessageNearby(position: Vector3, radius: number, text: string, color?: number, virtualWorld?: number): void
Name Type Description
position Vector3 The centre, [x, y, z].
radius number In game units (metres), 0 or more.
text string The message, up to 256 bytes of valid UTF-8 without control characters. {RRGGBB} codes change color within the line.
color number Optional. The line’s color, 0xRRGGBB.
virtualWorld number Optional. The virtual world to reach, or virtualWorlds.every for every one. Defaults to 0.

Nothing. Players without a known position don’t receive it.

A /me emote heard nearby.

gamemodes/roleplay.ts
import { chat, commands } from "nativemp";
commands.register("me", (player, args) => {
if (player.position) chat.sendServerMessageNearby(player.position, 20, `* ${player.name} ${args}`, 0xc2a2da, player.virtualWorld);
});