Add player count

This commit is contained in:
Ceda EI 2019-01-29 11:47:31 +05:30
parent f3b74b65ed
commit 149ab033b0
1 changed files with 9 additions and 1 deletions

View File

@ -1,10 +1,18 @@
local http_api = minetest.request_http_api() local http_api = minetest.request_http_api()
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
function send_messages(res) function send_messages(res)
for message in string.gmatch(res["data"], "[^\n]+") do for message in string.gmatch(res["data"], "[^\n]+") do
if message == "list" then if message == "list" then
local x = minetest.get_connected_players() local x = minetest.get_connected_players()
local text = "List of Players:\n" local text = "List of Players ("
text = text .. tostring(tablelength(x)) .. "/"
text = text .. tostring(minetest.settings:get("max_users")) .. "):"
for j, i in ipairs(x) do for j, i in ipairs(x) do
text = text .. "\n" .. i.get_player_name(i) text = text .. "\n" .. i.get_player_name(i)
end end