OnPlayerJoined: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{ | {{ScriptItem2 | ||
| | |name = OnPlayerJoined | ||
|side = server | |||
|type = event | |type = event | ||
| | |games = iii vc sa iv | ||
| | |desc = a player has connected to the server | ||
| | |arg1 = Client client The client that has connected to the server. | ||
|note = The chronological order of player connection events are:<br> | |||
| | |||
The chronological order of player connection events are:<br> | |||
[[OnPlayerConnect|OnPlayerConnect]]<br> | [[OnPlayerConnect|OnPlayerConnect]]<br> | ||
[[OnPlayerJoin|OnPlayerJoin]]<br> | [[OnPlayerJoin|OnPlayerJoin]]<br> | ||
[[OnPlayerJoined|OnPlayerJoined]] | [[OnPlayerJoined|OnPlayerJoined]] | ||
|exampleJS = | |cancel = false | ||
addEventHandler('OnPlayerJoined', (event, client) => { | |exampleJS = addEventHandler('OnPlayerJoined', (event, client) => { | ||
messageClient(`Hello ${client.name}, welcome to my server! 👋`, client, COLOUR_YELLOW); | messageClient(`Hello ${client.name}, welcome to my server! 👋`, client, COLOUR_YELLOW); | ||
}); | }); | ||
|exampleLua = | |exampleLua = addEventHandler('OnPlayerJoined', function(event, client) | ||
addEventHandler('OnPlayerJoined', function(event, client) | |||
messageClient('Hello ' .. client.name .. ', welcome to my server! 👋', client, COLOUR_YELLOW) | messageClient('Hello ' .. client.name .. ', welcome to my server! 👋', client, COLOUR_YELLOW) | ||
end) | end) | ||
}} | }} |
Revision as of 20:28, 19 November 2022
Event
Server Only
Online and Offline
Not Cancellable
Available since Server 1.0.0
OnPlayerJoined(Event event, Client client)
The OnPlayerJoined event is invoked when a player has connected to the server.
Parameters
1) | Event | event | The event object for this event. |
2) | Client | client | The client that has connected to the server. |
Attributes
const | This event cannot be cancelled. |
Notes
- The chronological order of player connection events are:
OnPlayerConnect
OnPlayerJoin
OnPlayerJoined.
Examples
Example 1 - JavaScript:
addEventHandler('OnPlayerJoined', (event, client) => {
messageClient(`Hello ${client.name}, welcome to my server! 👋`, client, COLOUR_YELLOW);
});
Example 2 - Lua:
addEventHandler('OnPlayerJoined', function(event, client)
messageClient('Hello ' .. client.name .. ', welcome to my server! 👋', client, COLOUR_YELLOW)
end)
Compatibility
There isn't any compatibility information for this event.
Related
Server Related
OnPlayerChat
OnPlayerCommand
OnPlayerConnect
OnPlayerJoin
OnPlayerJoined
OnPlayerQuit