onPlayerJoin | Multi Theft Auto: Wiki Skip to content

onPlayerJoin

Client-side
Server-side
Shared

This event is triggered when a player joins the server. This event is not cancellable.

Parameters

This event does not pass any parameters to the handler function.

Source

element: The source of this event is the player who joined.

Code Examples

server

This example gets the joined client's name and sends him a welcome message including his name.

-- we register greetPlayer as a handler for the event
function greetPlayer ( )
-- we store the player's name
local joinedPlayerName = getPlayerName ( source )
local serverName = getServerName( )
-- and send him a greeting
outputChatBox ( "Welcome " .. joinedPlayerName .. " to ".. serverName .."!" , source, 255, 255, 255 )
end
addEventHandler ( "onPlayerJoin", root, greetPlayer )

See Also