UniverseTeam

Transformice: Sala de Sorteios (v1.1)

Nov 5th, 2016
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.46 KB | None | 0 0
  1. -- Em SeuNome coloque o seu nickname
  2. -- Em Sorteio de Teste coloque o nome do sorteio
  3.  
  4. adm = "SeuNome"
  5. nome = "Sorteio de Teste"
  6.  
  7. mapa=[[<C><P Ca="" /><Z><S><S P="0,0,0.3,0.2,0,0,0,0" L="800" X="401" N="" Y="386" T="0" H="50" /></S><D><DS Y="348" X="400" /></D><O /></Z></C>]]
  8. mapa1=[[<C><P/><Z><S><S L="800" H="50" X="401" N="" Y="386" T="0" P="0,0,0.3,0.2,0,0,0,0" /></S><D><P C="ac2d0c" Y="373" T="15" P="0,0" X="563" /><P C="ac2d0c" Y="373" T="15" X="707" P="0,0" /><P C="ac2d0c" Y="373" T="15" X="90" P="0,0" /><P C="ac2d0c" Y="373" T="15" P="0,0" X="233" /><P C="bd4adb" Y="361" T="130" X="463" P="0,0" /><P C="bd4adb" Y="361" T="130" P="0,0" X="337" /><DS Y="200" X="400" /></D><O /></Z></C>]]
  9. mapa2=[[<C><P D="x_evenements/x_fondHalloween.jpg,0,-250" Ca="" /><Z><S><S L="800" X="400" H="50" Y="386" T="10" P="0,0,0.3,0,0,0,0,0" /></S><D><DS Y="346" X="400" /><P P="0,0" C="470f0e" Y="365" T="15" X="87" /><P P="0,0" Y="166" T="43" X="129" /><P P="0,0" Y="361" T="48" X="215" /><P P="0,0" Y="361" T="44" X="767" /><P P="0,0" C="470f0e" Y="366" T="19" X="715" /><P P="0,0" Y="361" T="44" X="559" /><P P="0,0" C="470f0e" Y="366" T="19" X="614" /><P P="0,0" C="470f0e" Y="366" T="19" X="665" /><P P="0,0" Y="362" T="48" X="507" /></D><O /></Z></C>]]
  10. mapa3=[[<C><P D="x_evenements/x_fondNowel2013.jpg,0,0" /><Z><S><S L="800" H="50" X="400" Y="386" T="10" P="0,0,0.3,0,0,0,0,0" /></S><D><DS Y="346" X="400" /><P P="0,0" C="8a311b" Y="367" T="15" X="84" /><P P="0,0" C="8a311b" Y="367" T="15" X="711" /><P P="0,0" C="8a311b" Y="366" T="15" X="567" /><P P="0,0" C="8a311b" Y="365" T="15" X="227" /></D><O /></Z></C>]]
  11.  
  12. participante = {}
  13. inicio = false
  14. fim=false
  15. qtd=0
  16. fast=0
  17.  
  18. tfm.exec.disableAfkDeath(true)
  19. tfm.exec.disableAutoShaman(true)
  20. tfm.exec.disableAutoNewGame(true)
  21.  
  22. function eventTextAreaCallback(id, p, cmd)
  23.    tfm.exec.setNameColor(adm, 0xd60004)
  24.    if cmd == "entrada" then
  25.         ui.addTextArea(0, "<p align='center'>Participando", p, 210, 370, 380, 20, 1, 0x00ff00, 0.8,false)
  26.         entrada(p, #participante + 1)
  27.    elseif cmd == "map" then
  28.         ui.addPopup(1, 2, "<p align='center'>Mudar Mapa</p><p align='center'><font size='7'>Introduza o id do mapa</p><p align='left'><font color='#FFFFF0' size='9'>[0] Simples</p><p align='left'><font color='#FFFFF0' size='9'>[1] Normal</p><p align='left'><font color='#FFFFF0' size='9'>[2] Halloween</p><p align='left'><font color='#FFFFF0' size='9'>[3] Natal</p>", p, 300, 130, 200, false)
  29.    elseif cmd == "credits" then
  30.         ui.addPopup(-2, 0, "<font color='#EDD200' size='15'><p align='center'><s>Creditos</p></font> <p align='left'><s>Programado por: Ricfonseca & Ricat1998</p> <p align='left'><s>Desenvolvido por: Universe Team</p> <p align='left'><s>Versão em execução: 1.1.0</p> <p align='left'><s> </p> <p align='left'><s>Universe Team & Transformice Universe</p> <p align='left'><s>© 05/11/2016 Versão em Português</p>", p, 270, 120, 250, false)
  31.    elseif cmd == "ajuda" then  
  32.         ui.addPopup(-5, 0, "<font color='#EDD200' size='15'><p align='center'><s>Ajuda & FAQ</p></font> <p align='left'><s>1) Eu posso sair do cafofo?</p> <p align='left'><s>- Sim, você pode sair do cafofo que continuará registado no sorteio.</p> <p align='left'><s>2) Como participo no sorteio?</p> <p align='left'><s>- Para participar no sorteio clique em participar na barra cá em baixo.</p> <p align='left'><s>3) Quando vai começar o sorteio?</p> <p align='left'><s>- O sorteio começa quando o admistrador assim o entender.</p>", p, 168, 120, 460, false)
  33.    elseif cmd == "inicio" then
  34.         ui.addPopup(0, 2, "<p align='center'>Quantidade de vencedores", p, 300, 200, 200, false)
  35.    elseif cmd == "novo" then
  36.         novo()
  37.    end
  38. end
  39.  
  40. function eventNewPlayer(p)
  41.     tfm.exec.respawnPlayer(p)
  42.     tfm.exec.setNameColor(adm, 0xd60004)
  43.     ui.addTextArea(0, "<p align='center'><a href='event:entrada'>Clique para participar no sorteio!", p, 210, 370, 380, 20, 1, 0xffff00, 0.8, false)
  44.     ui.addTextArea(-2, "<p align='center'><a href='event:credits'>Creditos", p, 21, 370, 60, 20, 1, 0x0000ff, 0.8, false)
  45.     ui.addTextArea(-5, "<p align='center'><a href='event:ajuda'>Ajuda", p, 110, 370, 60, 20, 1, 0x0000ff, 0.8, false)
  46.     ui.addTextArea(-3, "<p align='center'><font size='30'>"..nome, p, 5, 40, 790, 40, 1, 1, 0.8, false)
  47. end
  48.  
  49. function eventPopupAnswer(id, p, cmd)
  50.  if id == 1 then
  51.   if tonumber(cmd, 10) then
  52.    if tonumber(cmd, 10) == 0 then
  53.     tfm.exec.newGame(mapa)
  54.    end
  55.    if tonumber(cmd, 10) == 1 then
  56.     tfm.exec.newGame(mapa1)
  57.    end
  58.    if tonumber(cmd, 10) == 2 then
  59.     tfm.exec.newGame(mapa2)
  60.    end
  61.    if tonumber(cmd, 10) == 3 then
  62.     tfm.exec.newGame(mapa3)
  63.    end
  64.    tfm.exec.setUIMapName("Sala de Sorteios")
  65.   end
  66.  end
  67.  if id == 0 then
  68.   if tonumber(cmd, 10) then
  69.         if tonumber(cmd, 10) >= 1 and tonumber(cmd, 10) <= #participante then
  70.             ui.removeTextArea(0, nil)
  71.             ui.removeTextArea(-1, nil)
  72.             ui.removeTextArea(-6, nil)
  73.             qtd = tonumber(cmd, 10)
  74.             fast = math.random(5,15)
  75.             inicio = true
  76.         end
  77.   end
  78.  end
  79. end
  80.  
  81. function participando(p)
  82.     for i, v in pairs(participante) do
  83.         if v == p then
  84.             return true
  85.         end
  86.     end
  87.     return false
  88. end
  89.  
  90. function entrada(p, num)
  91.     if not participando(p) then
  92.         participante[num] = p
  93.         ui.addTextArea(num, "<p align='center'>" .. p, nil, ((num-1)%8)*100+5, math.floor((num-1)/8)*30+100, 90, 20, 1, 1, 0.8, false)
  94.     end
  95. end
  96.  
  97. function novo()
  98.     for i=1, #participante do
  99.         ui.removeTextArea(i, nil)
  100.         table.remove(participante, 1)
  101.     end
  102.     ui.addTextArea(0, "<p align='center'><a href='event:entrada'>Clique para participar no sorteio!", nil, 210, 370, 380, 20, 1, 0xffff00, 0.8, false)
  103.     ui.addTextArea(-2, "<p align='center'><a href='event:credits'>Creditos", nil, 12, 370, 80, 20, 1, 0x0000ff, 0.8, false)
  104.     ui.addTextArea(-5, "<p align='center'><a href='event:ajuda'>Ajuda", nil, 111, 370, 80, 20, 1, 0x0000ff, 0.8, false)
  105.     ui.addTextArea(-1, "<p align='center'><a href='event:inicio'>Iniciar", adm, 707, 370, 80, 20, 1, 0xd60004, 0.8,false)
  106.     ui.addTextArea(-6, "<p align='center'><a href='event:map'>Mapa", adm, 609, 370, 80, 20, 1, 0xd60004, 0.8,false)
  107.     tfm.exec.removePhysicObject(0)
  108.     fim = false
  109. end
  110.  
  111. function sorteio(tipo)
  112.     local lista = {}
  113.     local sorteado = 0
  114.     for i=1, #participante do
  115.         lista[i] = i
  116.     end
  117.     local rand = 0
  118.     for i, v in pairs(participante) do
  119.         ui.addTextArea(i, "<p align='center'>" .. v, nil, ((i-1)%8)*100+5, math.floor((i-1)/8)*30+100, 90, 20, 1, 1, 0.8, false)
  120.     end
  121.     for i=1, qtd do
  122.         sorteado = math.random(#lista)
  123.         rand = lista[sorteado]
  124.         table.remove(lista, sorteado)
  125.         if tipo == "quase" then
  126.             ui.addTextArea(rand, "<p align='center'><font color='#ffff00'>" .. participante[rand], nil, ((rand-1)%8)*100+5, math.floor((rand-1)/8)*30+100, 90, 20, 1, 0xffff00, 0.8, false)
  127.         elseif tipo == "final" then
  128.             ui.addTextArea(rand, "<p align='center'><font color='#00ff00'><b>" .. participante[rand], nil, ((rand-1)%8)*100+5, math.floor((rand-1)/8)*30+100, 90, 20, 1, 0x00ff00, 0.8, false)
  129.         end
  130.     end
  131. end
  132.  
  133. function eventLoop()
  134.     if inicio then
  135.         if fast > 0 then
  136.             sorteio("quase")
  137.             fast = fast - 1
  138.         else
  139.             sorteio("final")
  140.             inicio = false
  141.             fim = true
  142.             ui.addTextArea(-1, "<p align='center'><a href='event:novo'>Novo sorteio", adm, 650, 370, 100, 20, 1, 0xd60004, 0.8,false)
  143.         end
  144.     end
  145.     if fim then
  146.         tfm.exec.displayParticle(math.random(21,24), math.random(1,800), 20, math.random(-20,20)/100, math.random(10,1000)/100, 0, 0, nil)
  147.         tfm.exec.displayParticle(math.random(21,24), math.random(1,800), 20, math.random(-20,20)/100, math.random(10,1000)/100, 0, 0, nil)
  148.         tfm.exec.displayParticle(math.random(21,24), math.random(1,800), 20, math.random(-20,20)/100, math.random(10,1000)/100, 0, 0, nil)
  149.     end
  150. end
  151.  
  152. function eventPlayerDied(p)
  153.  tfm.exec.respawnPlayer(p)
  154. end
  155.  
  156. tfm.exec.newGame(mapa1)
  157. ui.addTextArea(0, "<p align='center'><a href='event:entrada'>Clique para participar no sorteio!", nil, 210, 370, 380, 20, 1, 0xffff00, 0.8, false)
  158. ui.addTextArea(-2, "<p align='center'><a href='event:credits'>Creditos", nil, 12, 370, 80, 20, 1, 0x0000ff, 0.8, false)
  159. ui.addTextArea(-5, "<p align='center'><a href='event:ajuda'>Ajuda", nil, 111, 370, 80, 20, 1, 0x0000ff, 0.8, false)
  160. ui.addTextArea(-1, "<p align='center'><a href='event:inicio'>Iniciar", adm, 707, 370, 80, 20, 1, 0xd60004, 0.8,false)
  161. ui.addTextArea(-6, "<p align='center'><a href='event:map'>Mapa", adm, 609, 370, 80, 20, 1, 0xd60004, 0.8,false)
  162. ui.addTextArea(-3, "<p align='center'><font size='30px'>"..nome, nil, 5, 40, 790, 40, 1, 1, 0.8, false)
  163. tfm.exec.setUIMapName("Sala de Sorteios")
Add Comment
Please, Sign In to add comment