]> git.lizzy.rs Git - coronaserver.git/commitdiff
Bugfix
authorElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 4 Jun 2020 10:05:26 +0000 (12:05 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 4 Jun 2020 10:05:26 +0000 (12:05 +0200)
playerlist.lua

index 11f5dbd9b295be758119e410401701eb45c2ddc5..6478f62f26a42493042816a053774d93fb06513c 100644 (file)
@@ -6,25 +6,28 @@ controls.register_on_press(function(player, key)
                local players = minetest.get_connected_players()
                for i, p in pairs(players) do
                        local n = p:get_player_name()
-                       local ping = math.max(1, math.ceil(4 - minetest.get_player_information(n).avg_rtt * 4))
-                       list[#list + 1] = player:hud_add({
-                               hud_elem_type = "text",
-                               position = {x = 1, y = 0},
-                               offset = {x = -50, y = 5 + (i - 1) * 18},
-                               text = n,
-                               alignment = {x = -1, y = 1},
-                               scale = {x = 100, y = 100},
-                               number = tonumber(coronaserver.get_rank(n).color:gsub("#", ""), 16),
-                       })
-                       list[#list + 1] = player:hud_add({
-                               hud_elem_type = "image",
-                               position = {x = 1, y = 0},
-                               offset = {x = -5, y = (i - 1) * 18},
-                               text = "server_ping_" .. ping .. ".png",
-                               alignment = {x = -1, y = 1},
-                               scale = {x = 1.5, y = 1.5},
-                               number = 0xFFFFFF,
-                       })
+                       local info =  minetest.get_player_information(n)
+                       if info then
+                               local ping = math.max(1, math.ceil(4 - info.avg_rtt * 4))
+                               list[#list + 1] = player:hud_add({
+                                       hud_elem_type = "text",
+                                       position = {x = 1, y = 0},
+                                       offset = {x = -50, y = 5 + (i - 1) * 18},
+                                       text = n,
+                                       alignment = {x = -1, y = 1},
+                                       scale = {x = 100, y = 100},
+                                       number = tonumber(coronaserver.get_rank(n).color:gsub("#", ""), 16),
+                               })
+                               list[#list + 1] = player:hud_add({
+                                       hud_elem_type = "image",
+                                       position = {x = 1, y = 0},
+                                       offset = {x = -5, y = (i - 1) * 18},
+                                       text = "server_ping_" .. ping .. ".png",
+                                       alignment = {x = -1, y = 1},
+                                       scale = {x = 1.5, y = 1.5},
+                                       number = 0xFFFFFF,
+                               })
+                       end
                end
                coronaserver.playerlist[name] = list
        end