Advertisement
Tectoon

[TFM] BaffVamp

May 4th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.25 KB | None | 0 0
  1. -- BaffVamp
  2. -- Tables
  3. minigame={
  4.     ["version"]="1.0";
  5.     ["vampiros"]=0;
  6.     ["ratos"]=0;
  7.     ["alive"]=0;
  8. };
  9. players={}
  10. toDespawn={}
  11. mapas={"258972","334445","423793","615791","760329","812007","946893","955523","1296883","1542025","1638989","1676629","1782151","2389613","2393716","2403639","2428213","2429313","2435372","2541364","2561153","2563004","2680717","2683284","2686097","2693083","2761246","2821033","2910904","2929496","2938327","2940045","2944932","2951616","2953590","2956031","2956156","2971085","2975699","2976059","2983430","2986318","2999898","3001393","3006311","3020988","3027934","3032840","3033710","3044452","3057493","3061098","3068111","3069138","3079426","3090849","3101671","3103683","3105156","3110659","3119050","3120924","3128337","3140275","3167932","3170618","3187755","3195331","3197349","3225462","3240230","3270111","3292389","3296041","3333339","3334083","3337200","3359267","3377553","3430472","3435288","3460936","3482009","3485896","3488764","3509662","3515991","3611033","3745155","3745168","3808004","3946003"}
  12. vamp=false;
  13. -- Inicio do Script
  14. tfm.exec.disableAutoNewGame(true)
  15. tfm.exec.disableAutoShaman(true)
  16. tfm.exec.disableAutoTimeLeft(true)
  17. tfm.exec.newGame(mapas[math.random(#mapas)])
  18. -- Ffa
  19. -- Dar keys
  20. function eventNewPlayer(name)
  21.     for i,key in ipairs({32,40,83}) do
  22.         tfm.exec.bindKeyboard(name,key,true,true)
  23.     end
  24.     players[name]={
  25.         timestamp=os.time(),
  26.         offsets={x=2, y=10}
  27.     }
  28. end
  29. for player in pairs(tfm.get.room.playerList) do
  30. eventNewPlayer(player)
  31. end
  32. -- Eventos do teclado
  33. function eventKeyboard(name,key,down,x,y)
  34.     if (key==32 or key==40 or key==83) and not tfm.get.room.playerList[name].isDead and started and not tfm.get.room.playerList[name].isVampire then
  35.         if players[name].timestamp < os.time()-1000 then
  36.             local id
  37.             if tfm.get.room.playerList[name].isFacingRight then
  38.                 id=tfm.exec.addShamanObject(19,x+players[name].offsets.x,y+players[name].offsets.y)
  39.             else
  40.                 id=tfm.exec.addShamanObject(20,x+players[name].offsets.x,y+players[name].offsets.y)
  41.             end
  42.             players[name].timestamp=os.time()
  43.             table.insert(toDespawn,{os.time(),id})
  44.         end
  45.     end
  46.     if (key==32 or key==40 or key==83) and not tfm.get.room.playerList[name].isDead and started and  tfm.get.room.playerList[name].isVampire then
  47.         tfm.exec.movePlayer(name,xx,yy,false,0,-50,false)
  48.     end
  49. end
  50. -- Player vira vampiro
  51. function eventPlayerVampire(player)
  52.     if vamp == false then
  53.     vamp=true;
  54. end
  55.     minigame.vampiros=minigame.vampiros+1;
  56.     minigame.ratos=minigame.ratos-1;
  57.     teamWon()
  58. end
  59. -- Jogador morre
  60. function eventPlayerDied(player)
  61.     if tfm.get.room.playerList[player].isVampire then
  62.         minigame.vampiros=minigame.vampiros-1;
  63.     end
  64.     if not tfm.get.room.playerList[player].isVampire then
  65.         minigame.ratos=minigame.ratos-1;
  66.     end
  67.     minigame.alive=minigame.alive-1;
  68.     teamWon()
  69. end
  70. -- Loop
  71. function eventLoop(time,rt)
  72.         if time >= 3000 and not started then
  73.         started=true
  74.     end
  75.     if rt<=0 or minigame.alive == 0 then
  76.         tfm.exec.newGame(mapas[math.random(#mapas)])
  77.     end
  78.     for i,cannon in ipairs(toDespawn) do
  79.         if cannon[1] <= os.time()-3000 then
  80.             tfm.exec.removeObject(cannon[2])
  81.             table.remove(toDespawn,i)
  82.         end
  83.     end
  84.     tfm.exec.setUIMapName("<R>Vampiros :<N2> "..minigame.vampiros.."   <G>|   <CH>Ratos :<N2> "..minigame.ratos.."")
  85. end
  86. -- Novo Jogador
  87. function eventNewGame()
  88.     vamp=false;
  89.     started=false;
  90.     minigame.vampiros=0;
  91.     minigame.ratos=0;
  92.     minigame.alive=0;
  93.     for player in pairs(tfm.get.room.playerList) do
  94.         minigame.ratos=minigame.ratos+1;
  95.         minigame.alive=minigame.alive+1;
  96.     end
  97.     ui.removeTextArea(0,NIL)
  98. end
  99. -- Verificar time ganhador
  100. function teamWon()
  101.     if vamp == true then
  102.         if minigame.vampiros == 0 then
  103.             ui.addTextArea(0,"<p align='center'><font size='18'><VP>Os <CH>ratos<VP> ganharam a partida!</font></p>",NIL,300,150,200,50,1,1,0.5,true)
  104.             for player in pairs(tfm.get.room.playerList) do
  105.                 tfm.exec.giveCheese(player)
  106.                 tfm.exec.playerVictory(player)
  107.             end
  108.             tfm.exec.setGameTime(15)
  109.         end
  110.         if minigame.ratos == 0 then
  111.             ui.addTextArea(0,"<p align='center'><font size='18'><VP>Os <R>vampiros<VP> ganharam a partida!</font></p>",NIL,300,150,200,50,1,1,0.5,true)
  112.             tfm.exec.setGameTime(15)
  113.         end
  114.     end
  115. end
  116. -- Jogador ganha
  117. function eventPLayerWon(player)
  118.     minigame.alive=minigame.alive+1;
  119. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement