Brenower

[TFM][Brenower] Ballua

Feb 8th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.89 KB | None | 0 0
  1. -- Ballua
  2. -- Créditos:Brenower
  3. -- Tables
  4. data={}
  5. mg={
  6.     ["baloes"]=0;
  7.     ["ids"]=100;
  8.     ["sta"]=false;
  9.     ["time"]=os.time();
  10.     maps={0,4560949,4701122,4701807,4701827};
  11.     dif1={0};
  12.     dif2={4701827,4701807,4701122};
  13.     dif3={4560949,4788077};
  14. };
  15. lang={
  16.     EN={
  17.         ["d1"]="Easy";
  18.         ["d2"]="Medium";
  19.         ["d3"]="Hard";
  20.         ["we"]="<J>Wellcome to minigame <v>ballua<j>!";
  21.     };
  22.     BR={
  23.         ["d1"]="Fácil";
  24.         ["d2"]="Medio";
  25.         ["d3"]="Difícil";
  26.         ["we"]="<J>Bem vindo ao minigame <v>ballua<j>!";
  27.     }; 
  28. };
  29. -- Functions
  30. function giveData(p)
  31.     if not data[p] then
  32.         nD={
  33.             ["baloes"]=0;
  34.             ["pontos"]=0;
  35.             ["vy"]=0;
  36.             ["id"]=nil;
  37.             ["trans"]=false;
  38.             ["time"]=os.time();
  39.             ["t"]=0;
  40.             ["q"]=false;
  41.         };
  42.         data[p]=nD;
  43.         mg.ids=mg.ids+1;
  44.         data[p].t=mg.ids;
  45.     end
  46. end
  47.  
  48. function mapLevel(map)
  49.     map = tonumber(map:sub(2))
  50.         for i,v in pairs(mg.dif1) do
  51.             if tonumber(v) == map then
  52.                 tfm.exec.setUIMapName("<CH>"..trans("d1").." <BL>- "..tfm.get.room.currentMap.." - <J>"..tfm.get.room.xmlMapInfo.author)
  53.             end
  54.         end
  55.         for i,v in pairs(mg.dif2) do
  56.             if tonumber(v) == map then
  57.                 tfm.exec.setUIMapName("<CH>"..trans("d2").." <BL>- "..tfm.get.room.currentMap.." - <J>"..tfm.get.room.xmlMapInfo.author)
  58.             end
  59.         end
  60.         for i,v in pairs(mg.dif3) do
  61.             if tonumber(v) == map then
  62.                 tfm.exec.setUIMapName("<CH>"..trans("d3").." <BL>- "..tfm.get.room.currentMap.." - <J>"..tfm.get.room.xmlMapInfo.author)
  63.             end
  64.         end
  65. end
  66.  
  67. function trans(msg,sender)
  68.     if lang[tfm.get.room.community] then
  69.         msg = lang[tfm.get.community][msg]
  70.     else
  71.         msg = lang.EN[msg]
  72.     end
  73.     if sender then
  74.         msg = msg:format(sender[1],sender[2],sender[3],sender[4],sender[5],sender[6],sender[7],sender[8],sender[9],sender[10])
  75.     end
  76.     return msg
  77. end
  78. -- Novo jogador entra na sala
  79. function eventNewPlayer(p)
  80.     tfm.exec.chatMessage(trans("we"),p)
  81.     giveData(p)
  82.     tfm.exec.bindKeyboard(p,32,false,true)
  83.     tfm.exec.bindKeyboard(p,40,false,true)
  84.     ui.addTextArea(30,"",nil,-20,-425,300,300,0x6a7495,0x6a7495,1,true)
  85. end
  86. -- Inicio do script
  87. tfm.exec.disableAutoNewGame(true)
  88. tfm.exec.disableAutoShaman(true)
  89. tfm.exec.disableAutoTimeLeft(true)
  90. tfm.exec.newGame(mg.maps[math.random(#mg.maps)])
  91. for i in pairs(tfm.get.room.playerList) do
  92.     eventNewPlayer(i)
  93. end
  94. -- Eventos do teclado
  95. function eventKeyboard(p,key,down,x,y)
  96.     if not tfm.get.room.playerList[p].isDead and mg.sta == true and data[p].time < os.time()-1600 then
  97.         if data[p].trans == false then
  98.             id=tfm.exec.addShamanObject(28,x,y,0,0,0,true)
  99.             data[p].trans=true;
  100.             data[p].id=id;
  101.             ui.addTextArea(data[p].t,"<font size='17'color='#000000' face='Soopafresh,Verdana'><I>ballua!</I></font>",nil,x-25,y,100,50,0,0,0)
  102.             ui.addTextArea(data[p].t+500,"<font size='17'color='#1C8484' face='Soopafresh,Verdana'><I>ballua!</I></font>",nil,x-25+2,y-1,100,50,0,0,0)
  103.             data[p].time=os.time();
  104.             else
  105.             data[p].trans=false;
  106.             ui.removeTextArea(data[p].t+250,nil)
  107.             tfm.exec.movePlayer(p,tfm.get.room.objectList[data[p].id].x,tfm.get.room.objectList[data[p].id].y,false,0,-25)
  108.             tfm.exec.removeObject(data[p].id)
  109.             data[p].time=os.time();
  110.         end
  111.     end
  112. end
  113. -- Loop
  114. function eventLoop(ct,rt)
  115.     for i in pairs(data) do
  116.         if data[i].trans == true then
  117.             tfm.exec.movePlayer(i,30,-200,false,0,-100)
  118.         end
  119.         if data[i].time < os.time()-1500 then
  120.             ui.removeTextArea(data[i].t,nil)
  121.             ui.removeTextArea(data[i].t+500,nil)
  122.             if data[i].trans == true then
  123.                 ui.addTextArea(data[i].t+250,i,nil,tfm.get.room.objectList[data[i].id].x-30,tfm.get.room.objectList[data[i].id].y,nil,nil,1,1,0.3)
  124.             end
  125.         end
  126.     end
  127.     if rt <= 0 then
  128.         tfm.exec.newGame(mg.maps[math.random(#mg.maps)])
  129.     end
  130.     if mg.time < os.time()-3000 then
  131.         mg.sta=true;
  132.     end
  133. end
  134. -- Jogador morre
  135. function eventPlayerDied(p)
  136.     data[p].time=os.time();
  137.     tfm.exec.respawnPlayer(p)
  138.     if data[p].trans == true and data[p].q == true then
  139.         tfm.exec.movePlayer(p,30,-200,false,0,-100)
  140.         tfm.exec.giveCheese(p)
  141.     end
  142. end
  143. -- Jogador pega o queijo
  144. function eventPlayerGetCheese(p)
  145.     data[p].q=true;
  146. end
  147. -- Novo jogo inicia-se
  148. function eventNewGame()
  149.     tfm.exec.setGameTime(63)
  150.     mapLevel(tfm.get.room.currentMap)
  151.     mg.time=os.time();
  152.     mg.sta=false;
  153.     for i in pairs(data) do
  154.         data[i].trans=false;
  155.         data[i].q=false;
  156.         ui.removeTextArea(data[i].t+250,nil)
  157.     end
  158. end
  159. -- Jogador ganha a partida
  160. function eventPlayerWon(p)
  161.     local v = 0;
  162.     for i in pairs(tfm.get.room.playerList) do
  163.         if not tfm.get.room.playerList[i].isDead then
  164.             v=v+1;
  165.         end
  166.     end
  167.     if v == 0 then
  168.         tfm.exec.newGame(mg.maps[math.random(#mg.maps)])
  169.     end
  170. end
  171. -- Comandos
  172. function eventChatCommand(p,cm)
  173.     if p == [[Brenower]] then
  174.         if cm:sub(1) == [[c]] then
  175.             tfm.exec.chatMessage("<R>• <b>"..p.."</b> : <j>"..cm:sub(3))
  176.         end
  177.         if cm:sub(2) == [[np]] then
  178.             tfm.exec.newGame(cm:sub(4))
  179.         end
  180.     end
  181.     if cm == [[help]] then
  182.         tfm.exec.chatMessage("<R>ERROR",p)
  183.     end
  184.     if cm == [[noob]] then
  185.         tfm.exec.chatMessage("<J>PR0 :P",p)
  186.     end
  187. end
Advertisement
Add Comment
Please, Sign In to add comment