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.
Signature
Section titled “Signature”chat.sendServerMessageNearby(position: Vector3, radius: number, text: string, color?: number, virtualWorld?: number): voidParameters
Section titled “Parameters”| 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. |
Returns
Section titled “Returns”Nothing. Players without a known position don’t receive it.
Example
Section titled “Example”A /me emote heard nearby.
import { chat, commands } from "nativemp";
commands.register("me", (player, args) => { if (player.position) chat.sendServerMessageNearby(player.position, 20, `* ${player.name} ${args}`, 0xc2a2da, player.virtualWorld);});Related
Section titled “Related”chat.sendServerMessage: everyone, or one playerchat.onPlayerMessage: turn global chat into local chat