Advertisement
Dudugz-Contistente

Untitled

Jan 5th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. p={}
  2. shaman = ""
  3. mapas = {6998890}
  4. vivos = 0
  5.  
  6. time = os.time();
  7. jogadores = {}
  8.  
  9. tfm.exec.disableAutoNewGame(true)
  10. tfm.exec.disableAutoShaman(true)
  11. tfm.exec.disableAutoTimeLeft(true)
  12.  
  13. function split(t,s)
  14. local a={}
  15. for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
  16. table.insert(a,i)
  17. end
  18. return a
  19. end
  20.  
  21. function eventChatCommand(p, cmd)
  22. local arg = split(cmd, " ")
  23.  
  24. if arg[1] == "commands" then
  25. tfm.exec.chatMessage("<B><I><J>→ Comandos:</J></I></B><br>!help - mensagem de ajuda.<br>!rank - abre o ranking.<br>!p [nick] - abre o perfil, sem o nome abre apenas o seu.",name)
  26. end
  27.  
  28. if arg[1] == "p" then
  29. tfm.exec.chatMessage("<I><R>→ O perfil está em manutenção.</R></I>",name)
  30. end
  31.  
  32. if arg[1] == "help" then
  33. tfm.exec.chatMessage("<B><I><VI>→ Como jogar:</VI></B></I><br><VP>O jogo tem dois portais, um azul que segue os ratos e um laranja que aparece aleatóriamente no mapa, a função dos ratos é sobreviver e não ser morto pelos portais, se o tempo acabar os vivos vencem, caso contrário todos morrerem nimguém vence.</VP>",name)
  34. end
  35.  
  36. if arg[1] == "rank" then
  37. eventRanking(p)
  38. end
  39. end
  40.  
  41. function eventRanking(name)
  42. local sc = {}
  43. for name, player in pairs(tfm.get.room.playerList) do
  44. sc[#sc+1] = {n=name,s=player.score} -- insira o valor que quiser
  45. end
  46.  
  47. table.sort(sc,function(a,b) return a.s>b.s end) -- aqui ele reorganiza tudo certinho o s ali no a.s e b.s é o score da tabela acima
  48.  
  49. str = ''
  50. ui.addTextArea(0,"",name,200,45,300,300,nil,0x324650,nil,true)
  51. ui.addTextArea(1,'<B><J><font size="16"><I><p align="center">Ranking',name,195,40,310,30,nil,0x2e424d,nil,true)
  52. ui.addTextArea(2,"",name,205,85,290,223,0x0e232b,0x0e232b,nil,true)
  53. ui.addTextArea(-1,"<B><p align='center'><font size='15'><R><a href='event:close'>Fechar</a>",name,205,320,290,20,0x3c5063,0x3c5063,nil,true)
  54. y1 = 87
  55. x1 = 208
  56. for k,v in pairs(sc) do
  57. if k < 7 then
  58. ui.addTextArea(4949+k,k,name,x1,y1,25,17,0x2e424d,0x2e424d,70,true)
  59. ui.addTextArea(3939+k,v.n,name,x1+40,y1,nil,17,0x2e424d,0x2e424d,70,true)
  60. ui.addTextArea(2929+k,v.s,name,x1+150,y1,60,17,0x2e424d,0x2e424d,70,true)
  61. y1 = y1+30
  62. end
  63. end
  64. end
  65.  
  66. function eventTextAreaCallback(id,name,link)
  67. if link == "close" then
  68. for id=-1,2 do
  69. ui.removeTextArea(id,name)
  70. ui.removeTextArea(6969+id,name)
  71. ui.removeTextArea(7979+id,name)
  72. end
  73.  
  74. for id=4949,4956 do
  75. ui.removeTextArea(id,name)
  76. ui.removeTextArea(6969+id,name)
  77. ui.removeTextArea(7979+id,name)
  78. end
  79.  
  80. for id=3939,3946 do
  81. ui.removeTextArea(id,name)
  82. ui.removeTextArea(6969+id,name)
  83. ui.removeTextArea(7979+id,name)
  84. end
  85.  
  86. for id=2929,2936 do
  87. ui.removeTextArea(id,name)
  88. ui.removeTextArea(6969+id,name)
  89. ui.removeTextArea(7979+id,name)
  90. end
  91. end
  92. end
  93.  
  94. function eventLoop(t,r)
  95. tfm.exec.addShamanObject(27, math.random(-5,810), math.random(20,380), 90, 800, 0)
  96. if t >= 1000 then
  97. name = jogadores[math.random(#jogadores)]
  98.  
  99. if tfm.get.room.playerList[name] then
  100. x = tfm.get.room.playerList[name].x
  101. y = tfm.get.room.playerList[name].y
  102. if tfm.get.room.playerList[name].isFacingRight then
  103. tfm.exec.addShamanObject(26, x+math.random(-5,5), y+math.random(-10,10), 270, -800, 0)
  104. else
  105. tfm.exec.addShamanObject(26, x+math.random(-5,5), y+math.random(-10,10), 90, 800, 0)
  106. end
  107. end
  108. end
  109.  
  110. if r < 1000 or vivos == 0 then
  111. str = ''
  112. str2 = ''
  113. for i,v in pairs(tfm.get.room.playerList) do
  114. if not v.isDead then
  115. tfm.exec.giveCheese(name)
  116. tfm.exec.playerVictory(name)
  117. if str ~= '' then
  118. str=str..','..name
  119. str2 = "são"
  120. else
  121. str=name
  122. str2 = "é"
  123. end
  124. end
  125. end
  126.  
  127. if str ~= '' then
  128. tfm.exec.chatMessage("<B><I><J>→ <VP>"..str.." "..str2.." o(s) vencedor(s).</J></I></B>")
  129. end
  130. tfm.exec.newGame(mapas[math.random(#mapas)])
  131. end
  132. end
  133.  
  134. function eventPlayerDied(name)
  135. vivos=vivos-1;
  136.  
  137. if vivos == 0 then
  138. tfm.exec.chatMessage("<B><J>→ Nimguém venceu.</J></B>")
  139. end
  140.  
  141. delete = nil
  142. for i,v in pairs(jogadores) do
  143. if v == name then
  144. delete=i
  145. end
  146. end
  147.  
  148. if delete ~= nil then
  149. table.remove(jogadores,delete)
  150. end
  151. end
  152.  
  153. function eventPlayerWon(name)
  154. vivos=vivos-1;
  155. end
  156.  
  157. function eventNewGame()
  158. tfm.exec.setGameTime(60)
  159. system.bindMouse(shaman,false)
  160. vivos = 0
  161. jogadores = {}
  162. for name,v in pairs(tfm.get.room.playerList) do
  163. table.insert(jogadores,name)
  164. vivos=vivos+1;
  165. end
  166.  
  167. system.bindMouse(shaman,true)
  168. end
  169.  
  170. function eventNewPlayer(name)
  171. p[name]={
  172. w=0,
  173. l=0,
  174. }
  175. tfm.exec.chatMessage("<CE>→ Bem-vindo ao Portals Attack.</CE><VP>→ Este minigame não está 100% concluido.</VP><VI>→ Veja os comandos com !commands.</VI>",name)
  176. end
  177.  
  178. for all in pairs(tfm.get.room.playerList) do
  179. eventNewPlayer(all)
  180. end
  181.  
  182. tfm.exec.newGame(mapas[math.random(#mapas)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement