试试这个:您可以直接使用mvp 和mvpp 表来计算出现次数;然后使用string.format根据需要格式化输出,但是由于可以有多个播放器,因此您可以使用table.concat组合多个播放器的输出;最后你输入ui:
function output(scores, x, y)
local out = {}
for player, score in scores do
table.insert(out, string.format("%s - %s", player, score))
end
ui.addTextArea(1,"<a href='event:closee'> ".. table.concat(out, ";") .. " </a>", NIL, 6, x,y, 50,0x1C3C41,0x1C3C41,0.9,true)
end
function eventLoop(time)
local mvp = {}
local mvpp = {}
if time < 120000 then
for name, player in pairs(tfm.get.room.playerList) do
if not player.isDead then
if TeamOne[name] then
mvp[name] = (mvp[name] or 0) + 1
end
if TeamTwo[name] then
mvpp[name] = (mvpp[name] or 0) + 1
end
end
end
end
-- now mvp = {player1 = 200, player3 = 50} for example
output(mvp, 6, 308)
output(mvpp, 406, 208)
end
实际上还有几个参数要传递给output()(比如addTextArea() 和href 名称的第一个参数),但你明白了。