Fix crash when player leaves b4 msg disappears
This commit is contained in:
parent
374f494c02
commit
4e1570dd26
12
init.lua
12
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user