summaryrefslogtreecommitdiffstats
path: root/Plugins/Core/web_playerlist.lua
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-15 14:16:42 +0100
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-15 14:16:42 +0100
commit5e1033c567064ffc4a81ac5a2f916db98e3a50ee (patch)
tree8409761d37e1bc62ea21faa4689dd85f6bcc5063 /Plugins/Core/web_playerlist.lua
parentSlight cleanup - removed old code, some additional comments on dangerous functions (diff)
downloadcuberite-5e1033c567064ffc4a81ac5a2f916db98e3a50ee.tar
cuberite-5e1033c567064ffc4a81ac5a2f916db98e3a50ee.tar.gz
cuberite-5e1033c567064ffc4a81ac5a2f916db98e3a50ee.tar.bz2
cuberite-5e1033c567064ffc4a81ac5a2f916db98e3a50ee.tar.lz
cuberite-5e1033c567064ffc4a81ac5a2f916db98e3a50ee.tar.xz
cuberite-5e1033c567064ffc4a81ac5a2f916db98e3a50ee.tar.zst
cuberite-5e1033c567064ffc4a81ac5a2f916db98e3a50ee.zip
Diffstat (limited to 'Plugins/Core/web_playerlist.lua')
-rw-r--r--Plugins/Core/web_playerlist.lua29
1 files changed, 11 insertions, 18 deletions
diff --git a/Plugins/Core/web_playerlist.lua b/Plugins/Core/web_playerlist.lua
index 62ccb1d44..ed6b7667c 100644
--- a/Plugins/Core/web_playerlist.lua
+++ b/Plugins/Core/web_playerlist.lua
@@ -1,6 +1,3 @@
-local PlayerHTML = ""
-local PlayerNum = 0
-
function HandleRequest_PlayerList( Request )
local World = cRoot:Get():GetWorld()
local Content = ""
@@ -19,25 +16,21 @@ function HandleRequest_PlayerList( Request )
Content = Content .. "<p>Connected Players: <b>" .. World:GetNumPlayers() .. "</b></p>"
Content = Content .. "<table>"
- PlayerNum = 0
- PlayerHTML = ""
- World:ForEachPlayer( CreatePlayerList )
+ local PlayerNum = 0
+ local AddPlayerToTable = function( Player )
+ PlayerNum = PlayerNum + 1
+ Content = Content .. "<tr>"
+ Content = Content .. "<td style='width: 10px;'>" .. PlayerNum .. ".</td>"
+ Content = Content .. "<td>" .. Player:GetName() .. "</td>"
+ Content = Content .. "<td><a href='?playerlist-kick=" .. Player:GetName() .. "'>Kick</a></td>"
+ Content = Content .. "</tr>"
+ end
+ World:ForEachPlayer( AddPlayerToTable )
- if( PlayerHTML ~= "" ) then
- Content = Content .. PlayerHTML
- else
+ if( PlayerNum == 0 ) then
Content = Content .. "<tr><td>None</td></tr>"
end
Content = Content .. "</table>"
Content = Content .. "<br>"
return Content
-end
-
-function CreatePlayerList( Player, Data )
- PlayerNum = PlayerNum + 1
- PlayerHTML = PlayerHTML .. "<tr>"
- PlayerHTML = PlayerHTML .. "<td style='width: 10px;'>" .. PlayerNum .. ".</td>"
- PlayerHTML = PlayerHTML .. "<td>" .. Player:GetName() .. "</td>"
- PlayerHTML = PlayerHTML .. "<td><a href='?playerlist-kick=" .. Player:GetName() .. "'>Kick</a></td>"
- PlayerHTML = PlayerHTML .. "</tr>"
end \ No newline at end of file