Advertisement
Dudugz-Contistente

Untitled

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