PlayerJoin: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
Line 1: Line 1:
{{Shared}}
{{ServersideCsJsEvent}}


This event is triggered when a player joins the server.
This event is triggered when a player joins the server.


{{JSContainer|
'''NOTE: ''' This event is not called for the local player who joined the server (when it's used in client-side).
'''NOTE: ''' This event is not called for the local player who joined the server (when it's used in client-side).
{{Parameters}}
* '''player''': The player who joined.


== Syntax ==
{{Example}}
This is a basic explanation about what does the example below do.


<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
mp.events.add('playerJoin', player => {
mp.events.add('playerJoin', player => {
     //do stuff here
     mp.gui.chat.push(`[SERVER]: ${player.name} has joined the server!`);
});
});
</syntaxhighlight>
</syntaxhighlight>
}}


=== Attributes ===
{{ClientsideCsJsEvent}}
* '''player''': The player who joined.
{{CSharpContainer|
<syntaxhighlight lang="c#">
public delegate void OnPlayerJoinDelegate(Player player);
</syntaxhighlight>


{{Parameters}}
* '''player''': The player joining the server, expects '''RAGE.Elements.Player''' type.


== Examples ==
{{Example}}
The example below shows up a message for a player and hides the browser when it is created.


This is a basic explanation about what does the example below do.
<syntaxhighlight lang="c#">
 
Events.OnPlayerJoin += OnPlayerJoin;
<syntaxhighlight lang="javascript">
</syntaxhighlight>
mp.events.add('playerJoin', player => {
<syntaxhighlight lang="c#">
     mp.gui.chat.push(`[SERVER]: ${player.name} has joined the server!`);
public void OnPlayerJoin(RAGE.Elements.Player player)
});
{
     RAGE.Chat.Output($"Player {player.Name} has joined");
}
</syntaxhighlight>
</syntaxhighlight>
}}
{{JSContainer|
Same as serverside
}}

Revision as of 09:29, 29 November 2018

Server-Side
Event

 C#  JavaScript



This event is triggered when a player joins the server.

JavaScript Syntax

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

Parameters

  • player: The player who joined.

Example

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!`);
});


Client-Side Event

 C#  JavaScript


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 for a player and hides the browser when it is created.

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


JavaScript Syntax

Same as serverside