PlayerJoin: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
{{ | {{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. | |||
{{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 => { | ||
mp.gui.chat.push(`[SERVER]: ${player.name} has joined the server!`); | |||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | |||
= | {{ClientsideCsJsEvent}} | ||
{{CSharpContainer| | |||
<syntaxhighlight lang="c#"> | |||
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 for a player and hides the browser when it is created. | |||
<syntaxhighlight lang="c#"> | |||
Events.OnPlayerJoin += OnPlayerJoin; | |||
<syntaxhighlight lang=" | </syntaxhighlight> | ||
<syntaxhighlight lang="c#"> | |||
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
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# 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