Advertisement
Dudugz-Contistente

Untitled

Oct 2nd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. data={}
  2. maps={7162824,7233571}
  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. tfm.exec.removeImage(data[k].id)
  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. tfm.exec.removeImage(data[k].id)
  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. v.isDead=false
  82. end
  83. end
  84. end)
  85. end
  86.  
  87. function eventLoop(t,r)
  88. if t > 4000 then
  89. if #freezers == 0 then
  90. local p = {} table.foreach(tfm.get.room.playerList,function(k,v) tfm.exec.setNameColor(k,0) table.insert(p,k) end)
  91. f = p[math.random(#p)] table.insert(freezers,f) tfm.exec.setNameColor(f,0xFFCC00) data[f].cooldown=os.time();
  92.  
  93. local fs,m = "", "<VP><V>%s</V> é o novo freezer, cuidado.</VP>"
  94.  
  95. for _,n in pairs(freezers) do
  96. if fs == "" then
  97. fs=n
  98. else
  99. fs=fs.."<VP>,</VP>"..n
  100. m="<VP><V>%s</V> são os novos freezers, cuidado.</VP>"
  101. end
  102. end
  103.  
  104. tfm.exec.chatMessage(string.format(m,fs))
  105. end
  106.  
  107. if #freezers == 0 and t > 5000 then
  108. 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
  109. tfm.exec.chatMessage("<FC>Os freezers morreram, os ratos vivos ganharam.</FC>")
  110. tfm.exec.newGame(maps[math.random(#maps)])
  111. end
  112.  
  113. if r <= 1000 then
  114. tfm.exec.chatMessage("<FC>O tempo acabou.</FC>")
  115. tfm.exec.newGame(maps[math.random(#maps)])
  116. end
  117.  
  118. if getAlives() == 0 then
  119. 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
  120. tfm.exec.chatMessage("<FC>Os freezers vivos ganharam.</FC>")
  121. tfm.exec.newGame(maps[math.random(#maps)])
  122. end
  123.  
  124. check()
  125. end
  126. end
  127.  
  128. function eventPlayerDied(name)
  129. if isFreezer(name) then
  130. tfm.exec.chatMessage("<FC>O freezer "..name.." morreu.</FC>")
  131.  
  132. for _,n in ipairs(freezers) do
  133. if n == name then
  134. table.remove(freezers,_)
  135. break
  136. end
  137. end
  138. end
  139. end
  140.  
  141. function eventNewPlayer(name)
  142. data[name]={
  143. id=nil,
  144. freezed=false,
  145. cooldown=0,
  146. cooldown_dead=0,
  147. count=0
  148. }
  149.  
  150. system.bindKeyboard(name,32,true)
  151. end
  152.  
  153. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  154. tfm.exec.newGame(maps[math.random(#maps)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement