ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server events
  3. onPlayerJoin

Event

onPlayerJoin

ServerPlayersIdentical to MTA:SA

A player joined the server. A good place for a greeting, login and the first spawn.

Handler

addEventHandler("onPlayerJoin", root, function() ... end)

Source

source is the player who joined the server.

Example

addEventHandler("onPlayerJoin", root, function()
    outputChatBox(getPlayerName(source) .. " joined the game.", root, 140, 196, 232)
    spawnPlayer(source, 2495.3, -1687.0, 13.5)
end)

Notes

Good to know. The event arrives when the player is already an element on the server but is not in the world yet. To reject a connection before joining (e.g. a bad nickname), use onPlayerConnect and cancelEvent(true, reason).

See also