Advertisement
Bolodefchoco_LUAXML

[Function] Rotação de Mapas

Oct 18th, 2015
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.16 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 18/10/2015
  3. --Last update: 17/05/2016
  4. --[[ Notes:
  5.     Does:
  6.         Uma rotação automática usando a função rotate_maps
  7.     Args:
  8.         m --> Tabela de Mapas.
  9.         o --> Tabela de Configurações:
  10.                 disableSha --> Caso true, desativará o shaman.
  11.                 disableAfk --> Caso true, desativará o AfkDeath.
  12.                 time --> Seleciona o tempo de cada mapa (em minutos).
  13.                 SCheese --> Caso true, todos começarão com queijo.
  14.                 SShaman --> Caso true, todos começarão como shaman.
  15.                 SVamp --> Caso true, todos começarão como vampiro.
  16.                 SRev --> Caso true, todos aqueles que morrerem durante a partida irão reviver.
  17. ]]--
  18.  
  19. math.randomseed(os.time())
  20.  
  21. event={}addEventListener=function(a,b)a=a:lower()event[a]=event[a]or{}local c=0;for d in next,event[a]do c=c+1 end;event[a]["e"..c+1]=b;return"e"..c+1 end;do for e,f in next,{"NewGame","PlayerDied","Loop"}do _G["event"..f]=function(...)for g,h in next,event[f:lower()]or{}do h(...)end end end end
  22.  
  23. rotate_maps=function(m,o)
  24.     local currentMap=""
  25.     tfm.exec.disableAutoNewGame()
  26.     if o.disableSha then tfm.exec.disableAutoShaman() end
  27.     if o.disableAfk then tfm.exec.disableAfkDeath() end
  28.     addEventListener("NewGame",function()
  29.         currentMap=tfm.get.room.currentMap
  30.         if o.time then tfm.exec.setGameTime(o.time*60) end
  31.         if o.SCheese then table.foreach(tfm.get.room.playerList,tfm.exec.giveCheese) end
  32.         if o.SShaman then table.foreach(tfm.get.room.playerList,tfm.exec.setShaman) end
  33.         if o.SVamp then table.foreach(tfm.get.room.playerList,tfm.exec.setVampirePlayer) end
  34.     end)
  35.     addEventListener("PlayerDied",function()
  36.         if o.SRev then table.foreach(tfm.get.room.playerList,tfm.exec.respawnPlayer) end
  37.     end)
  38.     addEventListener("Loop",function(_,r)
  39.         local maps=m[math.random(#m)]
  40.         local i=0  
  41.         for k,v in next,tfm.get.room.playerList do if not v.isDead then i=i+1 end end
  42.         if i==0 or r<=0 or currentMap~=tfm.get.room.currentMap then tfm.exec.newGame(maps~=currentMap and maps or m[math.random(#m)]) end
  43.     end)
  44.      tfm.exec.newGame(m[math.random(#m)])
  45. end
  46.  
  47. rotate_maps({1,2,3,4,5,6},{
  48.     disableSha=false,
  49.     disableAfk=true,
  50.     time=2.5,
  51.     SCheese=false,
  52.     SShaman=false,
  53.     SVamp=false,
  54.     SRev=true,
  55. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement