Brenower

[Minigame] Meep Gamer

Feb 13th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.30 KB | None | 0 0
  1. -- Meep Gamer v3.0
  2. -- Créditos:Brenower
  3. -- Tables
  4. data={};
  5. mg={
  6.     ["alive"]=0;
  7.     ["map"]=0;
  8.     ["car"]=0;
  9.     ["team1"]=0;
  10.     ["team2"]=0;
  11.     ["win"]=false;
  12. };
  13. maps={"4741672"};
  14. players={};
  15. -- Functions
  16. function giveData(p)
  17.     if not data[p] then
  18.         nD={
  19.             ["team"]="...";
  20.             ["time"]=os.time();
  21.             ["wins"]=0;
  22.             ["morts"]=0;
  23.             ["winst"]=0;
  24.         };
  25.         data[p] = nD;
  26.     end
  27.     tfm.exec.bindKeyboard(p,32,false,true)
  28. end
  29.  
  30. function nextMap()
  31.     if mg.map == 1 or mg.map == 2 or mg.map == 3 then
  32.         tfm.exec.newGame(maps[math.random(#maps)])
  33.         tfm.exec.setGameTime(120)
  34.             for i in pairs(tfm.get.room.playerList) do
  35.                 tfm.exec.giveMeep(i)
  36.                 data[i].time=os.time();
  37.             end
  38.     else
  39.         mg.map=0;
  40.         tfm.exec.newGame(4741672)
  41.         tfm.exec.setGameTime(15)
  42.     end
  43. end
  44.  
  45. function giveWin()
  46.     for vv in pairs(tfm.get.room.playerList) do
  47.         tfm.exec.giveCheese(vv)
  48.         tfm.exec.playerVictory(vv)
  49.         tfm.exec.setGameTime(10)
  50.     end
  51. end
  52.  
  53. function team()
  54.     if mg.map == 3 then
  55.         local players = {};
  56.         for i in pairs(tfm.get.room.playerList) do
  57.             table.insert(players,i)
  58.         end
  59.         for i=1,#players do
  60.             local r = math.random(#players)
  61.             local p = players[r]
  62.             if i%2==0 then
  63.                 data[p].team="red";
  64.                 tfm.exec.setNameColor(p,0xCB546B)
  65.             else
  66.                 data[p].team="blue";
  67.                 tfm.exec.setNameColor(p,0x2F7FCC)
  68.             end
  69.                 table.remove(players,r)
  70.         end
  71.         else
  72.             for i in pairs(tfm.get.room.playerList) do
  73.                 tfm.exec.setNameColor(i,0xC2C2DA)
  74.             end
  75.     end
  76. end
  77.  
  78. function stats(p,pp)
  79.     ui.addTextArea(3,"<font size='14'>Partidas normais:<br /><br /><font size='12'><BL>Partidas ganhadas : <v>"..data[p].wins.."<br /><BL>Mortes : <v>"..data[p].morts.."<br /><br /><font size='14'><N>Partidas em equipe:<font size='12'><br /><br /><BL>Partidas ganhadas : <v>"..data[p].winst.."",pp,212,133,200,150,0x3C5064,0x2E5A61,1,true)
  80.     ui.addTextArea(2,"<font size='18' face='Soopafresh'> <v>"..p.."  <a href='event:close'>X</a>",pp,210,100,nil,nil,0x324650,0x2E5A61,1,true)
  81.     ui.addTextArea(1,"",pp,130,100,75,75,0x1E3D42,0x2E5A61,1,true)
  82. end
  83.  
  84. function check()
  85.     if mg.map == 2 or mg.map == 4 then
  86.         local i = 0;
  87.         for vv,v in pairs(tfm.get.room.playerList) do
  88.             if not v.isDead then
  89.                 i=i+1;
  90.             end
  91.         end
  92.         if i == 1 then
  93.             giveWin()
  94.         end
  95.     end
  96.     if mg.map == 3 then
  97.         local t1 = 0;
  98.         local t2 = 0;
  99.         for vv,v in pairs(tfm.get.room.playerList) do
  100.             if not tfm.get.room.playerList[vv].isDead then
  101.                 if data[vv].team == "blue" then
  102.                     t1=t1+1;
  103.                 else
  104.                     t2=t2+1;
  105.                 end
  106.             end
  107.         end
  108.         if t1 == 0 and t2 ~= 0 then
  109.             giveWin()
  110.         end
  111.         if t1 ~= 0 and t2 == 0 then
  112.             giveWin()
  113.         end
  114.     end
  115. end
  116. -- Novo jogador entra na sala
  117. function eventNewPlayer(p)
  118.     giveData(p)
  119.     tfm.exec.bindKeyboard(p,32,false,true)
  120. end
  121. -- Inicio do script
  122. tfm.exec.disableAutoShaman(true)
  123. tfm.exec.disableAutoNewGame(true)
  124. tfm.exec.disableAutoTimeLeft(true)
  125. print("<img src='http://i.imgur.com/zDRQwLM.png' /><br /><br /><br /><br /><br />")
  126. nextMap()
  127. for i in pairs(tfm.get.room.playerList) do
  128.     eventNewPlayer(i)
  129. end
  130. -- Loop
  131. function eventLoop(ct,rt)
  132.     if mg.map == 1 then
  133.         local x = {100,300,500,700};
  134.         local y = 230
  135.     tfm.exec.displayParticle(20,x[math.random(#x)],y-70,0,0,0,0,NIL)
  136.     tfm.exec.displayParticle(20,x[math.random(#x)]+100,y,0,0,0,0,NIL)
  137.     end
  138.     if rt <= 0 then
  139.         nextMap()
  140.     end
  141. end
  142. -- Novo jogo
  143. function eventNewGame()
  144.     mg.map=mg.map+1;
  145.     team()
  146. end
  147. -- Jogador morre
  148. function eventPlayerDied(p)
  149.     check()
  150.     data[p].morts=data[p].morts+1;
  151. end
  152. -- Eventos do teclado
  153. function eventKeyboard(p,key,down,x,y)
  154.     if mg.map == 4 and not tfm.get.room.playerList[p].isDead and data[p].time < os.time()-10000 then
  155.         data[p].time=os.time();
  156.         tfm.exec.explosion(x,y,25,100,true)
  157.         tfm.exec.movePlayer(p,nil,nil,false,-10,-10)
  158.     end
  159. end
  160. -- Comandos
  161. function eventChatCommand(p,cm)
  162.     local arg = {};
  163.     for i in cm:gmatch("[^%s]+") do
  164.         table.insert(arg,i)
  165.     end
  166.     if arg[1] == [[stats]] or arg[1] == [[p]] or arg[1] == [[profile]] or arg[1] == [[perfil]] and data[arg[2]] then
  167.         stats(arg[2],p)
  168.     end
  169. end
  170. -- Callbacks
  171. function eventTextAreaCallback(id,p,l)
  172.     if l == [[close]] then
  173.         if id == 2 then
  174.             for i = 1,3 do
  175.                 ui.removeTextArea(i,p)
  176.             end
  177.         end
  178.     end
  179. end
  180. -- Jogador ganha a partida
  181. function eventPlayerWon(p)
  182.     if mg.map == 3 then
  183.         data[p].winst=data[p].winst+1;
  184.     else
  185.         data[p].wins=data[p].wins+1;
  186.     end
  187. end
Advertisement
Add Comment
Please, Sign In to add comment