Skip to content

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).

function OnPlayerConnect(pid)
-- ...
end
Parameter Type
pid number the player

nothing

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) end
end

OnPlayerRequestSpawn · OnPlayerDisconnect · SetPlayerAdmin · GetDatabase · the Players group of the index