Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local admin = {
- ['Amanda#0125'] = true,
- ['Fly#8215'] = true
- }
- local players = { }
- --[[
- • Insira mapas na tabela maps sem o caractere '@':
- maps = { 123, 654321, 61 }
- ]]
- local maps = { COLOQUE OS MAPAS AQUI}
- local game_is_started, game_is_ended = false, false
- local player_list_text = "<p align='center'><font size='14'><j>Participantes</j></font>\n\n"
- local round_first_winner = ''
- local game_winner = ''
- local game_default_time = 601 -- Tempo do jogo em milissegundos
- local current_map_index = 1
- --[[ Disable ]]--
- for _, v in next, {'AutoShaman', 'AutoNewGame', 'AutoTimeLeft', 'AutoScore', 'AfkDeath', 'PhysicalConsumables'} do
- tfm.exec['disable' .. v]()
- end
- system.disableChatCommandDisplay()
- --[[ Functions Lib ]]--
- local function string_split(str, char)
- local a = {}
- string.gsub(str, '[^' .. char .. ']+', function(b)
- a[#a + 1] = b
- end)
- return a
- end
- local function init()
- players = { }
- game_is_started, game_is_ended = false, false
- game_winner = ''
- current_map_index = 1
- tfm.exec.newGame(0)
- end
- local function display_player_list(target)
- ui.addTextArea(1, player_list_text, target, 5, 25, 200, 365, nil, 0, .8)
- end
- local function update_player_list(target)
- local text = player_list_text
- local t = { };for k, v in next, players do t[#t + 1] = { k, v } end
- table.sort(t, function(a, b) return a[2] > b[2] end)
- for i = 1, #t do
- local name, score = t[i][1], t[i][2]
- local score_str = ''
- local tag = (target == name) and '<v>' or '<n>'
- if (game_is_started) then
- score_str = score_str .. string.format(': <j>%s ponto(s)', score)
- end
- text = text .. string.format('%s%s%s', tag, name, score_str) .. '\n'
- end
- ui.updateTextArea(1, text, target)
- end
- local function new_player(player)
- if (not players[player]) then
- players[player] = 0
- if (not game_is_started) then
- ui.removeTextArea(0, player)
- table.foreach(tfm.get.room.playerList, update_player_list)
- end
- end
- end
- local function get_next_map()
- _next = maps[current_map_index]
- if (_next) then
- return _next
- end
- return false
- end
- local function start_game()
- game_is_started = true
- tfm.exec.newGame(get_next_map())
- end
- function eventNewPlayer(player)
- if (not game_is_started and not game_is_ended) then
- display_player_list(target)
- ui.addTextArea(0, "<p align='center'><a href='event:entry'><j>Participar", player, 325, 25, 150, 20, 0x324650, 0, .8)
- table.foreach(tfm.get.room.playerList, update_player_list)
- end
- end
- function eventNewGame()
- round_first_winner = ''
- if (game_is_started) then
- tfm.exec.setGameTime(game_default_time)
- if (tfm.get.room.currentMap ~= maps[current_map_index]) then
- current_map_index = (current_map_index + 1)
- end
- for k in next, tfm.get.room.playerList do
- if (players[k]) then
- tfm.exec.setNameColor(k, 0xFFFFFF)
- else
- tfm.exec.killPlayer(k)
- end
- end
- for i = -1, 1 do
- ui.removeTextArea(i)
- end
- return
- elseif (game_is_ended) then
- tfm.exec.setNameColor(game_winner, 0x00FF00)
- tfm.exec.setGameTime(9e5)
- for k in next, tfm.get.room.playerList do
- if (k ~= game_winner) then
- tfm.exec.killPlayer(k)
- end
- end
- return
- end
- for k in next, tfm.get.room.playerList do
- tfm.exec.setPlayerScore(k, 0)
- if (admin[k]) then
- ui.addTextArea(-1, "<p align='center'><a href='event:start'><j>Começar", k, 645, 25, 150, 20, 0x324650, 0, .8)
- end
- end
- ui.addTextArea(0, "<p align='center'><a href='event:entry'><j>Participar", nil, 325, 25, 150, 20, 0x324650, 0, .8)
- display_player_list()
- end
- function eventLoop(elapsed, remaining)
- if (elapsed <= 1000) then
- tfm.exec.playEmote(game_winner, 0)
- end
- if (remaining <= 0) then
- if (game_is_started) then
- if (round_first_winner ~= '') then
- tfm.exec.newGame(get_next_map())
- else
- tfm.exec.newGame(tfm.get.room.currentMap)
- end
- elseif (game_is_ended) then
- tfm.exec.newGame('<C><P /><Z><S><S i="-200,-250,16692e791eb.png" P=",,9999,,,,," L="400" H="10" Y="270" T="14" X="400" /><S P=",,9999,,,,," i="-66,-20,1669252905c.png" L="200" H="10" Y="300" T="14" X="400" /></S><D><DS Y="300" X="400" /></D><O /></Z></C>')
- end
- end
- end
- function eventChatCommand(player, command)
- local command = string_split(command, ' ')
- --[[ Admin ]]--
- if (not admin[player]) then return end
- if (command[1] == 'np') then
- if (command[2]) then
- tfm.exec.newGame(command[2])
- return
- end
- tfm.exec.newGame(get_next_map())
- elseif (command[1] == 'add') then
- local _player = command[2]
- if (not _player) then return end
- if (tfm.get.room.playerList[_player]) then
- new_player(_player)
- end
- end
- end
- function eventPlayerWon(player)
- if (game_is_started) then
- if (round_first_winner == '') then
- round_first_winner = player
- tfm.exec.setGameTime(4, false)
- local player_score = players[player]
- if (player_score) then
- players[player] = (player_score + 10)
- tfm.exec.setPlayerScore(player, (player_score + 10))
- if (not get_next_map()) then
- game_is_started, game_is_ended = false, true
- for k in next, admin do
- ui.addTextArea(-1, "<p align='center'><a href='event:restart'><j>Reiniciar", k, 645, 25, 150, 20, 0x324650, 0, .8)
- end
- local t = { };for k, v in next, players do t[#t + 1] = { k, v } end
- table.sort(t, function(a, b) return a[2] > b[2] end)
- game_winner = t[1][1]
- return ui.addTextArea(1, string.format("<p align='center'><font size='37'>%s É O VENCEDOR. GG</font></font></p>", game_winner), nil, 5, 170, 800, nil, 0, 0, 0, true)
- end
- end
- display_player_list()
- table.foreach(tfm.get.room.playerList, update_player_list)
- end
- end
- end
- function eventPlayerDied(player)
- if (game_is_started) then
- for k, v in next, tfm.get.room.playerList do
- if (players[k]) then
- tfm.exec.respawnPlayer(k)
- end
- end
- end
- end
- function eventTextAreaCallback(_, player, callback)
- if (callback == 'entry') then
- new_player(player)
- elseif (callback == 'start') then
- if (#maps == 0) then
- return ui.addPopup(0, 0, '[Erro] A tabela maps está vazia.', player)
- end
- start_game()
- elseif (callback == 'restart') then
- init()
- end
- end
- init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement