Players::broadcastInDimension
Summary
The players.broadcastInDimension function sends a message to all players in a specified dimension. This function is particularly useful for dimension-specific events or announcements, allowing only players in that area to receive the message.
Required Params
- dimension: number — The dimension in which the message will be sent.
- text: string — The message text to broadcast to all players in the specified dimension.
Return value
- void
Syntax
void players.broadcastInDimension(number dimension, string text);
Example
This example sends a message to all players in the same dimension as the command sender.
mp.events.addCommand("say", (player, message) => {
mp.players.broadcastInDimension(player.dimension, `Message from ${player.name}: ${message}`);
});