3 controls.register_on_press(function(player, key)
5 local name = player:get_player_name()
7 local players = minetest.get_connected_players()
8 for i, p in pairs(players) do
9 local n = p:get_player_name()
10 local ping = math.max(1, math.ceil(4 - minetest.get_player_information(n).avg_rtt * 4))
11 list[#list + 1] = player:hud_add({
12 hud_elem_type = "text",
13 position = {x = 0.5, y = 0},
14 offset = {x = 20, y = 53 + (i - 1) * 18},
16 alignment = {x = 1, y = 1},
17 scale = {x = 100, y = 100},
20 list[#list + 1] = player:hud_add({
21 hud_elem_type = "image",
22 position = {x = 0.5, y = 0},
23 offset = {x = 0, y = 50 + (i - 1) * 18},
24 text = "server_ping_" .. ping .. ".png",
25 alignment = {x = -1, y = 1},
26 scale = {x = 1.5, y = 1.5},
30 playerlist[name] = list
34 controls.register_on_release(function(player, key)
35 if key == "sneak" and player then
36 for _, id in pairs(playerlist[player:get_player_name()]) do