Professional Documents
Culture Documents
local players = {}
-- [[ Disable ]] --
system.disableChatCommandDisplay(nil)
-- [[ Functions Lib ]] --
local split = function(str, s)
local res = {}
for part in string.gmatch(str, "[^" .. s .. "]+") do
table.insert(res, part)
end
return res
end
n = (n + 1)
if (n >= 10) then
i = (i + 1);list[i] = "<p align='center'>"
n = 1
id = (id + 1)
else
text = (kicking and "<a href='event:" .. k .. "'>" or '') ..
nick .. tag .. '\n'
end
local x = 6
for i = 1, #list do
addTextArea(i, list[i], name, x, 80, 180, 310, 0x324650, 0x000000, .8,
true)
if (kicking) then
addTextArea(0, "<p align='center'><font size='16'><b>Escolha quem
eliminar", name, 5, 25, 790, 25, 0x324650, 0, .8)
end
return #list
end
end
showPlayers(nil)
end
-- [[ API Functions ]] --
function eventNewPlayer(name)
if (not startGame) then
local text = "<p align='center'><j>Você está participando."
if (not players[name]) then
text = "<p align='center'><a href='event:entry'><j>Participar"
end
tfm.exec.setPlayerScore(name, 0)
end
table.foreach(tfm.get.room.playerList, eventNewPlayer)
function eventNewGame()
canFinish = false
kicking = false
mapWinner = ''
if (startGame) then
ui.removeTextArea(0);local a = showPlayers('?', false);for b = 1, a do
ui.removeTextArea(b, name) end
tfm.exec.setGameTime(63)
for i = 1, #players[roundWinner] do
local nick, tag = '<n>' .. players[roundWinner]
[i]:match('(.-)#[0-9]+$'), "<ch><font size='9'>" .. players[roundWinner]
[i]:match('#[0-9]+$')
text = text .. nick .. tag .. (i < #players[roundWinner]
and '<n>,</n> ' or '<n>.</n>')
end
tfm.exec.setGameTime(30)
end
end
else
players = {}
tfm.exec.setGameTime(99999)
end
mapName = (tfm.get.room.xmlMapInfo.author ~= '#Module' and
tfm.get.room.xmlMapInfo.author or mapName)
mapCode = tfm.get.room.currentMap or mapCode
ui.setMapName('<j>' .. mapName .. ' <bl>- ' .. mapCode .. ' <g>|
<n>Competidores : <v>' .. playersInGame .. '/' .. maxPlayers)
end
start()
return
end
if (startGame) then
if (canFinish and roundWinner ~= '') then
finishGame = true
start()
end
end
end
function eventPlayerWon(name)
if (startGame) then
if (mapWinner == '') then
mapWinner = name
local a = 0
for k in next, players do
a = (a + 1)
end
if (a > 2) then
kicking = true
tfm.exec.setGameTime(10, false)
showPlayers(name)
else
for k in next, players do
if (k ~= name) then
players[k] = nil
break
end
end
canFinish = true
roundWinner = name
tfm.exec.setGameTime(4, false)
end
tfm.exec.setPlayerScore(name, tfm.get.room.playerList[name].score + 1)
end
end
end
function eventPlayerDied(name)
local t = {}
for i = 1, #t do
if (players[t[i]]) then
return
end
end
if (startGame) then
tfm.exec.newGame('#17')
end
end
function eventPlayerLeft(name)
if (players[name]) then
players[name] = nil
if (kicking) then
showPlayers(mapWinner)
end
end
function eventChatCommand(name, cmd)
cmd = split(cmd, ' ')
-- [[ Adm Commands ]] --
if (perm[name]) then
if (cmd[1] == 'start') then
local a = playersInGame
if (a > 1) then
for i = -1, a do
ui.removeTextArea(i)
end
startGame = true
tfm.exec.newGame('#17')
end
end
end
end
playersInGame = (playersInGame + 1)
ui.setMapName('<j>' .. mapName .. ' <bl>- ' .. mapCode .. ' <g>|
<n>Competidores : <v>' .. playersInGame .. '/' .. maxPlayers)
ui.updateTextArea(0, '<j>Você está participando.', name)
showPlayers(nil)
end
elseif (cb == 'start') then
eventChatCommand(name, cb)
elseif (players[cb] and kicking) then
if (playersInGame > 0) then playersInGame = (playersInGame - 1) end
kicking = false
players[cb] = nil
local a = 1
for k in next, players do
a = (a + 1)
end
for i = 1, a do
ui.removeTextArea(i)
end
players[name][#players[name] + 1] = cb
tfm.exec.setGameTime(15, false)
end
end
start()