PlayerJoin: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
 
(38 intermediate revisions by 15 users not shown)
Line 1: Line 1:
This event is triggered when a player joins the server.
This event is triggered when a player '''joins''' the server.


==Parameters==
{{ServersideJsEvent}}
* '''player''' - player, which joined to the server.


=='''Example'''==
{{CSharpContainer|1=
This example outputs chat message, when player joins to the server.
See [[OnPlayerConnected]].
<div class="header" style="background-color: #E4F1FE; color: #4183D7; width: 100%; border: 1px solid #81CFE0;">
}}
<div style="margin-left: 15px;">Server-side</div>
</div>
<div class="content" style="background-color: #E4F1FE; color: #4183D7; width: 100%; border: 1px solid #81CFE0;">
<syntaxhighlight lang="javascript" style="margin: 0px;">
  function playerJoinHandler(player) {
    console.log(player.name + " join.");
  }


  mp.events.add({
{{Parameters}}
    "playerJoin": playerJoinHandler


  });
{{JSContainer|
{{Parameters}}
* '''player''': {{RageType|Player}} - The player who joined.
 
{{Example}}
<syntaxhighlight lang="javascript">
mp.events.add('playerJoin', (player) => {
    console.log(`[SERVER]: ${player.name} has joined the server!`);
});
</syntaxhighlight>
}}
 
{{ClientsideCsJsEvent}}
This event is '''not''' called for the '''local player''' who joined the server.
 
{{CSharpContainer|
<syntaxhighlight lang="csharp">
public delegate void OnPlayerJoinDelegate(Player player);
</syntaxhighlight>
 
{{Parameters}}
* '''player''': The player joining the server, expects '''RAGE.Elements.Player''' type.
 
{{Example}}
The example below shows up a message to the client when another player joins the server.
 
<syntaxhighlight lang="csharp">
Events.OnPlayerJoin += OnPlayerJoin;
</syntaxhighlight>
<syntaxhighlight lang="csharp">
public void OnPlayerJoin(RAGE.Elements.Player player)
{
    RAGE.Chat.Output($"Player {player.Name} has joined");
}
</syntaxhighlight>
</syntaxhighlight>
</div>
}}
 
{{JSContainer|
{{Parameters}}
* '''player''': {{RageType|Player}} - Another player who joined the server.
 
{{Example}}
<syntaxhighlight lang="javascript">
mp.events.add("playerJoin", (player) => {
    mp.gui.chat.push(`${player.name} has joined the server!`);
});
</syntaxhighlight>
}}
 
==See also==
{{Player_events}}
 
[[Category:Player]]
[[Category:Server-side Event]]
[[Category:Client-side Event]]

Latest revision as of 19:02, 15 May 2024

This event is triggered when a player joins the server.

Server-Side
Event

 JavaScript




C# Syntax


Parameters

JavaScript Syntax

Parameters

  • player: Player - The player who joined.

Example

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


Client-Side Event

 C#  JavaScript


This event is not called for the local player who joined the server.


C# Syntax

public delegate void OnPlayerJoinDelegate(Player player);

Parameters

  • player: The player joining the server, expects RAGE.Elements.Player type.

Example

The example below shows up a message to the client when another player joins the server.

Events.OnPlayerJoin += OnPlayerJoin;
public void OnPlayerJoin(RAGE.Elements.Player player)
{
    RAGE.Chat.Output($"Player {player.Name} has joined");
}


JavaScript Syntax

Parameters

  • player: Player - Another player who joined the server.

Example

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


See also

Checkpoint

Colshape

Entity

Player

Streaming

Vehicle

Waypoint