Players::broadcastInDimension: Difference between revisions
CocaColaBear (talk | contribs) (Created page with "This function writes a chat message for all players in dimension (like Player::outputChatBox). ==Syntax== <syntaxhighlight lang="typescript"> void players.broadcastInRang...") |
No edit summary |
||
| Line 1: | Line 1: | ||
{{ServersideJsFunction}} | |||
{{JSContainer| | |||
==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:''' {{RageType|number}} — The dimension in which the message will be sent. | |||
*'''text:''' {{RageType|string}} — The message text to broadcast to all players in the specified dimension. | |||
===Return value=== | |||
*''' {{RageType|void}} ''' | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="typescript"> | <syntaxhighlight lang="typescript"> | ||
void players. | void players.broadcastInDimension(number dimension, string text); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Example== | ==Example== | ||
This example sends message to all players in | This example sends a message to all players in the same dimension as the command sender. | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
mp.events.addCommand("say", (player, message) => { | mp.events.addCommand("say", (player, message) => { | ||
mp.players.broadcastInDimension(player.dimension, `Message from ${player.name}: ${message}`); | |||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See | }} | ||
==See also== | |||
{{PlayerPool_block}} | {{PlayerPool_block}} | ||
[[Category:Serverside API]] | |||
Latest revision as of 11:04, 10 November 2024
Server-Side Function
JavaScript Syntax
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}`);
});
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