diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-14 20:14:23 +0100 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-14 20:14:23 +0100 |
commit | e7ea352f41b867dad83d170b7382b22a46f25c49 (patch) | |
tree | e37ed55018238c84445eb60302c825726ebaf4e9 /Plugins/Core/web_playerlist.lua | |
parent | Makefile cleanup - read COMPILING for details on *nix compilation (diff) | |
download | cuberite-e7ea352f41b867dad83d170b7382b22a46f25c49.tar cuberite-e7ea352f41b867dad83d170b7382b22a46f25c49.tar.gz cuberite-e7ea352f41b867dad83d170b7382b22a46f25c49.tar.bz2 cuberite-e7ea352f41b867dad83d170b7382b22a46f25c49.tar.lz cuberite-e7ea352f41b867dad83d170b7382b22a46f25c49.tar.xz cuberite-e7ea352f41b867dad83d170b7382b22a46f25c49.tar.zst cuberite-e7ea352f41b867dad83d170b7382b22a46f25c49.zip |
Diffstat (limited to 'Plugins/Core/web_playerlist.lua')
-rw-r--r-- | Plugins/Core/web_playerlist.lua | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/Plugins/Core/web_playerlist.lua b/Plugins/Core/web_playerlist.lua index 6c736ce3c..62ccb1d44 100644 --- a/Plugins/Core/web_playerlist.lua +++ b/Plugins/Core/web_playerlist.lua @@ -1,3 +1,6 @@ +local PlayerHTML = ""
+local PlayerNum = 0
+
function HandleRequest_PlayerList( Request )
local World = cRoot:Get():GetWorld()
local Content = ""
@@ -16,20 +19,25 @@ function HandleRequest_PlayerList( Request ) Content = Content .. "<p>Connected Players: <b>" .. World:GetNumPlayers() .. "</b></p>"
Content = Content .. "<table>"
+ PlayerNum = 0
+ PlayerHTML = ""
+ World:ForEachPlayer( CreatePlayerList )
- local PlayerList = World:GetAllPlayers()
- if( #PlayerList > 0 ) then
- for i, Player in ipairs( PlayerList ) do
- Content = Content .. "<tr>"
- Content = Content .. "<td style='width: 10px;'>" .. i .. ".</td>"
- Content = Content .. "<td>" .. Player:GetName() .. "</td>"
- Content = Content .. "<td><a href='?playerlist-kick=" .. Player:GetName() .. "'>Kick</a></td>"
- Content = Content .. "</tr>"
- end
+ if( PlayerHTML ~= "" ) then
+ Content = Content .. PlayerHTML
else
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 |