Advertisement
Guest User

abece

a guest
Jul 16th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. admin = "Suguuru"
  2. teamPlayers = {
  3. {"Suguuru#0000", "", "", "", ""};
  4. {"Minifinny#0000", "", "", "", "", ""};
  5. }
  6. goalScore = 15
  7. maps = {424361,5813783,6607378,3209087,7424218,6571685,7386817,3549484,3603802,5886096,7611818,
  8. 7611847}
  9. ------------------------------------------------------------
  10. teamColor = {0xCC0000, 0x0033FF}
  11. teamScore = {0,0}
  12. gameStarted = nil
  13. gameFinished = nil
  14. currentMap = nil
  15. playersAlive = nil
  16. playersInRoom = 0
  17. players = {}
  18. team = {}
  19. first = nil
  20.  
  21. teamList = {"",""}
  22. for i=1,2 do
  23. for _,name in pairs(teamPlayers[i]) do
  24. team[name] = i
  25. teamList[i] = teamList[i] .. name .. "\n"
  26. end
  27. end
  28.  
  29. function main()
  30. tfm.exec.disableAutoNewGame(true)
  31. tfm.exec.disableAutoShaman(true)
  32. tfm.exec.disableAutoTimeLeft(true)
  33.  
  34. for name in pairs(tfm.get.room.playerList) do
  35. eventNewPlayer(name)
  36. end
  37.  
  38. tfm.exec.newGame(0)
  39.  
  40. local x = {110,690}
  41. for name,t in pairs(team) do
  42. tfm.exec.movePlayer(name, x[t], 350)
  43. end
  44. tfm.exec.movePlayer(admin, 400, 350)
  45.  
  46. ui.addTextArea(1, "<font size='16'>Equipo 1</font>\n\n"..teamList[1], nil, 30, 54, 160, 320, 0x4a4d60, 0x3a3d4b, 0.8, true)
  47. ui.addTextArea(2, "<font size='16'>Equipo 2</font>\n\n"..teamList[2], nil, 610, 54, 160, 320, 0x4a4d60, 0x3a3d4b, 0.8, true)
  48. ui.addTextArea(3, "<p align='center'><font size='16'><a href='event:start'> Empezar </a></font></p>", admin, 320, 180, 160, 32, 0x4a4d60, 0x3a3d4b, 1, true)
  49. end
  50.  
  51. function startGame()
  52. local newMap
  53. repeat
  54. newMap = math.random(#maps)
  55. until newMap ~= currentMap
  56. currentMap = newMap
  57. tfm.exec.newGame(maps[newMap])
  58. end
  59.  
  60. function endGame()
  61. startGame()
  62. end
  63.  
  64. function eventNewGame()
  65. playersAlive = playersInRoom
  66. first = false
  67.  
  68. for name,t in pairs(team) do
  69. tfm.exec.setNameColor(name, teamColor[t])
  70. end
  71.  
  72. tfm.exec.setGameTime(60)
  73. end
  74.  
  75. function eventNewPlayer(name)
  76. if team[name] then
  77. playersInRoom = playersInRoom + 1
  78. end
  79. end
  80.  
  81. function eventPlayerLeft(name)
  82. if team[name] then
  83. playersInRoom = playersInRoom - 1
  84. end
  85. end
  86.  
  87. function eventPlayerDied(name)
  88. if not gameStarted then return end
  89. if team[name] then
  90. playersAlive = playersAlive - 1
  91. checkPlayers()
  92. end
  93. end
  94.  
  95. function eventPlayerWon(name)
  96. if not gameStarted then return end
  97. if team[name] then
  98. if not first then
  99. first = true
  100. local t = team[name]
  101. teamScore[t] = teamScore[t] + 1
  102. updateScore()
  103. tfm.exec.setGameTime(5)
  104. if teamScore[t] == goalScore then
  105. gameStarted = false
  106. gameFinished = true
  107. local c = {"#F90505","#0045FF"}
  108. ui.addTextArea(5, "<p align='center'><font size='20' color='" .. c[t] .. "'>¡El equipo " .. t .. " ha ganado!</font></p>", nil, 0, 170, 800, 60, 0, 0, 0, true)
  109. end
  110. end
  111. playersAlive = playersAlive - 1
  112. checkPlayers()
  113. end
  114. end
  115.  
  116. function checkPlayers()
  117. if playersAlive == 0 then
  118. endGame()
  119. end
  120. end
  121.  
  122. function eventLoop(t, tr)
  123. if gameFinished then
  124. for i=1,8 do
  125. local x,y = math.random(0,800), math.random(0,400)
  126. for j=1,5 do
  127. tfm.exec.displayParticle(math.random(21,24), x, y, math.random(-5,5), 0, 0, math.random(10)/10, nil)
  128. end
  129. end
  130. end
  131. if not gameStarted then return end
  132. if tr <= 0 then
  133. endGame()
  134. end
  135. end
  136.  
  137. function eventTextAreaCallback(id, name, cb)
  138. if id == 3 and not gameStarted then
  139. gameStarted = true
  140. for i=1,3 do
  141. ui.removeTextArea(i)
  142. end
  143. updateScore()
  144. startGame()
  145. end
  146. end
  147.  
  148. function updateScore()
  149. local t = string.format("<p align='center'><font size='32'><font color='#F90505'>%02d</font> - <font color='#0045FF'>%02d</font></font></p>", teamScore[1], teamScore[2])
  150. ui.addTextArea(4, t, nil, 320, 20, 160, 43, 0x4a4d60, 0x3a3d4b, 0, true)
  151. end
  152.  
  153. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement