Advertisement
Dudugz-Contistente

Untitled

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