]> git.lizzy.rs Git - elidragon.git/blob - playerlist.lua
Create LICENSE
[elidragon.git] / playerlist.lua
1 elidragon.playerlist = {}
2 controls.register_on_press(function(player, key)
3         if key == "sneak" then
4                 local name = player:get_player_name()
5                 local list = {}
6                 local players = minetest.get_connected_players()
7                 for i, p in pairs(players) do
8                         local n = p:get_player_name()
9                         list[#list + 1] = player:hud_add({
10                                 hud_elem_type = "text",
11                                 position = {x = 1, y = 0},
12                                 offset = {x = -50, y = 5 + (i - 1) * 18},
13                                 text = n,
14                                 alignment = {x = -1, y = 1},
15                                 scale = {x = 100, y = 100},
16                                 number = tonumber(elidragon.get_rank(n).color:gsub("#", ""), 16),
17                         })
18                         list[#list + 1] = player:hud_add({
19                                 hud_elem_type = "image",
20                                 position = {x = 1, y = 0},
21                                 offset = {x = -5, y = (i - 1) * 18},
22                                 text = "server_ping_" .. math.ceil(4 - minetest.get_player_information(n).avg_rtt / 2 * 4) .. ".png",
23                                 alignment = {x = -1, y = 1},
24                                 scale = {x = 1.5, y = 1.5},
25                                 number = 0xFFFFFF,
26                         })
27                 end
28                 elidragon.playerlist[name] = list
29         end
30 end)
31 controls.register_on_release(function(player, key)
32         if key == "sneak" then
33                 for _, id in pairs(elidragon.playerlist[player:get_player_name()]) do
34                         player:hud_remove(id)
35                 end
36         end
37 end)