Advertisement
Dudugz-Contistente

Untitled

Oct 2nd, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.24 KB | None | 0 0
  1. data={}
  2. maps={7162824,7233571,6888882,3874909,5742159}
  3.  
  4. freezers={}
  5.  
  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.  
  16. tfm.exec.disableAutoShaman()
  17. tfm.exec.disableAutoNewGame()
  18.  
  19. sys={times={},newTimer=function(callback, tempo, arg1, arg2, arg3, arg4)if arg1 == nil and arg2 == nil and arg3 == nil and arg4 == nil then table.insert(sys.times,{call=callback, tempo=tempo, timer=os.time(), args={}}) end if arg1 ~= nil and arg2 == nil then table.insert(sys.times,{call=callback, tempo=tempo, timer=os.time(), args={arg1}}) end if arg1 ~= nil and arg2 ~= nil and arg3 == nil then table.insert(sys.times,{call=callback, tempo=tempo, timer=os.time(), args={arg1,arg2}}) end if arg1 ~= nil and arg2 ~= nil and arg3 ~= nil and arg4 == nil then table.insert(sys.times,{call=callback, tempo=tempo, timer=os.time(), args={arg1,arg2,arg3}}) end if arg1 ~= nil and arg2 ~= nil and arg3 ~= nil and arg4 ~= nil then table.insert(sys.times,{call=callback, tempo=tempo, timer=os.time(), args={arg1,arg2,arg3,arg4}}) end return #sys.times end, removeTimer=function(id) table.remove(sys.times,id) end, eventLoop=function() for i,v in ipairs(sys.times) do if v.timer < os.time()-(v.tempo*1000) then if v.args[1] == nil then v.call() end if v.args[1] ~= nil and v.args[2] == nil then v.call(v.args[1]) end if v.args[1] ~= nil and v.args[2] ~= nil and v.args[3] == nil then v.call(v.args[1],v.args[2]) end if v.args[1] ~= nil and v.args[2] ~= nil and v.args[3] ~= nil and v.args[4] == nil then v.call(v.args[1],v.args[2],v.args[3]) end if v.args[4] ~= nil then v.call(v.args[1],v.args[2],v.args[3],v.args[4]) end table.remove(sys.times,i) end end end}
  20.  
  21. getAlives=function()
  22. local a = 0 table.foreach(tfm.get.room.playerList, function(k,v) if not v.isDead and not isFreezer(k) then a=a+1 end end) return a
  23. end
  24.  
  25. function eventKeyboard(name,key,down,x,y)
  26. if key == 32 and isFreezer(name) and data[name].cooldown < os.time()-2000 then
  27. for k,player in pairs(tfm.get.room.playerList) do
  28. 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
  29. tfm.exec.killPlayer(k)
  30. data[k].coords = {player.x,player.y}
  31. data[k].id=tfm.exec.addImage("15eda796ea2.png","?"..player.id,data[k].coords[1]-25,data[k].coords[2]-25)
  32. data[k].freezed=true
  33. data[k].cooldown_dead = 20
  34. data[k].count = data[k].count+1
  35. data[name].cooldown=os.time()
  36. break
  37. elseif data[k].count == 2 and not data[k].isFreezer then
  38. if math.random(1,8) == 4 then
  39. table.insert(freezers,k)
  40. tfm.exec.setNameColor(k,0xFFCC00)
  41. data[k].cooldown=os.time();
  42. tfm.exec.chatMessage(k.." virou um novo freezer.")
  43. else
  44. tfm.exec.killPlayer(k)
  45. data[k].freezed=true
  46. data[k].id=tfm.exec.addImage("15eda796ea2.png","!"..player.id,data[k].coords[1]-20,data[k].coords[2]-20)
  47. end
  48. end
  49. end
  50. end
  51.  
  52. if key == 32 and not isFreezer(name) and not tfm.get.room.playerList[name].isDead and data[name].cooldown < os.time()-2500 then
  53. table.foreach(tfm.get.room.playerList,function(k,player)
  54. if data[k].cooldown_dead > 0 and name ~= k and data[k].freezed and not data[name].freezed and x >= player.x - 20 and x <= player.x + 20 and y >= player.y - 20 and y <= player.y + 20 then
  55. tfm.exec.respawnPlayer(k)
  56. tfm.exec.movePlayer(k,data[k].coords[1],data[k].coords[2])
  57. if data[k].id ~= nil then tfm.exec.removeImage(data[k].id) end
  58. data[k].freezed=false
  59. ui.removeTextArea(player.id)
  60. data[name].cooldown=os.time()
  61. end
  62. end)
  63. elseif data[name].cooldown > os.time()-2500 and not isFreezer(name) then
  64. tfm.exec.chatMessage("<G>Aguarde alguns segundos para poder descolar alguém.</G>",name)
  65. end
  66. end
  67.  
  68. function eventNewGame()
  69. freezers={}
  70.  
  71. table.foreach(tfm.get.room.playerList,function(k,v)
  72. data[k].freezed=false
  73. ui.removeTextArea(v.id,nil)
  74. if data[k].id ~= nil then tfm.exec.removeImage(data[k].id) end
  75. data[k].cooldown_dead=0
  76. data[k].count=0
  77. end)
  78.  
  79. tfm.exec.setGameTime(210)
  80. end
  81.  
  82. function check()
  83. table.foreach(tfm.get.room.playerList,function(k,v)
  84. if v.isDead then
  85. if data[k].cooldown_dead > 0 then
  86. 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)
  87. data[k].cooldown_dead=data[k].cooldown_dead-1
  88. else
  89. ui.removeTextArea(v.id)
  90. tfm.exec.removeImage(data[k].id)
  91. v.isDead=false
  92. end
  93. end
  94. end)
  95. end
  96.  
  97. function eventLoop(t,r)
  98. sys.eventLoop()
  99. if t > 6000 then
  100. if #freezers == 0 then
  101. local p = {} table.foreach(tfm.get.room.playerList,function(k,v) tfm.exec.setNameColor(k,0) table.insert(p,k) end)
  102. if getAlives() >= 15 then
  103. for i=1,2 do f = p[math.random(#p)] table.insert(freezers,f) tfm.exec.setNameColor(f,0xFFCC00) data[f].cooldown=os.time(); end
  104. else
  105. for i=1,1 do f = p[math.random(#p)] table.insert(freezers,f) tfm.exec.setNameColor(f,0xFFCC00) data[f].cooldown=os.time(); end
  106. end
  107.  
  108. local fs,m = "", "<VP><V>%s</V> é o novo freezer, cuidado.</VP>"
  109.  
  110. for _,n in pairs(freezers) do
  111. if fs == "" then
  112. fs=n
  113. else
  114. fs=fs.."<VP>,</VP>"..n
  115. m="<VP><V>%s</V> são os novos freezers, cuidado.</VP>"
  116. end
  117. end
  118.  
  119. tfm.exec.chatMessage(string.format(m,fs))
  120. end
  121.  
  122. if #freezers == 0 and t > 5000 then
  123. 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
  124. tfm.exec.chatMessage("<FC>Os freezers morreram, os ratos vivos ganharam.</FC>")
  125. tfm.exec.newGame(maps[math.random(#maps)])
  126. end
  127.  
  128. if r <= 1000 then
  129. tfm.exec.chatMessage("<FC>O tempo acabou.</FC>")
  130. tfm.exec.newGame(maps[math.random(#maps)])
  131. end
  132.  
  133. if getAlives() == 0 then
  134. 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
  135. tfm.exec.chatMessage("<FC>Os freezers vivos ganharam.</FC>")
  136. tfm.exec.newGame(maps[math.random(#maps)])
  137. end
  138.  
  139. check()
  140. end
  141. end
  142.  
  143. function eventPlayerDied(name)
  144. if isFreezer(name) then
  145. tfm.exec.chatMessage("<FC>O freezer "..name.." morreu.</FC>")
  146.  
  147. for _,n in ipairs(freezers) do
  148. if n == name then
  149. table.remove(freezers,_)
  150. break
  151. end
  152. end
  153. end
  154. end
  155.  
  156. function isHelpMessages(message)
  157. local msgs = {"como joga?","como joga","como jogar","help?","não sei como jogar","n sei joga","n sei jogar","não sei jogar","nao sei como jogar","como joga","alguém diz como joga"}
  158. for _,msg in pairs(msgs) do
  159. if message:lower() == msg then
  160. return true
  161. end
  162. end
  163.  
  164. return false
  165. end
  166.  
  167. function eventChatMessage(name,cmd)
  168. if cmd == "!help" or isHelpMessages(cmd) then
  169. tfm.exec.chatMessage("<CEP>> [<CE>Contistente</CE>] Olá, vou te ensinar a jogar.",name)
  170. tfm.exec.chatMessage("<CEP>> [<CE>Contistente</CE>] Vamos começar o tutorial, primeiramente",name)
  171. tfm.exec.chatMessage("<CEP>> [<CE>Contistente</CE>] toda vez que um novo mapa inicia após 4 segundos é escolhido 1/2 congeladores",name)
  172. tfm.exec.chatMessage("<CEP>> [<CE>Contistente</CE>] cuja a função deles é congelar os ratos apertando espaço, após ter um colega congelado",name)
  173. tfm.exec.chatMessage("<CEP>> [<CE>Contistente</CE>] você tem apenas 10 segundos para descongelar ele se não ele morre de vez.",name)
  174. tfm.exec.chatMessage("<CEP>> [<CE>Contistente</CE>] Basta apertar espaço perto do contador que ele é descongelado.",name)
  175. tfm.exec.chatMessage("<CEP>> [<CE>Contistente</CE>] Para mais dúvidas /c Contistente.",name)
  176. end
  177. end
  178.  
  179. function eventNewPlayer(name)
  180. data[name]={
  181. id=nil,
  182. freezed=false,
  183. cooldown=0,
  184. cooldown_dead=0,
  185. count=0
  186. }
  187.  
  188. tfm.exec.chatMessage("<V>[<VP>•</VP>]</V> O comando <B>!help</B> já está disponível no freezed.",name)
  189. tfm.exec.chatMessage("<V>[<VP>•</VP>]</V> Este minigame foi criado por <B>Contistente</B> baseado em idéias de <B>Fofinhoppp</B>.",name)
  190. tfm.exec.chatMessage("<V>[<VP>•</VP>]</V> Reporte bugs/Envia mapas a <B>Contistente</B>.",name)
  191.  
  192. system.bindKeyboard(name,32,true)
  193. end
  194.  
  195. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  196. tfm.exec.newGame(maps[math.random(#maps)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement