OnPlayerJoined: Difference between revisions

From GTA Connected
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{ScriptItem
{{ScriptItem2
|endpoint = shared
|name = OnPlayerJoined
|side = server
|type = event
|type = event
|name = onPlayerJoined
|games = iii vc sa iv
|usage = a player has connected to the server
|desc = a player has connected to the server
|callbackParameters = Event event, Client client
|arg1 = Client client The client that has connected to the server.
|cancellable = false
|note = {{Shared/PlayerConnectionEvents}}
|parameter1 = Client client The client that has connected to the server.
|cancel = false
|notes = {{Shared/PlayerConnectionEvents}}
|exampleJS = addEventHandler('OnPlayerJoined', (event, client) => {
messageClient(`Hello ${client.name}, welcome to my server! 👋`, client, COLOUR_YELLOW);
});
|exampleLua = addEventHandler('OnPlayerJoined', function(event, client)
messageClient('Hello ' .. client.name .. ', welcome to my server! 👋', client, COLOUR_YELLOW)
end)
}}
}}

Latest revision as of 12:29, 2 September 2023

Event Server Only icon-iii.png icon-vc.png icon-sa.png icon-iv.png 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:
  1. OnPlayerConnect
  2. OnPlayerJoin
  3. 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

icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnPlayerChat
icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnPlayerCommand
icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnPlayerConnect
icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnPlayerJoin
icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnPlayerJoined
icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnPlayerQuit