Advertisement
Guest User

Stopped

a guest
Feb 28th, 2017
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.32 KB | None | 0 0
  1. tfm.exec.disableAutoShaman(true)
  2. tfm.exec.disableAutoNewGame(true)
  3. tfm.exec.disableAutoTimeLeft(true)
  4.  
  5. p={}
  6. mapas={6974651,6980764,7025719,6980627}
  7. registroSpawnObjetos = {};
  8.  
  9. moving = true
  10. tempo = os.time();
  11. stop = 0
  12. vivos=0;
  13.  
  14. function eventNewGame()
  15.     tempo = os.time();
  16.     moving = true
  17.    
  18.     ui.setMapName("Stopped")
  19.    
  20.     vivos = 0;
  21.     pos=0
  22.    
  23.     for i,v in pairs(tfm.get.room.playerList) do
  24.         vivos=vivos+1;
  25.         p[i].rodadas = p[i].rodadas + 1
  26.     end
  27. end
  28.  
  29. function eventPlayerDied(name)
  30.     vivos=vivos-1;
  31.    
  32.     if vivos == 0 then
  33.         tfm.exec.newGame(mapas[math.random(#mapas)])
  34.     end
  35. end
  36.  
  37. function eventNewPlayer(name)
  38.     p[name]={
  39.         money = 0,
  40.         wins = 0,
  41.         rodadas = 0,
  42.         firsts= 0,
  43.         inventory = {},
  44.         using = {},
  45.         shop = {
  46.             {item="Caixa",price=30,id=2,buyed=false},
  47.             {item="Bigorna",price=30,id=10,buyed=false},
  48.         },
  49.         timestamp=os.time()
  50.     }
  51.  
  52.     for key=37,40 do
  53.         system.bindKeyboard(name, key, true, true)
  54.     end
  55.    
  56.     system.bindKeyboard(name, 32, true, true)
  57.    
  58.     ui.addTextArea(1, "<n>Bem vindos ao Novo Mini Game <font color='#ff4e00'>  #Stopped <n> Seu Objetibo é <rose>Correr até o Fim do Mapa e pega o queijo.<br><vp>[Atenção] Aquele que Pega Primeiro o Queijo... VENCE!!<br><font color='#ff0000'>Cuidado Quando Aparecer \"Stopped\" na sua tela, fique parado e não faça nenhum motivo.<br><n>Mas Por outro lado espero que se  <rose>Divirta-se <br><br><font size='14'><j>Comandos :</j><br><font size='12'><vp>!shop<br>!inv<br>!money<br>!p",name, 248.5, 97, 273, 202, 0x1c1c1c)
  59.     ui.addTextArea(0, "<font size='16'>                        Help", name, 225, 59, 322, 30, 0x3cff)
  60.     ui.addTextArea(2, "<font size='16'>   <a href='event:close'>Fechar</a>", name, 336.5, 269, 96, 30, 0xff0000)
  61. end
  62.  
  63.  
  64.  
  65. function split(t,s)
  66.         local a={}
  67.         for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
  68.             table.insert(a,i)
  69.         end
  70.         return a
  71. end
  72.  
  73. function eventChatCommand(name,cmd)
  74.     local arg = split(cmd, " ")
  75.  
  76.     if arg[1] == "p" then
  77.         if arg[2] then
  78.             nome = arg[2]:lower():gsub('%a', string.upper, 1)
  79.         else
  80.             nome = name
  81.         end
  82.        
  83.         if tfm.get.room.playerList[nome] then
  84.             ui.addTextArea(0,"",name,250,40,300,300,nil,0x324650,nil,true)
  85.             ui.addTextArea(1,'<B><J><font size="17"><p align="center">'..nome,name,245,35,310,30,nil,0x2e424d,nil,true)
  86.             ui.addTextArea(2,"<font size='14' color='#FF8B00'>Vitórias: "..p[nome].wins,name,255,80,290,220,0x0e232b,0x0e232b,nil,true)
  87.             ui.addTextArea(3,"<R><p align='center'><B><a href='event:close'>Fechar</a>",name,255,315,290,20,0x3c5063,0x3c5063,nil,true)
  88.         else
  89.            tfm.exec.chatMessage("<R>"..nome.." não se encontra em sala.</R>",name)
  90.         end
  91.     end
  92.    
  93.     if arg[1] == "money" then
  94.         sendMessage(name,"<B><VP><p align='center'>Você tem "..p[name].money.." R$.</VP></B>",name)
  95.     end
  96.  
  97.     if arg[1] == "shop" then
  98.         eventShop(name)
  99.     end
  100.  
  101.     if arg[1] == "inv" then
  102.         eventInv(name)
  103.     end
  104. end
  105.  
  106. function eventPlayerWon(name)
  107.     pos=pos+1
  108.     p[name].wins = p[name].wins + 1
  109.     if pos == 1 then
  110.         p[name].firsts = p[name].firsts + 1
  111.     end
  112.    
  113.     vivos=vivos-1;
  114.    
  115.     if vivos == 0 then
  116.         tfm.exec.newGame(mapas[math.random(#mapas)])
  117.     end
  118. end
  119.  
  120. function isTribeHouse()
  121.  return tfm.get.room.name:sub(1,2) == string.char(42, 0x03)
  122. end
  123.  
  124. function sendMessage(name,msg)
  125. room = isTribeHouse()
  126.  
  127.     if room then
  128.         ui.addPopup(0,3,msg,name,205,150,290,true)
  129.     else
  130.         tfm.exec.chatMessage(msg,name)
  131.     end
  132. end
  133. function eventShop(name)
  134.     str = ''
  135.     for i,loja in pairs(p[name].shop) do
  136.         if loja.buyed then
  137.             if str ~= '' then
  138.                 str = str.."<font color='#2aff00' size='12'>  «"..loja.item.."» <n>   | <font color='#e600ff' size='12' >  «$"..loja.price.."»  <n> | <font color='#FFEB00'>Item comprado</font><br>"
  139.             else
  140.                 str = "<font color='#2aff00' size='12'>  «"..loja.item.."» <n>   | <font color='#e600ff' size='12' >  «$"..loja.price.."»  <n> | <font color='#FFEB00'>Item comprado</font><br>"
  141.             end
  142.         else
  143.             if str ~= '' then
  144.                 str = str.."<font color='#2aff00' size='12'>  «"..loja.item.."» <n>   | <font color='#e600ff' size='12' >  «$"..loja.price.."»  <n> | <font color='#ffe000'><a href='event:buy-"..loja.item.."'>Comprar</a></font><br>"
  145.             else
  146.                 str = "<font color='#2aff00' size='12'>  «"..loja.item.."» <n>   | <font color='#e600ff' size='12' >  «$"..loja.price.."»  <n> | <font color='#ffe000'><a href='event:buy-"..loja.item.."'>Comprar</a></font><br>"
  147.             end
  148.         end
  149.     end
  150.  
  151.          ui.addTextArea(0,"",name,200,45,300,300,nil,0x324650,nil,true)
  152.          ui.addTextArea(3,'<B><J><font size="13"><p align="center">Inventário',name,195,40,310,30,nil,0x2e424d,nil,true)
  153.          ui.addTextArea(2,"<font size='12'><BL><p align='center'>Bem-vindo a loja, você tem <VP>"..p[name].money.."R$</VP></p></BL><br><br>"..str,name,205,85,290,220,0x0e232b,0x0e232b,nil,true)
  154.          ui.addTextArea(-5,"<B><p align='center'><font size='15'><R><a href='event:close'>Fechar</a>",name,205,320,290,20,0x3c5063,0x3c5063,nil,true)
  155. end
  156.  
  157. function eventInv(name)
  158.     str="<B><font size='12'><J>Nome do item</J>   |   <ROSE>Botão</ROSE>"
  159.     for i,v in pairs(p[name].inventory) do
  160.         if p[name].using.item == v.item then
  161.             str = str.."<br><B><font size='12'><J>"..v.item.."</J>   |   <VP>Usando</VP>"
  162.         else
  163.             str = str.."<br><B><font size='12'><J>"..v.item.."</J>   |   <ROSE><a href='event:usar-"..v.item.."'>Usar</a></ROSE>"
  164.         end
  165.     end
  166.  
  167.          ui.addTextArea(0,"",name,200,45,300,300,nil,0x324650,nil,true)
  168.          ui.addTextArea(3,'<B><J><font size="13"><p align="center">Inventário',name,195,40,310,30,nil,0x2e424d,nil,true)
  169.          ui.addTextArea(2,"<B><font size='12'>"..str,name,205,85,290,220,0x0e232b,0x0e232b,nil,true)
  170.          ui.addTextArea(-5,"<B><p align='center'><font size='15'><R><a href='event:close'>Fechar</a>",name,205,320,290,20,0x3c5063,0x3c5063,nil,true)
  171.    
  172. end
  173.  
  174. function eventTextAreaCallback(id,name,link)
  175.     if link == "close" then
  176.          for id=-5,5 do
  177.                   ui.removeTextArea(id,name)
  178.                   ui.removeTextArea(6969+id,name)
  179.                   ui.removeTextArea(7979+id,name)
  180.             end
  181.     end
  182.  
  183.     for i,v in pairs(p[name].shop) do
  184.         if link == "buy-"..v.item then
  185.             if p[name].money >= v.price then
  186.                 sendMessage(name,"<B><R>Você comprou "..v.item.." por -"..v.price.." R$.</R></B>")
  187.                 p[name].money = p[name].money-v.price
  188.                 table.insert(p[name].inventory,{item=v.item,id=v.id})
  189.                 v.buyed = true
  190.             else
  191.                 faltando = p[name].money-v.price
  192.                 sendMessage(name,"<B><R>Você precisa de "..faltando.." R$ para comprar "..v.item..".</R></B>")
  193.             end
  194.             eventShop(name)
  195.         end
  196.     end
  197.  
  198.     for i,v in pairs(p[name].inventory) do
  199.         if link=="usar-"..v.item then
  200.             p[name].using = {item=v.item,id=v.id}
  201.             eventInv(name)
  202.             sendMessage(name,"<B><J>Você agora está usando o item "..v.item..".</J></B>")
  203.         end
  204.     end
  205. end
  206.  
  207. for all in pairs(tfm.get.room.playerList) do
  208.     eventNewPlayer(all)
  209. end
  210.    
  211. function eventPlayerGetCheese(n)
  212. tfm.exec.playerVictory(n)
  213. tfm.exec.chatMessage("Parabéns "..n.." Venceu essa Partida!")
  214. end
  215.  
  216. function eventLoop(t,r)
  217.     local agora = os.time();
  218.     local remover = {};
  219.     for k, item in pairs(tfm.get.room.objectList) do
  220.         if (registroSpawnObjetos[item.id]) then
  221.             if (agora >= registroSpawnObjetos[item.id]) then
  222.                 table.insert(remover, item.id);
  223.             end
  224.         else           
  225.             local duracaoObjetos = {
  226.                 [2] = 4000, --[Caixa grande] = 4s
  227.        
  228.                    [10] = 3000 --[bigorna] = 5s
  229.             };
  230.             local duracaoPadrao = 3000; --quanto tempo os demais objetos que não estão listados acima irão durar
  231.             --formato: [id do objeto] = tempo em milisegundos
  232.             --ids dos objetos: http://atelier801.com/topic?f=6&t=801563&p=1#tab_4_message_1
  233.             registroSpawnObjetos[item.id] = agora + (duracaoObjetos[item.id] or duracaoPadrao);
  234.         end
  235.     end
  236.    
  237.     for i = 1, #remover do
  238.         --remoção dos objetos
  239.         tfm.exec.removeObject(remover[i]);
  240.         registroSpawnObjetos[remover[i]] = nil;
  241.     end
  242.  
  243.    
  244.     if t >= 3000 then
  245.         if tempo < os.time()-10000 then
  246.             ui.addTextArea(10,"<B><p align='center'><R>STOP</R>",nil,6,30,100,20,nil,0x324650,nil,true)
  247.             moving = false
  248.  
  249.             stop = stop+1;
  250.  
  251.             if stop == 8 then
  252.                 stop = 0
  253.                 tempo = os.time();
  254.             end
  255.         elseif tempo < os.time()-8000 then
  256.             ui.addTextArea(10,"<B><p align='center'><J>ALERT</J>",nil,6,30,100,20,nil,0x324650,nil,true)
  257.         else
  258.             moving = true
  259.             ui.addTextArea(10,"<B><p align='center'><font color='#00FF00'>RUN</font>",nil,6,30,100,20,nil,0x324650,nil,true)
  260.         end
  261.     end
  262. end
  263.  
  264. function eventKeyboard(name,key,down,x,y)
  265.     if not moving and (key == 37 or key == 38 or key == 39 or key == 40) then
  266.         tfm.exec.killPlayer(name)
  267.     end
  268.  
  269.     if not moving then
  270.         if name == i then
  271.             for i,v in pairs(tfm.get.room.playerList) do
  272.                 if v.movingRight then
  273.                     tfm.exec.killPlayer(i)
  274.                 else
  275.                     tfm.exec.killPlayer(i)
  276.                 end
  277.             end
  278.         end
  279.     end
  280.    
  281.     if (key==32) and not tfm.get.room.playerList[name].isDead then
  282.         if p[name].timestamp < os.time()-5000 then
  283.             local id
  284.             if tfm.get.room.playerList[name].isFacingRight then
  285.                 id=tfm.exec.addShamanObject(p[name].using.id,x+13,y-10,0,0,0)
  286.             else
  287.                 id=tfm.exec.addShamanObject(p[name].using.id,x-13,y-10,180,0,0)
  288.             end
  289.  
  290.             p[name].timestamp = os.time();
  291.         end
  292.     end
  293. end
  294.  
  295. for all in pairs(tfm.get.room.playerList) do
  296.     eventNewPlayer(all)
  297. end
  298.  
  299. tfm.exec.newGame(mapas[math.random(#mapas)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement