mirror of
https://github.com/minetest/minetest.git
synced 2024-12-23 14:42:24 +01:00
Move on join and on leave messages to lua (#4460)
This commit is contained in:
parent
cafa400fa5
commit
0b0075e6ad
@ -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()
|
||||
|
@ -1118,23 +1118,6 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id)
|
||||
if(!m_simple_singleplayer_mode) {
|
||||
// Send information about server to player in chat
|
||||
SendChatMessage(peer_id, getStatusString());
|
||||
|
||||
// Send information about joining in chat
|
||||
{
|
||||
std::string name = "unknown";
|
||||
Player *player = m_env->getPlayer(peer_id);
|
||||
if(player != NULL)
|
||||
name = player->getName();
|
||||
|
||||
std::wstring message;
|
||||
message += L"*** ";
|
||||
message += narrow_to_wide(name);
|
||||
message += L" joined the game.";
|
||||
SendChatMessage(PEER_ID_INEXISTENT,message);
|
||||
if (m_admin_chat)
|
||||
m_admin_chat->outgoing_queue.push_back(
|
||||
new ChatEventNick(CET_NICK_ADD, name));
|
||||
}
|
||||
}
|
||||
Address addr = getPeerAddress(player->peer_id);
|
||||
std::string ip_str = addr.serializeString();
|
||||
@ -2660,19 +2643,6 @@ void Server::DeleteClient(u16 peer_id, ClientDeletionReason reason)
|
||||
|
||||
Player *player = m_env->getPlayer(peer_id);
|
||||
|
||||
// Collect information about leaving in chat
|
||||
{
|
||||
if(player != NULL && reason != CDR_DENY)
|
||||
{
|
||||
std::wstring name = narrow_to_wide(player->getName());
|
||||
message += L"*** ";
|
||||
message += name;
|
||||
message += L" left the game.";
|
||||
if(reason == CDR_TIMEOUT)
|
||||
message += L" (timed out)";
|
||||
}
|
||||
}
|
||||
|
||||
/* Run scripts and remove from environment */
|
||||
{
|
||||
if(player != NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user