Dudugz-Contistente

Untitled

Oct 2nd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. data={}
  2. maps={7162824,7233571,6888882,3874909,5742159}
  3.  
  4. freezers={}
  5. isFreezer=function(name)
  6. for _,n in pairs(freezers) do
  7. if n == name then
  8. return true
  9. end
  10. end
  11.  
  12. return false
  13. end
  14. tfm.exec.disableAutoShaman()
  15. tfm.exec.disableAutoNewGame()
  16.  
  17. getAlives=function()
  18. local a = 0 table.foreach(tfm.get.room.playerList, function(k,v) if not v.isDead and freezer ~= k then a=a+1 end end) return a
  19. end
  20.  
  21. function eventKeyboard(name,key,down,x,y)
  22. if key == 32 and isFreezer(name) and data[name].cooldown < os.time()-2000 then
  23. for k,player in pairs(tfm.get.room.playerList) do
  24. if name ~= k and not isFreezer(k) and data[k].count < 2 and not player.isDead and not data[k].freezed and x >= player.x - 15 and x <= player.x + 15 and y >= player.y - 15 and y <= player.y + 15 then
  25. tfm.exec.killPlayer(k)
  26. data[k].coords = {player.x,player.y}
  27. data[k].id=tfm.exec.addImage("15eda796ea2.png","?"..player.id,data[k].coords[1]-20,data[k].coords[2]-20)
  28. data[k].freezed=true
  29. data[k].cooldown_dead = 20
  30. data[k].count = data[k].count+1
  31. data[name].cooldown=os.time()
  32. break
  33. elseif data[k].count == 2 then
  34. if math.random(1,8) == 4 then
  35. table.insert(freezers,k)
  36. tfm.exec.setNameColor(k,0xFFCC00)
  37. data[k].cooldown=os.time();
  38. else
  39. tfm.exec.killPlayer(k)
  40. data[k].freezed=true
  41. data[k].id=tfm.exec.addImage("15eda796ea2.png","?"..player.id,data[k].coords[1]-20,data[k].coords[2]-20)
  42. end
  43. end
  44. end
  45. end
  46.  
  47. if key == 32 and not isFreezer(name) and not tfm.get.room.playerList[name].isDead and data[name].cooldown < os.time()-2500 then
  48. table.foreach(tfm.get.room.playerList,function(k,player)
  49. if data[k].cooldown_dead > 0 and name ~= k and player.isDead and not data[name].freezed and x >= player.x - 15 and x <= player.x + 15 and y >= player.y - 15 and y <= player.y + 15 then
  50. tfm.exec.respawnPlayer(k)
  51. tfm.exec.movePlayer(k,data[k].coords[1],data[k].coords[2])
  52. if data[k].id ~= nil then ui.removeImage(data[k].id) end
  53. data[k].freezed=false
  54. ui.removeTextArea(player.id)
  55. data[name].cooldown=os.time()
  56. end
  57. end)
  58. end
  59. end
  60.  
  61. function eventNewGame()
  62. freezers={}
  63.  
  64. table.foreach(tfm.get.room.playerList,function(k,v)
  65. data[k].freezed=false
  66. ui.removeTextArea(v.id,nil)
  67. if data[k].id ~= nil then ui.removeImage(data[k].id) end
  68. data[k].cooldown_dead=0
  69. data[k].count=0
  70. end)
  71. end
  72.  
  73. function check()
  74. table.foreach(tfm.get.room.playerList,function(k,v)
  75. if v.isDead then
  76. if data[k].cooldown_dead > 0 then
  77. ui.addTextArea(v.id,'<B><font color="#2F7FCC" size="13">'..math.floor(data[k].cooldown_dead/2),nil,data[k].coords[1],data[k].coords[2],30,30,0,0,0,true)
  78. data[k].cooldown_dead=data[k].cooldown_dead-1
  79. else
  80. ui.removeTextArea(v.id)
  81. if data[k].id ~= nil then ui.removeImage(data[k].id) end
  82. v.isDead=false
  83. end
  84. end
  85. end)
  86. end
  87.  
  88. function eventLoop(t,r)
  89. if t > 4000 then
  90. if #freezers == 0 then
  91. local p = {} table.foreach(tfm.get.room.playerList,function(k,v) tfm.exec.setNameColor(k,0) table.insert(p,k) end)
  92. for i=1,4 do f = p[math.random(#p)] table.insert(freezers,f) tfm.exec.setNameColor(f,0xFFCC00) data[f].cooldown=os.time(); end
  93.  
  94. local fs,m = "", "<VP><V>%s</V> é o novo freezer, cuidado.</VP>"
  95.  
  96. for _,n in pairs(freezers) do
  97. if fs == "" then
  98. fs=n
  99. else
  100. fs=fs.."<VP>,</VP>"..n
  101. m="<VP><V>%s</V> são os novos freezers, cuidado.</VP>"
  102. end
  103. end
  104.  
  105. tfm.exec.chatMessage(string.format(m,fs))
  106. end
  107.  
  108. if #freezers == 0 and t > 5000 then
  109. for name,v in pairs(tfm.get.room.playerList) do if not v.isDead then tfm.exec.giveCheese(name)tfm.exec.playerVictory(name) end end
  110. tfm.exec.chatMessage("<FC>Os freezers morreram, os ratos vivos ganharam.</FC>")
  111. tfm.exec.newGame(maps[math.random(#maps)])
  112. end
  113.  
  114. if r <= 1000 then
  115. tfm.exec.chatMessage("<FC>O tempo acabou.</FC>")
  116. tfm.exec.newGame(maps[math.random(#maps)])
  117. end
  118.  
  119. if getAlives() == 0 then
  120. for name,v in pairs(tfm.get.room.playerList) do if not v.isDead then tfm.exec.giveCheese(name)tfm.exec.playerVictory(name) end end
  121. tfm.exec.chatMessage("<FC>Os freezers vivos ganharam.</FC>")
  122. tfm.exec.newGame(maps[math.random(#maps)])
  123. end
  124.  
  125. check()
  126. end
  127. end
  128.  
  129. function eventPlayerDied(name)
  130. if isFreezer(name) then
  131. tfm.exec.chatMessage("<FC>O freezer "..name.." morreu.</FC>")
  132.  
  133. for _,n in ipairs(freezers) do
  134. if n == name then
  135. table.remove(freezers,_)
  136. break
  137. end
  138. end
  139. end
  140. end
  141.  
  142. function eventNewPlayer(name)
  143. data[name]={
  144. id=nil,
  145. freezed=false,
  146. cooldown=0,
  147. cooldown_dead=0,
  148. count=0
  149. }
  150.  
  151. system.bindKeyboard(name,32,true)
  152. end
  153.  
  154. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  155. tfm.exec.newGame(maps[math.random(#maps)])
Add Comment
Please, Sign In to add comment