Move on join and on leave messages to lua (#4460)

This commit is contained in:
Xunto 2016-08-22 22:21:48 +04:00 committed by Nils Dagsson Moskopp
parent cae4272b18
commit bf33a189da
Signed by: erle
GPG Key ID: A3BC671C35191080
1 changed files with 11 additions and 3 deletions

View File

@ -87,11 +87,19 @@ end
local player_list = {}
core.register_on_joinplayer(function(player)
player_list[player:get_player_name()] = player
local player_name = player:get_player_name()
player_list[player_name] = player
core.chat_send_all("*** " .. player_name .. " joined the game.")
end)
core.register_on_leaveplayer(function(player)
player_list[player:get_player_name()] = nil
core.register_on_leaveplayer(function(player, timed_out)
local player_name = player:get_player_name()
player_list[player_name] = nil
local announcement = "*** " .. player_name .. " left the game."
if timed_out then
announcement = announcement .. " (timed out)"
end
core.chat_send_all(announcement)
end)
function core.get_connected_players()