Advertisement
superpaste

x1+ competição

Apr 8th, 2017
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.40 KB | None | 0 0
  1. maps = {5124098, 5124067, 5124047, 5124024, 5124011, 5124002}
  2. tfm.exec.disableAfkDeath(true)
  3. tfm.exec.disableAutoNewGame(true)
  4. tfm.exec.disableAutoScore(true)
  5. tfm.exec.disableAutoShaman(true)
  6. tfm.exec.disableAutoTimeLeft(true)
  7. tfm.exec.newGame(7107555, nil)
  8.  
  9. for i, v in pairs(tfm.get.room.playerList) do
  10. tfm.exec.setPlayerScore(i, 0, false)
  11. end
  12.  
  13. admin = ""
  14. playing = false
  15. ui.addTextArea(1, "                                                                 !nick para escolher o admin", nil, 0, 20, 800, 0, 0x123450, 0x123450, 0.9, true)
  16. people = 0
  17. function eventChatCommand(jogador, comando)
  18. if admin == "" then
  19.         have = false
  20.             for i, v in pairs(tfm.get.room.playerList) do
  21.                 if i == comando then
  22.                     have = true
  23.                 end
  24.             end
  25.         if have then
  26.             admin = comando
  27.             ui.removeTextArea(1, nil)
  28.             ui.addTextArea(1, '<a href="event:organize">Organizar torneio</a>', admin, 0, 20, 0, 0, 0x123450, 0x123450, 1, true)
  29.         else
  30.             ui.updateTextArea(1, "o jogador " .. comando .. " não existe", nil)
  31.         end
  32. else
  33. end
  34. end
  35.  
  36. function eventTextAreaCallback(id, jogador, callback)
  37. if callback == "organize" then
  38.         people = ""
  39.         for i, v in pairs(tfm.get.room.playerList) do
  40.             people = people .. '<a href="event:h'..i..'">'..i..'</a><br/>'
  41.         end
  42. play = {}
  43. ui.addTextArea(1, 'ratos<br/>' .. people, admin, 0, 20, 400, 300, 0x123450, 0xCFCFCF, 1, true)
  44. ui.addTextArea(2, 'a jogar', admin, 400, 20, 400, 300, 0x123450, 0xCFCFCF, 1, true)
  45. ui.addTextArea(3, '                                                     necessita no mínimo 2', admin, 0, 312, 800, 0, 0x123450, 0xCFCFCF, 1, true)
  46. ui.addTextArea(4, '                                                     <a href="event:close">fechar</a>', admin, 0, 340, 800, 0, 0x123450, 0xCFCFCF, 1, true)
  47.  
  48. end
  49. print(string.sub(callback, 1, 1))
  50. if string.sub(callback, 1, 1) == "h" then
  51. have = false
  52. print(string.sub(callback, 2))
  53. for i, v in pairs(play) do
  54.  
  55. if string.sub(callback, 2) == v then
  56. have = true
  57. end
  58. end
  59. if have then
  60. for i, v in pairs(play) do
  61. if string.sub(callback, 2) == v then
  62. number = i
  63. end
  64. end
  65. play[number] = nil
  66. else
  67. play[#play + 1] = string.sub(callback, 2)
  68. end
  69. redation = 'a jogar<br/>'
  70. for i, v in pairs(play) do
  71. redation = redation .. v .. '<br/>'
  72. end
  73. ui.updateTextArea(2, redation, nil)
  74. if #play > 1 then
  75. ui.updateTextArea(3, '                                                      <a href="event:start">começar!</a>', nil)
  76. else
  77. ui.updateTextArea(3, '                                                      necessita no mínimo 2', nil)
  78. end
  79. end
  80. print(callback)
  81. if callback == "close" then
  82. ui.removeTextArea(1, admin)
  83. ui.removeTextArea(2, admin)
  84. ui.removeTextArea(3, admin)
  85. ui.removeTextArea(4, admin)
  86. ui.addTextArea(1, '<a href="event:organize">Organizar torneio</a>', admin, 0, 20, 0, 0, 0x123450, 0x123450, 1, true)
  87. end
  88. if callback == "start" then
  89. ui.removeTextArea(1, admin)
  90. ui.removeTextArea(2, admin)
  91. ui.removeTextArea(3, admin)
  92. ui.removeTextArea(4, admin)
  93. ui.addTextArea(1, '<a href="event:organize">Organizar torneio</a>', admin, 0, 20, 0, 0, 0x123450, 0x123450, 1, true)
  94. map = maps[math.random(#maps)]
  95. people = #play
  96. for i, v in pairs(play) do
  97. end
  98. playing = true
  99. tfm.exec.newGame(map, nil)
  100. end
  101. end
  102.  
  103. function eventNewGame()
  104. is = false
  105. for i, v in pairs(maps) do
  106. if v == map then
  107. is = true
  108. end
  109. end
  110. if is then
  111. selected = false
  112. for i, v in pairs(tfm.get.room.playerList) do
  113. for n, g in pairs(play) do
  114. print(g)
  115. print(i)
  116. if i == g then
  117. selected = true
  118. end
  119. end
  120. if selected == true then
  121. system.bindKeyboard(i, 32, false, true)
  122. else
  123. tfm.exec.killPlayer(i)
  124. end
  125. end
  126. people = #play
  127. else
  128. for i, v in pairs(tfm.get.room.playerList) do
  129. system.bindKeyboard(i, 32, false, false)
  130. end
  131. end
  132. end
  133.  
  134. function eventKeyboard(j, id, p, x, y)
  135. if playing then
  136. if tfm.get.room.playerList[j].isFacingRight then
  137. tfm.exec.addShamanObject(17, x, y + 30, 90, 0, 0, false)
  138. else
  139. tfm.exec.addShamanObject(17, x, y + 30, -90, 0, 0, false)
  140. end
  141. end
  142. end
  143.  
  144. function eventPlayerDied(j)
  145. people = people -1
  146. if people == 1 then
  147. winner = j
  148. for i, v in pairs(tfm.get.room.playerList) do
  149. system.bindKeyboard(i, 32, false, false)
  150. if not v.isDead then
  151. winner = i
  152. end
  153. end
  154.  
  155. tfm.exec.newGame(7107555, nil)
  156. ui.addPopup(1, 0, winner .. " ganhou!", nil, 300, 200, 200, true)
  157. playing = false
  158. tfm.exec.setPlayerScore(winner, 1, true)
  159. end
  160. end
  161.  
  162. function eventLoop()
  163. upper = -1
  164. for i, v in pairs(tfm.get.room.playerList) do
  165. if v.score > upper then
  166. upper = v.score
  167. end
  168. for i, v in pairs(tfm.get.room.playerList) do
  169. if v.score == upper then
  170. tfm.exec.setNameColor(i, 0xE9E654)
  171. else
  172. tfm.exec.setNameColor(i, 0xC2C2DA)
  173. end
  174. end
  175. end
  176.  
  177. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement