Players::call

From RAGE Multiplayer Wiki
Jump to navigation Jump to search

This function triggers an event for:

  • the whole server
  • specified players array


Syntax

mp.players.call(String eventName[, Array Arguments]);
mp.players.call(Array players, String eventName[, Array Arguments]);

Required Arguments

  • eventName: Event name, what will be called.
  • args: Any arguments, what should be sended to client. Supports entities, strings, numbers and booleans. (Objects and Arrays should be packed to JSON format.)

Example

1. Trigger "disablePlayerRegeneration" event for everyone near new mp.Vector3(150, 100, 50).

Server-Side
const playersArray = mp.players.toArray().filter((player) => (player.dist(new mp.Vector3(150, 100, 50)) < 20));
mp.players.call(playersArray, "disablePlayerRegeneration");


2. Trigger "disablePlayerRegeneration" event for everyone.

Server-Side
mp.players.call("disablePlayerRegeneration");


See Also