From b621fb511f5048968434475e4ebc7f4d012626aa Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Mon, 29 Dec 2014 20:21:57 +0100 Subject: Added player count to webadmin Now it shows the number of online players near the memory use --- MCServer/webadmin/template.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'MCServer/webadmin') diff --git a/MCServer/webadmin/template.lua b/MCServer/webadmin/template.lua index 4d3934da8..416657c4b 100644 --- a/MCServer/webadmin/template.lua +++ b/MCServer/webadmin/template.lua @@ -52,12 +52,21 @@ end +function GetTotalPlayers() + Players=0 + local EachPlayer = function(Player) + Players = Players + 1 + end + cRoot:Get():ForEachPlayer(EachPlayer) + return Players +end function ShowPage(WebAdmin, TemplateRequest) SiteContent = {} local BaseURL = WebAdmin:GetBaseURL(TemplateRequest.Request.Path) local Title = "MCServer WebAdmin" + local NumPlayers = GetTotalPlayers() local MemoryUsageKiB = cRoot:GetPhysicalRAMUsage() local NumChunks = cRoot:Get():GetTotalChunkCount() local PluginPage = WebAdmin:GetPage(TemplateRequest.Request) @@ -102,6 +111,7 @@ function ShowPage(WebAdmin, TemplateRequest)
-- cgit v1.2.3 From 48b0f4daa4fe190e48b2d2652a79c3f2c14c31b5 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Tue, 30 Dec 2014 10:31:16 +0100 Subject: Use cRoot:Get():GetServer():GetNumPlayers() instead of a custom function. --- MCServer/webadmin/template.lua | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'MCServer/webadmin') diff --git a/MCServer/webadmin/template.lua b/MCServer/webadmin/template.lua index 416657c4b..6ea7b69bc 100644 --- a/MCServer/webadmin/template.lua +++ b/MCServer/webadmin/template.lua @@ -52,21 +52,13 @@ end -function GetTotalPlayers() - Players=0 - local EachPlayer = function(Player) - Players = Players + 1 - end - cRoot:Get():ForEachPlayer(EachPlayer) - return Players -end function ShowPage(WebAdmin, TemplateRequest) SiteContent = {} local BaseURL = WebAdmin:GetBaseURL(TemplateRequest.Request.Path) local Title = "MCServer WebAdmin" - local NumPlayers = GetTotalPlayers() + local NumPlayers = cRoot:Get():GetServer():GetNumPlayers() local MemoryUsageKiB = cRoot:GetPhysicalRAMUsage() local NumChunks = cRoot:Get():GetTotalChunkCount() local PluginPage = WebAdmin:GetPage(TemplateRequest.Request) -- cgit v1.2.3