Players::broadcastInRange
Server-Side Function
JavaScript Syntax
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}`);
});
See also
- Functions
- Players::broadcast
- Players::broadcastInDimension
- Players::broadcastInRange
- Players::call
- Players::callInDimension
- Players::callInRange
- Players::callUnreliable
- Players::callInDimensionUnreliable
- Players::callInRangeUnreliable
- Players::reloadResources
- Pool::apply
- Pool::at
- Pool::exists
- Pool::forEach
- Pool::forEachInDimension
- Pool::forEachInRange
- Pool::getClosest
- Pool::getClosestInDimension
- Pool::toArray
- Pool::toArrayFast