From 4e1570dd2601a7c2302007526065c70704ee8efd Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 12 Nov 2016 19:16:33 +0100 Subject: [PATCH] Fix crash when player leaves b4 msg disappears --- init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/init.lua b/init.lua index 3677223..1379dbb 100644 --- a/init.lua +++ b/init.lua @@ -75,7 +75,13 @@ cmsg.push_message_player = function(player, text) local text = tbl.text -- Horrible Workaround code ends here + if not player then + return + end local pname = player:get_player_name() + if (not pname) then + return + end if cmsg.hudids[pname] == nil then cmsg.hudids[pname] = player:hud_add({ hud_elem_type = "text", @@ -97,7 +103,13 @@ cmsg.push_message_player = function(player, text) end minetest.after(cmsg.settings.display_time, function(param) + if not param.player then + return + end local pname = param.player:get_player_name() + if (not pname) or (not cmsg.messages[pname]) then + return + end for i=1, #cmsg.messages[pname] do if param.msgid == cmsg.messages[pname][i].msgid then table.remove(cmsg.messages[pname], i) -- 2.11.4.GIT