OnPlayerConnect
The handshake is done and the client is loading the level.
The player has a name and an address and no position yet; they are not in the world until OnPlayerSpawn. The server
remembers nothing about them from earlier visits: a mode with a database looks the name up here (or the
player’s id). Names are not unique - two players may join under one; a mode whose accounts are names turns
the second one away here with Kick. Also
called for everyone on the server after a reload - the place to make the mode’s admins again
(SetPlayerAdmin).
Syntax
Section titled “Syntax”function OnPlayerConnect(pid) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | the player |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”function OnPlayerConnect(pid) SendClientMessage(pid, COLOR_SERVER, "Welcome, " .. GetPlayerName(pid) .. ". /help for the commands.") SendClientMessageToAll(COLOR_SERVER, GetPlayerName(pid) .. " joined") if admins[GetPlayerName(pid):lower()] then SetPlayerAdmin(pid, true) endendSee also
Section titled “See also”OnPlayerRequestSpawn · OnPlayerDisconnect · SetPlayerAdmin · GetDatabase · the Players group of the index
