Players::broadcastInDimension: Difference between revisions

From RAGE Multiplayer Wiki
(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:
This function writes a chat message for all players in dimension (like [[Player::outputChatBox]]).
{{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.broadcastInRange(number dimension, string text);
void players.broadcastInDimension(number dimension, string text);
</syntaxhighlight>  
</syntaxhighlight>  
===Required Arguments===
*'''dimension:''' The dimension in which the broadcast will be sent.
*'''text:''' The text to be sent.


==Example==
==Example==
This example sends message to all players in his dimension
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}`);
    mp.players.broadcastInDimension(player.dimension, `Message from ${player.name}: ${message}`);
 
});
});
</syntaxhighlight>
</syntaxhighlight>


==See Also==
}}
==See also==
{{PlayerPool_block}}
{{PlayerPool_block}}
[[Category:Serverside API]]

Latest revision as of 11:04, 10 November 2024

Server-Side
Function

 JavaScript



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