PlayerJoin: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
Line 1: Line 1:
{{Shared}}
This event is triggered when a player joins the server.
This event is triggered when a player joins the server.


==Parameters==
'''NOTE: ''' This event is not called for the local player who joined the server (when it's used in client-side).
* '''player''' - player which joined the server.
 
== Syntax ==


==Example==
This example outputs chat message, when player joins to the server.
{{ServerSide}}
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
  function playerJoinHandler(player) {
mp.events.add('playerJoin', player => {
     console.log(`${player.name} join.`);
     //do stuff here
  }
});
</syntaxhighlight>


  mp.events.add("playerJoin", playerJoinHandler);
=== Attributes ===
* '''player''': The player who joined.
 
 
== Examples ==
 
This is a basic explanation about what does the example below do.
 
<syntaxhighlight lang="javascript">
mp.events.add('playerJoin', player => {
    mp.gui.chat.push(`[SERVER]: ${player.name} has joined the server!`);
});
</syntaxhighlight>
</syntaxhighlight>
==See also==
{{Player_events}}

Revision as of 19:33, 23 August 2018

Shared

This event is triggered when a player joins the server.

NOTE: This event is not called for the local player who joined the server (when it's used in client-side).

Syntax

mp.events.add('playerJoin', player => {
    //do stuff here
});

Attributes

  • player: The player who joined.


Examples

This is a basic explanation about what does the example below do.

mp.events.add('playerJoin', player => {
    mp.gui.chat.push(`[SERVER]: ${player.name} has joined the server!`);
});