Advertisement
VincentJonathan

Untitled

Jul 22nd, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.98 KB | None | 0 0
  1. tfm.exec.disableAutoShaman()
  2. tfm.exec.disableAutoNewGame()
  3. tfm.exec.disableAutoTimeLeft()
  4. tfm.exec.disablePhysicalConsumables(true)
  5. tfm.exec.disableAfkDeath(true)
  6.  
  7. local ADMINISTRADOR = "Owl#3124" -- CHANGE TO YOUR NICKNAME, SO YOU WILL BE GAME ADMIN
  8. local WINS = 10 -- POINTS TO WIN THE GAME
  9.  
  10. --[[
  11. After running the script, use the command !team1 Players and !team2 Players to set both players in the specified team
  12. Then you just need to press GO!
  13. Type !score team1/team2 number to change its score.
  14. Type !skip to skip to the next map
  15. ]]
  16.  
  17. local teams = {
  18.     [1] = {},
  19.     [2] = {},
  20. }
  21. local points = {
  22.     [1] = 0,
  23.     [2] = 0,
  24. }
  25. local isfirst = false
  26. local gameRunning = false
  27. local winTime = false
  28. local playersInGame = {}
  29. local colors = {
  30.     [1] = "ff6347",
  31.     [2] = "19b5fe"
  32. }
  33.  
  34. function newMap()
  35.     tfm.exec.newGame("#3")
  36.     tfm.exec.setGameTime(303)
  37. end
  38.  
  39. function eventPlayerWon(player)
  40.     if not isfirst then
  41.         isfirst = true
  42.         tfm.exec.setGameTime(5)
  43.         if table.contains(teams[1], player) then
  44.             tfm.exec.setGameTime(5)
  45.             for i = 0, 3 do
  46.                 defaultEffect(9, {13}, math.random(800), math.random(400), 20)
  47.             end
  48.             points[1] = points[1]+1
  49.         elseif table.contains(teams[2], player) then
  50.             tfm.exec.setGameTime(5)
  51.             for i = 0, 3 do
  52.                 defaultEffect(9, {9}, math.random(800), math.random(400), 20)
  53.             end
  54.             points[2] = points[2]+1
  55.         else
  56.             isfirst = false
  57.         end
  58.         winner = false
  59.         if points[1] >= WINS then
  60.             winner = 1
  61.         elseif points[2] >= WINS then
  62.             winner = 2
  63.         end
  64.         if winner then
  65.             gameRunning = false
  66.             winTime = os.time()
  67.             ui.addTextArea(20, string.format("<p align='center'><font size='37' color='#000000'>TEAM %s IS THE WINNER!", winner), nil, 0, 171, 800, 500, 0, 0, 0, true)
  68.             ui.addTextArea(21, string.format("<p align='center'><font size='37' color='#000000'>TEAM %s IS THE WINNER!", winner), nil, 1, 170, 800, 500, 0, 0, 0, true)
  69.             ui.addTextArea(22, string.format("<p align='center'><font size='37' color='#%s'>TEAM %s IS THE WINNER!", colors[winner], winner), nil, 1, 170, 800, 500, 0, 0, 0, true)
  70.         end
  71.         displayScore()
  72.     end
  73. end
  74.  
  75. function eventLoop(elapsed, remain)
  76.     if gameRunning then
  77.         remain = remain/1000
  78.         if remain < 0 then
  79.             remain = 100
  80.             newMap()
  81.         end
  82.     else
  83.         if winTime then
  84.             if winTime > os.time()-30000 then
  85.                 for i = 0, 2 do
  86.                     defaultEffect(9, {11, 9, 0, 13}, math.random(800), math.random(400), 80)
  87.                 end
  88.             else
  89.                 winTime = false
  90.                 ui.removeTextArea(20)
  91.                 ui.removeTextArea(21)
  92.                 ui.removeTextArea(22)
  93.                 displayTeams()
  94.                 teams = {
  95.                     [1] = {},
  96.                     [2] = {},
  97.                 }
  98.                 points = {
  99.                     [1] = 0,
  100.                     [2] = 0,
  101.                 }
  102.                 playersInGame = {}
  103.             end
  104.         end
  105.     end
  106. end
  107.  
  108. function eventChatCommand(player, command)
  109.     if player:lower() == ADMINISTRADOR:lower() then
  110.         args = string.split(command, " ")
  111.         if args[1] == "team1" then
  112.             table.remove(args, 1)
  113.             teams[1] = {}
  114.             points[1] = 0
  115.             for index, player in pairs(args) do
  116.                 table.insert(teams[1], player)
  117.                 playersInGame[player] = true
  118.             end
  119.             displayTeams()
  120.  
  121.         elseif args[1] == "team2" then
  122.             table.remove(args, 1)
  123.             teams[2] = {}
  124.             points[2] = 0
  125.             for index, player in pairs(args) do
  126.                 table.insert(teams[2], player)
  127.                 playersInGame[player] = true
  128.             end
  129.             displayTeams()
  130.  
  131.         elseif args[1] == "skip" then
  132.             newMap()
  133.  
  134.         elseif args[1] == "score" then
  135.             if args[2] and args[3] then
  136.                 local team = tonumber(args[2]:match("team(%d+)") or 0)
  137.                 if team > 0 and team < 3 then
  138.                     local newScore = tonumber(args[3]) or points[team]
  139.                     points[team] = newScore
  140.                     displayScore()
  141.                 end
  142.             end
  143.         end
  144.     end
  145. end
  146.  
  147. function eventNewGame()
  148.     if gameRunning then
  149.         isfirst = false
  150.         for i, p in pairs(teams[1]) do
  151.             tfm.exec.setNameColor(p, "0x"..colors[1])
  152.         end
  153.         for i, p in pairs(teams[2]) do
  154.             tfm.exec.setNameColor(p, "0x"..colors[2])
  155.         end
  156.         displayScore()
  157.     end
  158. end
  159.  
  160. function displayScore()
  161.     ui.addTextArea(17, string.format("<p align='center'><font size='23' color='#000000'>%s x %s", points[1], points[2]), nil, 0, 21, 800, 30, 0, 0, 0, true)
  162.     ui.addTextArea(18, string.format("<p align='center'><font size='23' color='#000000'>%s x %s", points[1], points[2]), nil, 1, 20, 800, 30, 0, 0, 0, true)
  163.     ui.addTextArea(19, string.format("<p align='center'><font size='23'><font color='#%s'>%s<N> x <font color='#%s'>%s", colors[1], points[1], colors[2], points[2]), nil, 0, 20, 800, 30, 0, 0, 0, true)
  164. end
  165.  
  166. function displayTeams()
  167.     ui.addTextArea(1, "", nil, 199, 69, 400, 260, 0x5A7A8B, 0x5A7A8B, 1, true)
  168.     ui.addTextArea(2, "", nil, 201, 71, 400, 260, 0x0E1417, 0x0E1417, 1, true)
  169.     ui.addTextArea(3, "", nil, 200, 70, 400, 260, 0x324650, 0x324650, 1, true)
  170.     ui.addTextArea(4, "", nil, 209, 79, 142, 22, 0x324650, 0x5A7A8B, 1, true)
  171.     ui.addTextArea(5, "<p align='center'><V>Team 1", nil, 210, 80, 140, 20, 0x324650, 0x324650, 1, true)
  172.     ui.addTextArea(6, "", nil, 449, 79, 142, 22, 0x324650, 0x5A7A8B, 1, true)
  173.     ui.addTextArea(7, "<p align='center'><V>Team 2", nil, 450, 80, 140, 20, 0x324650, 0x324650, 1, true)
  174.     ui.addTextArea(8, "<p align='center'><font color='#5A7A8B'>|</font>", nil, 210, 102, 140, 200, 0, 0, 0, true)
  175.     ui.addTextArea(9, "<p align='center'><font color='#5A7A8B'>|</font>", nil, 450, 102, 140, 200, 0, 0, 0, true)
  176.     ui.addTextArea(10, "", nil, 209, 120, 140, 200, 0x5A7A8B, 0x5A7A8B, 1, true)
  177.     ui.addTextArea(11, "<p align='center'><font color='#"..colors[1].."'>"..table.concat(teams[1], "\n"), nil, 210, 121, 138, 198, 0x324650, 0x324650, 1, true)
  178.     ui.addTextArea(12, "", nil, 451, 120, 140, 200, 0x5A7A8B, 0x5A7A8B, 1, true)
  179.     ui.addTextArea(13, "<p align='center'><font color='#"..colors[2].."'>"..table.concat(teams[2], "\n"), nil, 452, 121, 138, 198, 0x324650, 0x324650, 1, true)
  180.     ui.addTextArea(14, "<p align='center'><font color='#5A7A8B'>____         ____</font>", nil, 330, 200, 140, 200, 0, 0, 0, true)
  181.     ui.addTextArea(15, "", nil, 380, 202, 40, 20, 0x5A7A8B, 0x5A7A8B, 1, true)
  182.     ui.addTextArea(16, "<p align='center'><V>VS", nil, 381, 203, 38, 18, 0x324650, 0x324650, 1, true)
  183.     ui.addTextArea(16, "<p align='center'><V><a href='event:iniciarJogo'>GO", ADMINISTRADOR, 381, 203, 38, 18, 0x324650, 0x324650, 1, true)
  184. end
  185.  
  186. function eventTextAreaCallback(id, player, callback)
  187.     if callback == 'iniciarJogo' then
  188.         if #teams[2] > 0 and #teams[1] > 0 then
  189.             gameRunning = true
  190.             for i = 1, 16 do
  191.                 ui.removeTextArea(i)
  192.             end
  193.             defaultEffect(9, {9}, 400, 212, 80)
  194.             newMap()
  195.         end
  196.     end
  197. end
  198.  
  199. function string.split(s, pattern, n)
  200.     local st = {}
  201.     for sb in string.gmatch(s, "[^"..pattern.."]+") do
  202.     if not n or n > -1 then
  203.         table.insert(st,sb)
  204.     else
  205.         st[#st] = st[#st]..pattern..sb
  206.     end
  207.     n = n and n-1 or false
  208.     end
  209.     return st
  210. end
  211.  
  212. function table.contains(tableT, element)
  213.     for _, value in pairs(tableT) do
  214.         if value == element then
  215.             return true
  216.         end
  217.     end
  218.     return false
  219. end
  220.  
  221. defaultEffect=function(id,p,x,y,rand) -- thanks for the function santah
  222.     local minDist = 1
  223.     local outerBorder = 20
  224.     local maxDist = 30
  225.     local totalParticles = rand and 40 or (id == -1 and 35 or 75)
  226.     for i = 1, totalParticles do
  227.         if rand then
  228.             id = p[math.random(#p)]
  229.         end
  230.         local dist = math.min(math.random(minDist, maxDist), outerBorder)
  231.         local angle = math.random(0, 360)
  232.         local r = math.rad(angle)
  233.         local dx = math.cos(r)
  234.         local dy = math.sin(r)
  235.         local vx = dist * dx / 10
  236.         local vy = dist * dy / 10
  237.         local ax = -vx / dist / 15
  238.         local ay = (-vy / dist / 15) + 0.05
  239.         if id == -1 then
  240.             tfm.exec.displayParticle(9, x + dx, y + dy, vx, vy, ax, ay, nil)
  241.             tfm.exec.displayParticle(1, x + dx, y + dy, vx, vy, ax, ay, nil)
  242.         else
  243.             tfm.exec.displayParticle(id, x + dx, y + dy, vx, vy, ax, ay, nil)
  244.         end
  245.     end
  246. end
  247.  
  248. displayTeams()
  249.  
  250. function eventPlayerDied(name)
  251.     tfm.exec.respawnPlayer(name)
  252. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement