Fix crash when player leaves b4 msg disappears

This commit is contained in:
Wuzzy 2016-11-12 19:16:33 +01:00
parent 374f494c02
commit 4e1570dd26
1 changed files with 12 additions and 0 deletions

View File

@ -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)