Skip to main content

Players::broadcastInRange

Server-side function

Summary​

The mp.players.broadcastInRange function allows sending a chat message to all players within a specified range from a position. This is useful for proximity-based messaging, where only nearby players will receive the message.

Required Params​

  • position: Vector3 — The position from which the message is sent.
  • range: number — The radius around the position for the message range.
  • text: string — The message text to be broadcast.

Optional Params​

  • dimension: number — The dimension where the message is sent (default is all dimensions).

Return value​

  • void

Syntax​

mp.players.broadcastInRange(position, range, text [, dimension]);

Example​

This example sends a message to all players within 15 units of the player.

mp.events.addCommand("say", (player, message) => {
let pos = player.position;
mp.players.broadcastInRange(pos, 15, `Message from ${player.name}: ${message}`);
});