A leave message¶
This plugin prints a message in the console whenever a player leaves.
main.lua
plugin.registerEvent("PlayerQuitEvent", function(event)
local player = event:getPlayer()
logger.info(player:getName() .. " left the server.")
end)
How it works¶
It looks just like the join event, only with a different event name: PlayerQuitEvent happens when a player leaves. Events come in all kinds, and they all work the same way, so learning one teaches you the rest.
This time we use logger.info instead of sendMessage. The player has already left, so there's nobody to send a message to, and the console is the place to see it.
Try it¶
Join your server, leave, and look at the console for your name.
That's all six. Next, put them all together into one plugin.