Advertisement
Camilledrain_LUA

Sniper v1.0.6

Oct 12th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.55 KB | None | 0 0
  1. tfm.exec.disableAutoNewGame(true)
  2. tfm.exec.disablePhysicalConsumables(true)
  3. tfm.exec.disableAllShamanSkills(true)
  4. enabled=true
  5. vivo=0
  6. vivos=0
  7. loop=0
  8. prox=false
  9. shaman=""
  10. remain=10
  11. players={}
  12. p={}
  13. mapas={"@7284500","@7282115","@7282073","@7284814","@6958866","@7177229","@3859389","@7285283","@4122612","@7286965"}
  14. system.disableChatCommandDisplay("cmd",true)
  15. system.disableChatCommandDisplay("p",true)
  16. system.disableChatCommandDisplay("rank",true)
  17. tfm.exec.newGame(mapas[math.random(#mapas)])
  18. function eventLoop(p,f)
  19.     ui.setMapName("<N><J>"..tfm.get.room.currentMap.."   <G>|   <N>Vivos : <V>"..vivos.."")
  20.     if vivo == 2 then
  21.         tfm.exec.killPlayer(shaman)
  22.     end
  23.     if f <= 5000 and f >= 4400 and vivo >= 2 then
  24.         eventWin()
  25.         tfm.exec.chatMessage("<N>Tempo esgotado! <VP><b>"..vivos.."</b> <N>ratos permaneceram vivos.",nil)
  26.     end
  27.     if f <= 500 then
  28.         tfm.exec.newGame(mapas[math.random(#mapas)])
  29.     end
  30.     loop=loop+0.5
  31.     if enabled == true then
  32.     remain=remain-0.5
  33.     end
  34.     if remain <= 5 and remain >= 0.5 then
  35.         ui.addTextArea(0,"<font size='33'><p align='center'>"..math.ceil(remain).."",nil,370,350,60,45,0x000001,0x000001,0.8,true)
  36.     end
  37.     if remain <= 0 and remain >= -1 then
  38.         ui.addTextArea(0,"<font size='33'><p align='center'>Go!",nil,350,350,100,45,0x000001,0x000001,0.8,true)
  39.     end
  40.     if remain <= -1.5 then
  41.         tfm.exec.setGameTime(30+(vivos*3))
  42.         ui.removeTextArea(0,nil)
  43.         enabled=false
  44.         remain=10
  45.     end
  46.     vivos=vivo-1
  47. end
  48. function eventChatCommand(name,message)
  49.     local arg = split(message, " ")
  50.  
  51.     if arg[1] == "p" then
  52.         if arg[2] then
  53.             nome = arg[2]:lower():gsub('%a', string.upper, 1)
  54.         else
  55.             nome = name
  56.         end
  57.        
  58.         if tfm.get.room.playerList[nome] then
  59.                 ui.addTextArea(1,'<B><J><font size="17"><p align="center">'..nome,name,245,190,315,30,nil,0x2e424d,nil,true)
  60.                 ui.addTextArea(2,"<font size='12'>Vitórias: "..p[nome].wins.."<br>Rodadas: "..p[nome].rodadas.."<br>Eficiência: "..math.ceil(p[nome].eff).."%<br>Pontos: "..p[nome].pontos.."",name,255,230,290,70,0x0e232b,0x0e232b,nil,true)
  61.                 ui.addTextArea(3,"<R><p align='center'><B><a href='event:fechar'>Fechar</a>",name,255,300,290,20,0x3c5063,0x3c5063,nil,true)
  62.             else
  63.                 tfm.exec.chatMessage("<R>"..nome.." não se encontra em sala.</R>",name)
  64.             end
  65.     end
  66.  
  67.     if arg[1] == "rank" then
  68.             eventRanking(name)
  69.         end
  70.     if message == "cmd" then
  71.         if name == "Camilledrain" then
  72.             tfm.exec.chatMessage("Mandem seus mapas para o module:<br><b>http://atelier801.com/topic?f=751215&t=912752</b>",nil)
  73.         end
  74.     end
  75. end
  76. function eventTextAreaCallback(id,name,link)
  77.     if link == "fechar" then
  78.         for id=0,3 do
  79.             ui.removeTextArea(id,name)
  80.         end
  81.     end
  82.     if link == "close" then
  83.     for id=-1,2 do
  84.         ui.removeTextArea(id,name)
  85.         ui.removeTextArea(6969+id,name)
  86.         ui.removeTextArea(7979+id,name)
  87.     end
  88.     end
  89. end
  90. function eventRanking(name)
  91.     local sc = {}
  92.     for name, player in pairs(tfm.get.room.playerList) do
  93.         sc[#sc+1] = {n=name,s=p[name].pontos,f=p[name].eff,w=p[name].wins}
  94.     end
  95.    
  96.     table.sort(sc,function(a,b) return a.s>b.s end)
  97.  
  98.     str = ''
  99.     for k,v in pairs(sc) do
  100.         if k < 10 then
  101.             if str ~= '' then
  102.                 str=str.."<br><J>"..k.."°</J>  |  <VP>"..v.n.."".."<N> "..v.s.." / "..v.w.." <J>"
  103.             else
  104.                 str="<J>"..k.."°</J>  |  <VP>"..v.n.."".."<N> "..v.s.." / "..v.w.." <J>"
  105.             end
  106.         end
  107.     end
  108.              ui.addTextArea(1,'<B><J><font size="13"><p align="center">Top 10 (pontos / vitórias)',name,255,150,360,30,nil,0x2e424d,nil,true)
  109.            ui.addTextArea(2,"<B><font size='12'>"..str,name,255,185,360,150,0x0e232b,0x0e232b,nil,true)
  110.        ui.addTextArea(-1,"<B><p align='center'><font size='15'><R><a href='event:close'>Fechar</a>",name,340,320,190,20,0x3c5063,0x3c5063,nil,true)
  111.     return str
  112. end
  113. function eventSummoningEnd(name)
  114.     tfm.exec.killPlayer(name)
  115. end
  116. function eventNewGame()
  117.     tfm.exec.setGameTime(36000)
  118.     tfm.exec.chatMessage("Não é permitido o uso de objetos de shaman! Use somente a seta pra baixo.",nil)
  119.     vivo=0
  120.     prox=false
  121.     obterJogadores()
  122.     enabled=true
  123.     remain=10
  124.     for name,player in pairs(tfm.get.room.playerList) do
  125.         p[name].rodadas=p[name].rodadas+1
  126.         p[name].eff=(p[name].wins/p[name].rodadas)*100
  127.         if name:sub(1,1) == "*" then
  128.             tfm.exec.killPlayer(name)
  129.             tfm.exec.chatMessage("<R>Você precisa estar logado no Transformice para poder jogar.",name)
  130.         end
  131.         if tfm.get.room.playerList[name].isShaman then
  132.             shaman=name
  133.             tfm.exec.setPlayerScore(name,0,false)
  134.         end
  135.         vivo=vivo+1
  136.     end
  137. end
  138. function eventNewPlayer(name)
  139.             p[name] = {
  140.                 wins = 0,
  141.                 rodadas = 0,
  142.                 eff = 0,
  143.                 pontos = 1
  144.             }
  145.             tfm.exec.bindKeyboard(name,40,true,true)
  146.         tfm.exec.bindKeyboard(name,83,true,true)
  147.         tfm.exec.chatMessage("<VP><b>Sniper!</b><br><N>Sobreviva às bigornas do shaman! Criado por Camilledrain, ranking e perfil feitos por Ahrizrdbrand e Skyrectarrow.<br><br>versão 1.0.6: adição de novos mapas, perfil e ranking temporários",name)
  148. end
  149. function split(t,s)
  150. local a={}
  151. for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
  152.  table.insert(a,i)
  153.  end
  154.     return a
  155. end
  156. for name,player in pairs(tfm.get.room.playerList) do
  157.     eventNewPlayer(name)
  158. end
  159. function obterJogadores()
  160.     players={}
  161.     for name,player in pairs(tfm.get.room.playerList) do
  162.         table.insert(players,name)
  163.     end
  164. end
  165. function eventKeyboard(name,key,down,x,y)
  166.     if y < 150 then
  167.         if enabled == false then
  168.             if loop >= 1.5 then
  169.                 tfm.exec.addShamanObject(10,x,y+60,90,0,25,false)
  170.                 loop=0
  171.             end
  172.         end
  173.     end
  174. end
  175. obterJogadores()
  176. function eventPlayerDied(name)
  177.     p[shaman].pontos=p[shaman].pontos+1
  178.     p[name].pontos=p[name].pontos+1
  179.     vivo=vivo-1
  180.     if tfm.get.room.playerList[name].isShaman then
  181.         p[name].pontos=p[name].pontos-15
  182.         eventWin()
  183.     end
  184.     local i=0
  185.     local n
  186.     for pname,player in pairs(tfm.get.room.playerList) do
  187.         if not player.isDead then
  188.             i=i+1
  189.             n=pname
  190.         end
  191.     end
  192.     if i==0 then
  193.         tfm.exec.newGame(mapas[math.random(#mapas)])
  194.     elseif i==1 then
  195.         tfm.exec.giveCheese(n)
  196.         tfm.exec.playerVictory(n)
  197.         tfm.exec.setGameTime(5)
  198.         p[name].pontos=p[name].pontos+16
  199.     end
  200. end
  201. function eventWin()
  202.     for name,player in pairs(tfm.get.room.playerList) do
  203.         tfm.exec.killPlayer(shaman)
  204.         tfm.exec.giveCheese(name)
  205.         tfm.exec.playerVictory(name)
  206.         tfm.exec.setGameTime(5)
  207.     end
  208. end
  209. function eventPlayerWon(name)
  210.     p[name].pontos=p[name].pontos+10
  211.     vivo=vivo-1
  212.     p[name].wins=p[name].wins+1
  213.     if tfm.get.room.playerList[name].isShaman then
  214.         p[name].wins=p[name].wins+1
  215.         p[name].pontos=p[name].pontos+10
  216.     end
  217. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement