OnPlayerJoined: Difference between revisions

From GTA Connected
Jump to navigation Jump to search
(Since the event doesn't exist client-side, I made it server-side only. I also added an example)
No edit summary
Line 7: Line 7:
|cancellable = false
|cancellable = false
|parameter1 = Client client The client that has connected to the server.
|parameter1 = Client client The client that has connected to the server.
|notes = {{Shared/PlayerConnectionEvents}}
|notes =  
The chronological order of player connection events are:<br>
[[OnPlayerConnect|OnPlayerConnect]]<br>
[[OnPlayerJoin|OnPlayerJoin]]<br>
[[OnPlayerJoined|OnPlayerJoined]]
|exampleJSSS =  
|exampleJSSS =  
addEventHandler('OnPlayerJoined', (event, client) => {
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);
});
});
|exampleLuaSS =
addEventHandler('OnPlayerJoined', function(event, client)
messageClient('Hello ' .. client.name .. ', welcome to my server! 👋', client, COLOUR_YELLOW)
end)
}}
}}

Revision as of 15:22, 12 August 2021

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

function(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

Examples

Example 1 - JavaScript - Server-Side:

addEventHandler('OnPlayerJoined', (event, client) => { messageClient(`Hello ${client.name}, welcome to my server! 👋`, client, COLOUR_YELLOW); });


Example 2 - Lua - Server-Side:

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