From e7ea352f41b867dad83d170b7382b22a46f25c49 Mon Sep 17 00:00:00 2001 From: faketruth Date: Tue, 14 Feb 2012 19:14:23 +0000 Subject: Got rid of cWorld::GetAllPlayers() and implemented ForEachPlayer() more or less in Lua Core now uses ForEachPlayer() to interact with connected players git-svn-id: http://mc-server.googlecode.com/svn/trunk@260 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- Plugins/Core/web_playerlist.lua | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'Plugins/Core/web_playerlist.lua') 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 .. "

Connected Players: " .. World:GetNumPlayers() .. "

" Content = Content .. "" + PlayerNum = 0 + PlayerHTML = "" + World:ForEachPlayer( CreatePlayerList ) - local PlayerList = World:GetAllPlayers() - if( #PlayerList > 0 ) then - for i, Player in ipairs( PlayerList ) do - Content = Content .. "" - Content = Content .. "" - Content = Content .. "" - Content = Content .. "" - Content = Content .. "" - end + if( PlayerHTML ~= "" ) then + Content = Content .. PlayerHTML else Content = Content .. "" end Content = Content .. "
" .. i .. "." .. Player:GetName() .. "Kick
None
" Content = Content .. "
" return Content +end + +function CreatePlayerList( Player, Data ) + PlayerNum = PlayerNum + 1 + PlayerHTML = PlayerHTML .. "" + PlayerHTML = PlayerHTML .. "" .. PlayerNum .. "." + PlayerHTML = PlayerHTML .. "" .. Player:GetName() .. "" + PlayerHTML = PlayerHTML .. "Kick" + PlayerHTML = PlayerHTML .. "" end \ No newline at end of file -- cgit v1.2.3