SHARE
TWEET

Untitled

a guest Feb 27th, 2020 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local admin = {
  2.     ['Amanda#0125'] = true,
  3.     ['Fly#8215'] = true
  4. }
  5.  
  6. local players = { }
  7.  
  8. --[[
  9.     • Insira mapas na tabela maps sem o caractere '@':
  10.         maps = { 123, 654321, 61 }
  11. ]]
  12. local maps = { COLOQUE OS MAPAS AQUI}
  13.  
  14. local game_is_started, game_is_ended = false, false
  15.  
  16. local player_list_text = "<p align='center'><font size='14'><j>Participantes</j></font>\n\n"
  17. local round_first_winner = ''
  18. local game_winner = ''
  19.  
  20. local game_default_time = 601 -- Tempo do jogo em milissegundos
  21. local current_map_index = 1
  22.  
  23. --[[ Disable ]]--
  24. for _, v in next, {'AutoShaman', 'AutoNewGame', 'AutoTimeLeft', 'AutoScore', 'AfkDeath', 'PhysicalConsumables'} do
  25.     tfm.exec['disable' .. v]()
  26. end
  27.  
  28. system.disableChatCommandDisplay()
  29.  
  30. --[[ Functions Lib ]]--
  31. local function string_split(str, char)
  32.     local a = {}
  33.  
  34.     string.gsub(str, '[^' .. char .. ']+', function(b)
  35.         a[#a + 1] = b
  36.     end)
  37.  
  38.     return a
  39. end
  40.  
  41. local function init()
  42.     players = { }
  43.  
  44.     game_is_started, game_is_ended = false, false
  45.  
  46.     game_winner = ''
  47.  
  48.     current_map_index = 1
  49.  
  50.     tfm.exec.newGame(0)
  51. end
  52.  
  53. local function display_player_list(target)
  54.     ui.addTextArea(1, player_list_text, target, 5, 25, 200, 365, nil, 0, .8)
  55. end
  56.  
  57. local function update_player_list(target)
  58.     local text = player_list_text
  59.  
  60.     local t = { };for k, v in next, players do t[#t + 1] = { k, v } end
  61.     table.sort(t, function(a, b) return a[2] > b[2] end)
  62.  
  63.     for i = 1, #t do
  64.         local name, score = t[i][1], t[i][2]
  65.  
  66.         local score_str = ''
  67.  
  68.         local tag = (target == name) and '<v>' or '<n>'
  69.  
  70.         if (game_is_started) then
  71.             score_str = score_str .. string.format(': <j>%s ponto(s)', score)
  72.         end
  73.  
  74.         text = text .. string.format('%s%s%s', tag, name, score_str) .. '\n'
  75.     end
  76.  
  77.     ui.updateTextArea(1, text, target)
  78. end
  79.  
  80. local function new_player(player)
  81.     if (not players[player]) then
  82.         players[player] = 0
  83.  
  84.         if (not game_is_started) then
  85.             ui.removeTextArea(0, player)
  86.  
  87.             table.foreach(tfm.get.room.playerList, update_player_list)
  88.         end
  89.     end
  90. end
  91.  
  92. local function get_next_map()
  93.     _next = maps[current_map_index]
  94.     if (_next) then
  95.         return _next
  96.     end
  97.  
  98.     return false
  99. end
  100.  
  101. local function start_game()
  102.     game_is_started = true
  103.  
  104.     tfm.exec.newGame(get_next_map())
  105. end
  106.  
  107. function eventNewPlayer(player)
  108.     if (not game_is_started and not game_is_ended) then
  109.         display_player_list(target)
  110.  
  111.         ui.addTextArea(0, "<p align='center'><a href='event:entry'><j>Participar", player, 325, 25, 150, 20, 0x324650, 0, .8)
  112.  
  113.         table.foreach(tfm.get.room.playerList, update_player_list)
  114.     end
  115. end
  116.  
  117. function eventNewGame()
  118.     round_first_winner = ''
  119.  
  120.     if (game_is_started) then
  121.         tfm.exec.setGameTime(game_default_time)
  122.  
  123.         if (tfm.get.room.currentMap ~= maps[current_map_index]) then
  124.             current_map_index = (current_map_index + 1)
  125.         end
  126.  
  127.         for k in next, tfm.get.room.playerList do
  128.             if (players[k]) then
  129.                 tfm.exec.setNameColor(k, 0xFFFFFF)
  130.             else
  131.                 tfm.exec.killPlayer(k)
  132.             end
  133.         end
  134.  
  135.         for i = -1, 1 do
  136.             ui.removeTextArea(i)
  137.         end
  138.  
  139.         return
  140.     elseif (game_is_ended) then
  141.         tfm.exec.setNameColor(game_winner, 0x00FF00)
  142.         tfm.exec.setGameTime(9e5)
  143.  
  144.         for k in next, tfm.get.room.playerList do
  145.             if (k ~= game_winner) then
  146.                 tfm.exec.killPlayer(k)
  147.             end
  148.         end
  149.  
  150.         return
  151.     end
  152.  
  153.     for k in next, tfm.get.room.playerList do
  154.         tfm.exec.setPlayerScore(k, 0)
  155.  
  156.         if (admin[k]) then
  157.             ui.addTextArea(-1, "<p align='center'><a href='event:start'><j>Começar", k, 645, 25, 150, 20, 0x324650, 0, .8)
  158.         end
  159.     end
  160.  
  161.     ui.addTextArea(0, "<p align='center'><a href='event:entry'><j>Participar", nil, 325, 25, 150, 20, 0x324650, 0, .8)
  162.  
  163.     display_player_list()
  164. end
  165.  
  166. function eventLoop(elapsed, remaining)
  167.     if (elapsed <= 1000) then
  168.         tfm.exec.playEmote(game_winner, 0)
  169.     end
  170.  
  171.     if (remaining <= 0) then
  172.         if (game_is_started) then
  173.             if (round_first_winner ~= '') then
  174.                 tfm.exec.newGame(get_next_map())
  175.             else
  176.                 tfm.exec.newGame(tfm.get.room.currentMap)
  177.             end
  178.         elseif (game_is_ended) then
  179.             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>')
  180.         end
  181.     end
  182. end
  183.  
  184. function eventChatCommand(player, command)
  185.     local command = string_split(command, ' ')
  186.  
  187.     --[[ Admin ]]--
  188.     if (not admin[player]) then return end
  189.  
  190.     if (command[1] == 'np') then
  191.         if (command[2]) then
  192.             tfm.exec.newGame(command[2])
  193.  
  194.             return
  195.         end
  196.  
  197.         tfm.exec.newGame(get_next_map())
  198.     elseif (command[1] == 'add') then
  199.         local _player = command[2]
  200.         if (not _player) then return end
  201.  
  202.         if (tfm.get.room.playerList[_player]) then
  203.             new_player(_player)
  204.         end
  205.     end
  206. end
  207.  
  208. function eventPlayerWon(player)
  209.     if (game_is_started) then
  210.         if (round_first_winner == '') then
  211.             round_first_winner = player
  212.  
  213.             tfm.exec.setGameTime(4, false)
  214.  
  215.             local player_score = players[player]
  216.             if (player_score) then
  217.                 players[player] = (player_score + 10)
  218.                 tfm.exec.setPlayerScore(player, (player_score + 10))
  219.  
  220.                 if (not get_next_map()) then
  221.                     game_is_started, game_is_ended = false, true
  222.  
  223.                     for k in next, admin do
  224.                         ui.addTextArea(-1, "<p align='center'><a href='event:restart'><j>Reiniciar", k, 645, 25, 150, 20, 0x324650, 0, .8)
  225.                     end
  226.  
  227.                     local t = { };for k, v in next, players do t[#t + 1] = { k, v } end
  228.                     table.sort(t, function(a, b) return a[2] > b[2] end)
  229.                     game_winner = t[1][1]
  230.  
  231.                     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)
  232.                 end
  233.             end
  234.  
  235.             display_player_list()
  236.             table.foreach(tfm.get.room.playerList, update_player_list)
  237.         end
  238.     end
  239. end
  240.  
  241. function eventPlayerDied(player)
  242.     if (game_is_started) then
  243.         for k, v in next, tfm.get.room.playerList do
  244.             if (players[k]) then
  245.                 tfm.exec.respawnPlayer(k)
  246.             end
  247.         end
  248.     end
  249. end
  250.  
  251. function eventTextAreaCallback(_, player, callback)
  252.     if (callback == 'entry') then
  253.         new_player(player)
  254.     elseif (callback == 'start') then
  255.         if (#maps == 0) then
  256.             return ui.addPopup(0, 0, '[Erro] A tabela maps está vazia.', player)
  257.         end
  258.  
  259.         start_game()
  260.     elseif (callback == 'restart') then
  261.         init()
  262.     end
  263. end
  264.  
  265. init()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top