OnPlayerJoin: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 2: | Line 2: | ||
This event is triggered when a player joins the server. | This event is triggered when a player joins the server. | ||
== | ==Parameters== | ||
No parameters. | |||
== | ==Source== | ||
The source of this event is the [[player]] who joined. | |||
==Example== | ==Example== | ||
Line 15: | Line 13: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- we register greetPlayer as a handler for the event | -- we register greetPlayer as a handler for the event | ||
function greetPlayer ( ) | function greetPlayer ( ) | ||
-- we store the player's name | -- we store the player's name | ||
local joinedPlayerName = getClientName ( source ) | local joinedPlayerName = getClientName ( source ) | ||
-- and send him a greeting | -- and send him a greeting | ||
outputChatBox ( "Welcome " ..joinedPlayerName.. " to the server!" , source, 255, 255, 255 ) | outputChatBox ( "Welcome " .. joinedPlayerName .. " to the server!" , source, 255, 255, 255 ) | ||
end | end | ||
addEventHandler ( "onPlayerJoin", getRootElement(), greetPlayer ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See also== | ==See also== | ||
{{Event functions}} | {{Event functions}} |
Revision as of 15:08, 15 November 2007
This event is triggered when a player joins the server.
Parameters
No parameters.
Source
The source of this event is the player who joined.
Example
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 = getClientName ( source ) -- and send him a greeting outputChatBox ( "Welcome " .. joinedPlayerName .. " to the server!" , source, 255, 255, 255 ) end addEventHandler ( "onPlayerJoin", getRootElement(), greetPlayer )
See also
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled