musugas

Preguntas y respuestas musugas

Dec 25th, 2015
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 26.05 KB | None | 0 0
  1. --Tiempo para cada respuesta en segundos
  2. local timeForAnswer = 30
  3. local timeForAnswers = 30
  4. -- Administradores que pueden hacer preguntas.
  5. local admins = {tu nombre=true}
  6. --Ronda que se jugara
  7. local ronda = 3
  8.  
  9.  
  10.  
  11. --No tocar
  12. local questions = {}
  13. local data = {}
  14. local correctoResponder= {}
  15. local selectQuest = ""
  16. local winners = {}
  17. local currentQuestion = nil
  18. local podiu
  19. local m = {{},0}
  20. local timeToQuestion = false
  21. local answerMaking = 0
  22. local preguntado
  23. local r = ""
  24. local text="Mi pregunta [Click aqui para cambiar]"
  25. local opcionesRespuesta = {"Mi respuesta 1"}
  26. local editing=0
  27. local correcta=0
  28. local correctAnswer = {}
  29. local xml = '<C><P defilante="0,0,0,1" L="4000" /><Z><S /><D /><O /></Z></C>'
  30. local playersAlive = 0
  31. local resp2 = "Respuesta"
  32. local modeGame = 1
  33. local quejas = {}
  34. local color = {0x732374,0x227682}
  35. local ultimoIdPiso = 0
  36. local xposition = 50
  37. local colors = ""
  38. local incorrectAnswer = {}
  39. local map = '<C><P Ca="" D="../share/Noel_2012/meli/1280_960.jpg,0,-250" /><Z><S><S P="0,0,0.3,0.2,0,0,0,0" L="100" o="ffffffff" lua="1000" H="80" c="4" Y="350" T="12" X="100" /><S P="0,0,0.3,0.2,0,0,0,0" L="100" o="ffffffff" lua="1001" H="80" c="4" Y="350" T="12" X="250" /><S P="0,0,0.3,0.2,0,0,0,0" L="100" o="ffffffff" lua="1002" H="80" c="4" Y="350" T="12" X="400" /><S P="0,0,0.3,0.2,0,0,0,0" L="100" o="ffffffff" lua="1003" H="80" c="4" Y="350" T="12" X="550" /><S P="0,0,0.3,0.2,0,0,0,0" L="100" o="ffffffff" lua="1004" H="80" c="4" Y="350" T="12" X="700" /><S L="106" H="46" X="100" Y="410" T="5" P="0,0,0.3,0.2,0,0,0,0" /><S L="106" H="46" X="250" Y="410" T="5" P="0,0,0.3,0.2,0,0,0,0" /><S L="106" H="46" X="400" Y="410" T="5" P="0,0,0.3,0.2,0,0,0,0" /><S L="106" H="46" X="550" Y="410" T="5" P="0,0,0.3,0.2,0,0,0,0" /><S L="106" H="46" X="700" Y="410" T="5" P="0,0,0.3,0.2,0,0,0,0" /><S L="109" o="c0fc01" H="10" X="101" Y="390" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="109" o="7325f3" H="10" X="250" Y="390" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="109" o="fc0000" H="10" X="400" Y="390" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="109" o="33e900" H="10" X="550" Y="390" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="109" o="dfe3" H="10" X="699" Y="390" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="55" o="ffffffff" H="10" X="404" Y="238" T="12" P="0,0,0.3,0.2,0,0,0,0" /></S><D><DS Y="208" X="408" /></D><O /></Z></C>'
  40.  
  41. set1={["type"]=14,["width"]=40,["height"]=10,["color"]=0x00ff00,["dynamic"]=false,["true"]=false,["foreground"]=true}
  42. set2={["type"]=14,["width"]=10,["height"]=200,["color"]=0x00ff00,["dynamic"]=false,["true"]=false,["foreground"]=true}
  43. set3={["type"]=14,["width"]=10,["height"]=200,["color"]=0x00ff00,["dynamic"]=false,["true"]=false,["foreground"]=true}
  44.  
  45. -- 1 = Multiple // 2 = Sencilla // 3 = Plataforma
  46.  
  47. function main()
  48.     tfm.exec.disableAutoNewGame(true)
  49.     tfm.exec.disableAutoTimeLeft(true)
  50.     tfm.exec.disableAutoShaman(true)
  51.     tfm.exec.disableAfkDeath (true)
  52.         for i, command in ipairs ({"q","msg","queja","verqueja"}) do
  53.            system.disableChatCommandDisplay(command,true)
  54.         end    
  55.         tfm.exec.newGame(xml);
  56.         tfm.exec.setUIMapName("<v><b>TransforBrainy</b> <BL>\t|\t<N>Hola!, en breve comenzaremos <t>Preparate!<>")
  57.         table.foreach(tfm.get.room.playerList, eventNewPlayer)
  58. end
  59.  
  60. function randomColor(player)
  61.     colors = "0x" .. string.format("%X", math.random(0x000000, 0xFFFFFF))
  62.     set1={["type"]=12,["width"]=40,["height"]=10,["color"]=colors,["dynamic"]=false,["true"]=false,["foreground"]=true}
  63.     set2={["type"]=12,["width"]=10,["height"]=200,["color"]=colors,["dynamic"]=false,["true"]=false,["foreground"]=true}
  64.     set3={["type"]=12,["width"]=10,["height"]=200,["color"]=colors,["dynamic"]=false,["true"]=false,["foreground"]=true}
  65.     tfm.exec.setNameColor (player, colors)
  66. end
  67.  
  68.  
  69. function eventNewPlayer(name)
  70.         if admins[name] then
  71.                 ui.addTextArea(6500, "<a href='event:qsencilla'>Sencilla</a> | <a href='event:qmultiple'>Multiple</a>", name,0,380,nil,20,color[1], color[2],nil,true)
  72.  
  73.         end
  74.        if (not data[name]) then
  75.        data[name] = {
  76.            puntos = 0,
  77.            respondio=false,
  78.            racha=0,
  79.            idPiso = 0,
  80.            perdioHoy = false
  81.        }
  82.    end
  83.    playersAlive = playersAlive +1
  84.    for i=1,200 do tfm.exec.bindKeyboard(name,i,true,true)end
  85.    --ui.addPopup(1000,0,string.format("<font size='20'><b><font face='Soopafresh'><p align='center'>Informacion (Ronda %d)</p></font></b><br></font><font size='10'>Hola %s! Bienvenido a %s, donde tu objetivo es demostrar que eres el raton mas conocedor de Transformice. Ahora, te informaremos un poquito la mecanica del juego. <font color=[[#6C77C]]>(Para mas informacion visita el foro)</font>\n\n<b>1.</b> La respuesta no contendra mas de 3 palabras\n<b>2. </b>Tienes 15 segundos para responder\n<b>3.</b> Podras ver el ranking del concurso usando el comando !ranking\n<b>4.</b> Recuerda respetar a todos los ratones\n<b>5.</b> Diviertete pensando un poquito!",ronda, name, "Transforbrain"),name,200,50,400, true)
  86.    tfm.exec.respawnPlayer(name)
  87.    drawPiso(name)
  88. end
  89.  
  90. function drawPiso(player)
  91.         randomColor(player)
  92.         tfm.exec.movePlayer(player, xposition+10, 80)
  93.         tfm.exec.addPhysicObject ( ultimoIdPiso, xposition, 100, set1 )
  94.         data[player].idPiso = ultimoIdPiso
  95.         ultimoIdPiso = ultimoIdPiso + 1
  96.         tfm.exec.addPhysicObject ( ultimoIdPiso, xposition-20, 0, set2 )
  97.         ultimoIdPiso= ultimoIdPiso + 1
  98.         tfm.exec.addPhysicObject (ultimoIdPiso, xposition+20, 0, set3 )
  99.         ultimoIdPiso = ultimoIdPiso + 1
  100.         xposition = xposition + 50
  101.         tfm.exec.playEmote (player, 0)
  102.        
  103. end
  104. function leaderboard(name)
  105.         i=0
  106.     tfm.exec.playEmote (name, 8)
  107.     local tablu,txt,txt2 = {},"",""
  108.     ia = 0
  109.     nameGanador = ""
  110.     for name, player in pairs(tfm.get.room.playerList) do      
  111.         if data[name].perdioHoy == false then
  112.         ia = ia +1
  113.             txt = txt.."<n>"..name..'\n'
  114.             nameGanador = name
  115.         end
  116.        
  117.     end
  118.     if ia == 1 then
  119.         ui.addTextArea(10000000, "<p align='center'><font size='20'><b><font face='Verdana'>GANADOR</p></font></b><font size='10'>"..nameGanador.." es el ganador(a)!!\n\n<p align='center'><a href='event:closeAll'>Cerrar</a></p>", name,50,20,700,nil,color[2], color[2],nil,true)
  120.     end
  121.     ui.addTextArea(-7,"<g>Utilize la rueda del mouse para bajar.\n\n"..txt,name,200,75,400,261,color[1],color[2],1,true)
  122.     ui.addTextArea(-8,"<font size='20'><b><p align='center'>Aun quedan concursando...</p></font></b><br></font><font size='10'>",name,200,40,400,30,color[2],color[2],1,true)
  123.     ui.addTextArea(-9,"<p align='center'><a href='event:closeRanking'>Cerrar</a></p>",name,200,335,400,20,color[2],color[2],1,true)
  124.         print(txt2)
  125.  
  126. end
  127.  
  128. function checkCorrect(choises, name)
  129.  
  130.        if modeGame==1 then
  131.                 ui.addTextArea(10, "<p align='center'><font size='20'><b><font face='Verdana'>La respuesta era</p></font></b><font size='10'>"..choises[correcta].."\n\n<p align='center'><a href='event:closeAll'>Cerrar</a></p>", name,50,20,700,nil,color[2], color[2],nil,true)
  132.  
  133.         elseif modeGame==2 then
  134.             ui.addTextArea(10, "<p align='center'><font size='20'><b><font face='Verdana'>La respuesta era</p></font></b><font size='10'>"..resp2.."\n\n<p align='center'><a href='event:closeAll'>Cerrar</a></p>", name,50,20,700,nil,color[2], color[2],nil,true)
  135. end
  136.  
  137. end
  138. function drawMultipleChoise(quest,choises,name,mode)
  139.        
  140.        if modeGame==1 then
  141.                 ui.addTextArea(1,"\n<font size='16'><p align='center'>"..quest.."</p></font>", name,50,85,400,250,color[1],color[2],1,true)
  142.                 ui.addTextArea(8, "<p align='center'><font size='20'><b><font face='Verdana'>Responde a la pregunta</font></b><br></font><font size='10'>", name,50,50,400,30,color[2],color[2],1,true)
  143.                 x,id = 160,2
  144.                 for i=1,#choises do            
  145.                         if mode then                  
  146.                                 ui.addTextArea(id, "<p align='center'>"..choises[i], name,50,x,400,20,color[1],verifColour(i,true),1,true)
  147.                         else
  148.                                 ui.addTextArea(id, "<a href='event:mianswer"..i.."'><p align='center'>"..choises[i], name,50,x,400,20,color[1],color[2],1,true)
  149.                         end
  150.                         x = x + 32
  151.                         id = id + 1
  152.                 end
  153.         elseif modeGame==2 then
  154.                 ui.addTextArea(1,"\n<font size='16'><p align='center'>"..quest.."</p></font>", name,50,85,400,250,color[1],color[2],1,true)
  155.                 ui.addTextArea(8, "<p align='center'><font size='20'><b><font face='Verdana'>Responde a la pregunta</font></b><br></font><font size='10'>", name,50,50,400,30,color[2],color[2],1,true)
  156.                 if mode then
  157.                         ui.addTextArea(2, "<p align='center'>"..resp2, name,50,160,400,20,color[1], color[2],1,true)
  158.                         ui.addPopup(1005,0,"",name,-600,-400,1,true)
  159.                         ui.addPopup(1005,0,"",nil,-600,-400,1,true)
  160.                 else
  161.                         ui.addPopup(1005,2,"",name,100,160,300,true)
  162.                 end
  163.                
  164.         elseif modeGame ==3 then               
  165.                  ui.addTextArea(8, "<p align='center'><font size='20'><b><font face='Verdana'>Responde a la pregunta</font></b><br></font><font size='15'>\n"..quest, name,50,20,700,nil,color[2],color[2],nil,true)
  166.                
  167.                
  168.                 if mode then
  169.                     i = 0
  170.                     for _,prop in ipairs(safeZones) do
  171.                         i = i + 1          
  172.                         if choises[i] then
  173.                             ui.addTextArea(i, choises[i], nil, prop[2]-prop[4]/2,prop[3]-prop[5]/2,prop[4],nil, color[1], verifColour(i, true), 1, false)      
  174.                         end
  175.                         if correcta ~= i then
  176.                             --tfm.exec.addShamanObject(40,prop[2],prop[3]-20)                          
  177.                             tfm.exec.explosion(prop[2],prop[3],50,50)
  178.                            
  179.                         end
  180.                        
  181.                     end
  182.                 else
  183.                     i = 0
  184.                     for _,prop in ipairs(safeZones) do
  185.                         i = i + 1  
  186.                         if choises[i] then
  187.                             ui.addTextArea(i, choises[i], nil, prop[2]-prop[4]/2,prop[3]-prop[5]/2-50,prop[4],nil, color[1], color[2], 0.8, false)
  188.                         end
  189.                     end
  190.                
  191.                 end
  192.        
  193.         end
  194.        
  195. end
  196.  
  197. function verifColour(id,mode)
  198.         if mode then
  199.                 if id == correcta then
  200.                         color0 = 0x0c992f
  201.                 else
  202.                         color0 = 0x990c3d
  203.                 end
  204.                 return color0
  205.         else
  206.                 if id == correcta then
  207.                         color0 = 0x0c992f              
  208.                 else
  209.                         color0 = color[2]
  210.                 end
  211.                 return color0
  212.         end
  213. end
  214.  
  215.  
  216. function eventKeyboard(name,key,down,x,y)
  217.         if key==76 then
  218.                 leaderboard(name)
  219.         end
  220. end
  221.  
  222.  
  223. function parseXML(xml, key, path, matching, ...)
  224.     local i = 0
  225.     local part = xml:match(path)
  226.     local parse = {}
  227.     for data in string.gmatch(part,matching) do
  228.         if data:find(key) then
  229.             i = i + 1
  230.             parse[i] = {}  
  231.             for a=1,#arg do
  232.                 table.insert(parse[i],data:match(arg[a]..'="(.-)"'))       
  233.             end
  234.         end
  235.     end
  236.     return parse
  237. end
  238.  
  239.  
  240.  
  241. function verifCorrect(name,x, y)    
  242.     local x1,x2,y1,y1      
  243.     local salve = false
  244.      prop = correctZone
  245.          x1 = prop[2] - prop[4]/2        
  246.          x2 = prop[2] + prop[4]/2        
  247.          y1 = prop[3] - prop[5]/2          
  248.          y2 = prop[3]  + prop[5]/2
  249.          if x>x1-10 and x<x2+10 and y>y1-10 and y<y2+10 then
  250.               index = #correctAnswer+1
  251.               data[name].puntos = data[name].puntos + 1      
  252.               data[name].racha = data[name].racha + 1
  253.               correctoResponder[#correctoResponder+1] = name             
  254.               data[name].respondio=true
  255.               tfm.exec.playEmote (name, 0)
  256.               tfm.exec.setNameColor (name, 0x3ecfa7)
  257.         else
  258.             tfm.exec.playEmote (name, 2)
  259.             tfm.exec.setNameColor (name, color[2])
  260.          end
  261.        
  262. end
  263.  
  264. function eventNewGame()
  265.     correctoResponder = {}
  266.     --safeZones = parseXML(tfm.get.room.xmlMapInfo.xml,'lua','<S>.-</S>','<S.-/>','lua','X','Y','L','H')
  267.     for name,player in pairs(tfm.get.room.playerList) do
  268.         tfm.exec.setNameColor (name, 0x000000)
  269.     end
  270. end
  271.  
  272. particles = {0,2,9,13,4}
  273. function drawLights()
  274.     for i=1,120 do
  275.         posx, posy = 800,400
  276.         tfm.exec.displayParticle(particles[math.random(#particles)],math.random(posx),math.random(posy),0,2,0,0,nil)
  277.     end
  278. end
  279.  
  280.  
  281. function drawLights2()
  282.     for i=1,30 do
  283.         posx, posy = 800,400
  284.         tfm.exec.displayParticle(particles[math.random(#particles)],math.random(posx),math.random(posy),0,2,0,0,nil)
  285.     end
  286. end
  287.  
  288. function eventTextAreaCallback(id,name,cb)
  289.         if cb=="qmultiple" then
  290.                 modeGame=1
  291.                 x,id = 160,2
  292.                 ui.addTextArea(9, "<J><a href='event:finish'>[Preguntar]</a> <BL> | <N>Control de respuesta: <V><a href='event:addanswers'>[+] Add</a><R> <a href='event:deleteAnswer'>[-] Remove</a>  <bv><a href='event:changeTime'>"..timeForAnswer.." segs</a> <N><p align='center'>", name,50,50,400,20,color[2],color[2],nil,true)
  293.                 ui.addTextArea(1,"<font size='15'><a href='event:asignarq'><p align='center'>"..text.."</p></a></font>", name,50,75,400,250,color[1],color[2],nil,true)
  294.                 for i=1,#opcionesRespuesta do          
  295.                         ui.addTextArea(id, "Edit: <a href='event:edit"..i.."'><p align='center'>"..opcionesRespuesta[i].."  <V><a href='event:asignara"..i.."'>[Asignar correcta]</a>", name,50,x,400,20,color[1],verifColour(i),nil,true)
  296.                         x = x + 30
  297.                         id = id + 1            
  298.                 end    
  299.         end
  300.         if cb=="qsencilla" then
  301.                 modeGame=2
  302.                 ui.addTextArea(9, "<J><a href='event:finish'>[Preguntar]</a> <BL> | <N>Control de respuesta:  <bv><a href='event:changeTime'>"..timeForAnswer.." segs</a> <N><p align='center'>", name,50,50,400,20,color[2],color[2],nil,true)
  303.                 ui.addTextArea(1,"<font size='15'><a href='event:asignarq'><p align='center'>"..text.."</p></a></font>", name,50,75,400,250,color[1],color[2],nil,true)
  304.                 ui.addTextArea(2, "<a href='event:asignar2'><p align='center'>"..(resp2 or "Respuesta").."</p></a>", name,50,160,400,20,color[1],color[2],nil,true)
  305.         end
  306.         if cb=="qplataformer" then
  307.             tfm.exec.newGame(map)
  308.             eventTextAreaCallback(0,name,"qplataforma")
  309.         end
  310.          if cb=="qplataforma" then
  311.                 modeGame=3
  312.                
  313.                 x,id = 160,2
  314.                 ui.addTextArea(9, "<J><a href='event:finish'>[Preguntar]</a> <BL> | <N>Control de respuesta: <V><a href='event:addanswers'>[+] Add</a><R> <a href='event:deleteAnswer'>[-] Remove</a>  <bv><a href='event:changeTime'>"..timeForAnswer.." segs</a> <N><p align='center'>", name,50,50,400,20,color[2],color[2],nil,true)
  315.                 ui.addTextArea(1,"<font size='15'><a href='event:asignarq'><p align='center'>"..text.."</p></a></font>", name,50,75,400,250,color[1],color[2],nil,true)
  316.                 for i=1,#opcionesRespuesta do          
  317.                         ui.addTextArea(id, "Edit: <a href='event:edit"..i.."'><p align='center'>"..opcionesRespuesta[i].."  <V><a href='event:asignara"..i.."'>[Asignar correcta]</a>", name,50,x,400,20,color[1],verifColour(i),nil,true)
  318.                         x = x + 30
  319.                         id = id + 1            
  320.                 end    
  321.         end
  322.         if cb:find("asignara") then
  323.                 correcta = cb:sub(9)+0
  324.                 if modeGame == 3 then
  325.                     correctZone = safeZones[correcta]              
  326.                 end
  327.                 act(id,name)
  328.         end
  329.         if cb=="asignar2" then
  330.                 ui.addPopup(1003,2,"<p align='center'><font size='10'><b><font face='Verdana'>Respuesta</font>",name,200,50,200, true)
  331.         end
  332.         if cb=="asignarq" then
  333.                 ui.addPopup(1000,2,"<p align='center'><font size='10'><b><font face='Verdana'>Nueva pregunta</font>",name,200,50,200, true)
  334.         end
  335.         if cb=="changeTime" then
  336.                 ui.addPopup(1002,2,"<p align='center'><font size='10'><font face='Verdana'>Cuanto tiempo durara la pregunta?</font></p>",name,200,50,200, true)
  337.         end
  338.         if cb=="addanswers" then
  339.                 if #opcionesRespuesta <= 4 then
  340.                         opcionesRespuesta[#opcionesRespuesta+1] = "Mi respuesta "..#opcionesRespuesta+1
  341.                         act(id,name)
  342.                 end
  343.         end
  344.         if cb=="deleteAnswer" then
  345.                 table.remove(opcionesRespuesta,#opcionesRespuesta)
  346.                 if #opcionesRespuesta == 0 then
  347.                         opcionesRespuesta = {"Mi respuesta 1"}
  348.                 end
  349.                 act(id,name)
  350.         end
  351.         if cb:find("edit") then
  352.                 editing = cb:sub(5)+0          
  353.                 ui.addPopup(1001,2,"<p align='center'><font size='10'><b><font face='Verdana'>Editar respuesta</font>",name,200,50,200, true)
  354.         end
  355.         if cb == "finish" then             
  356.                 if (correcta ~= 0 and #opcionesRespuesta ~=1) or modeGame==2 then
  357.                         ui.removeTextArea(6500,nil)
  358.                         closeUIQuestions(name)                     
  359.                         ui.removeTextArea(1,name)
  360.                         correctAnswer = {}
  361.                         answerMaking = answerMaking +1
  362.                         closeUIQuestions(nil);
  363.                         drawMultipleChoise(text,opcionesRespuesta,nil)
  364.                         timeToQuestion = true
  365.                         prueba = os.time()
  366.                         incorrectAnswer = {}
  367.  
  368.                 else
  369.                         ui.addPopup(1,0,"Te ha faltado algo....",name,200,50,200, true)
  370.                 end
  371.         end
  372.         if cb == "closeAll" then
  373.                 closeUIQuestions(name);
  374.         end
  375.         if cb == "closeMsg" then
  376.                 for i=13,15 do
  377.                         ui.removeTextArea(i,name)
  378.                 end
  379.         end
  380.         if cb == "closeRanking" then
  381.                 closeUIRanking(name)
  382.         end
  383.         if cb:sub(1,8)=="mianswer" then
  384.                 if modeGame==1 then
  385.                         if (cb:sub(9)+0) == correcta then
  386.                                 if (not data[name].respondio) then
  387.                                         index = #correctAnswer+1
  388.                                         tfm.exec.playEmote (name, 6)
  389.                                         correctoResponder[#correctoResponder+1] = name 
  390.                                         correctAnswer[index] = "<BL>"..index..". <V>"..name .. " <j>"..math.abs(math.floor((prueba-os.time())/10)/100).." segs <N>"
  391.                                         data[name].puntos = data[name].puntos + 1      
  392.                                         data[name].racha = data[name].racha + 1
  393.                                         data[name].respondio=true
  394.                                 end
  395.                         else
  396.                                 data[name].racha = 0
  397.                                 incorrectAnswer[#incorrectAnswer+1] = name
  398.                         end
  399.                         closeUIQuestions(name);
  400.                 end
  401.         end
  402. end
  403. function eventChatCommand(name, command)
  404.     local args={}
  405.     for arg in command:gmatch("[^%s]+") do
  406.                 table.insert(args, arg)
  407.         end
  408.         if admins[name] then
  409.                 if args[1] == "msg" then
  410.                         local str=table.concat(args," ",2):gsub("&lt;","<"):gsub("&gt;", ">")
  411.                         local str=str:gsub('%%<',"&lt;"):gsub('%%>',"&gt;")
  412.                         showMsg(str,name)
  413.                 end
  414.                 if args[1] == "verqueja" then
  415.                         for n,i in pairs(quejas) do
  416.                                 print(i)
  417.                         end
  418.                 end
  419.         end
  420.         if args[1] == "rank" then
  421.                 leaderboard(name)
  422.     end
  423.     if args[1] == "queja" then
  424.         table.insert(quejas,"<rose>["..name.."]<n> "..table.concat(args," ",2))
  425.     end
  426.    
  427. end
  428.  
  429. function closeUIQuestions(name)
  430.         for i=-6,11 do
  431.                 ui.removeTextArea(i,name)
  432.         end
  433. end
  434. function closeUIRanking(name)
  435.         for i=-10,-7 do
  436.                 ui.removeTextArea(i,name)
  437.         end
  438. end
  439. function showMsg(txt,name)
  440.         ui.addTextArea(15,"<n>"..txt.."</b></font></a><>",nil,275,176,250,100,color[1],color[2],1,true)
  441.         ui.addTextArea(13,"<font size='14'><b><font face='Verdana'><p align='center'>Mensaje</p></font></b>",nil,275,150,250,20,color[2],color[2],nil,true)
  442.         ui.addTextArea(14,"<p align='center'><a href='event:closeMsg'>Cerrar</a></p>",nil,275,275,250,20,color[2],color[2],nil,true)
  443. end
  444. function showCorrectAnswers()  
  445.         drawLights()
  446.         drawMultipleChoise(text,opcionesRespuesta,name,true)  
  447.         txt,i= "",0        
  448.         if modeGame == 3 then
  449.             for name,player in pairs(tfm.get.room.playerList) do
  450.                 verifCorrect(name, player.x, player.y)
  451.             end
  452.         end    
  453.         for name,player in pairs(tfm.get.room.playerList) do
  454.             tfm.exec.setNameColor (name, color[2])
  455.            
  456.            
  457.         end
  458.         if(modeGame~=3) then
  459.             for player,name in pairs(correctAnswer) do
  460.            
  461.                 i = i + 1              
  462.                 if i <= 30 then
  463.                         txt = txt..name.."\n"
  464.                        
  465.                 end
  466.             end        
  467.             ui.addTextArea(-6, "<font size='10'><g>Utilize la rueda del mouse para bajar.\n\n"..txt, name,480,84,250,240,color[1],color[2],nil,true)
  468.             ui.addTextArea(10, "<font size='20'><b><font face='Verdana'><p align='center'>"..(#correctAnswer or 0).." Ganador(es)!</p></font></b>"..txt, name,480,50,250,30,color[2],color[2],nil,true)
  469.             ui.addTextArea(11, "<p align='center'><a href='event:closeAll'>Cerrar</a></p>", name,480,320,250,20,color[2],color[2],nil,true)
  470.         end
  471.         if modeGame == 3 then          
  472.             for a=1, #correctoResponder do
  473.              i = i + 1             
  474.                 if i <= 30 then
  475.                         txt = txt..correctoResponder[i].."\n"
  476.                 end
  477.             end
  478.              ui.addTextArea(10, "<p align='center'><font size='20'><b><font face='Verdana'>"..(#correctoResponder or 0).." Ganador(es)!</p></font></b><font size='10'>"..txt.."\n\n<p align='center'><a href='event:closeAll'>Cerrar</a></p>", name,50,20,700,nil,color[2], color[2],nil,true)
  479.         end
  480.         for i=1,#correctoResponder do
  481.             tfm.exec.playEmote (correctoResponder[i], 0)
  482.             tfm.exec.setNameColor (correctoResponder[i], 0x3ecfa7)
  483.         end
  484.         text="Mi pregunta [Click aqui para cambiar]"
  485.         opcionesRespuesta = {"Mi respuesta 1"}
  486.         editing=0
  487.         correcta=0
  488.         correctAnswer={}
  489. end
  490.  
  491. function verifLosers()
  492.    
  493.     for i=1,#incorrectAnswer do
  494.         lose(incorrectAnswer[i])
  495.         data[incorrectAnswer[i]].perdioHoy = true
  496.     end
  497.     print(playersAlive)
  498.    
  499.    
  500. end
  501. function eventLoop()
  502.         drawLights2()      
  503.         if timeToQuestion then
  504.                 timeForAnswer = timeForAnswer - 0.5
  505.                 if timeForAnswer <= 0 then
  506.                     closeUIQuestions(nil);
  507.                         timeToQuestion = false
  508.                         timeForAnswer = 30
  509.                         timeForAnswers = 30
  510.                         checkCorrect(opcionesRespuesta, nil)
  511.                         --showCorrectAnswers()
  512.                         verifLosers()                      
  513.                         tfm.exec.setUIMapName("<v><b>Preguntas y Respuestas</b> <j># "..answerMaking.."<BL>\t|\t<N>Se ha acabado el tiempo para responder!<>")
  514.                        
  515.                         --tfm.exec.movePlayer(preguntador,30,231)
  516.                         preguntador = ""
  517.                         resp2 = "Respuesta"
  518.                         for a,b in pairs(tfm.get.room.playerList)do if (not data[a].respondio) then data[a].racha=0; lose(a) end data[a].respondio=false end
  519.                 else                  
  520.                         tfm.exec.setUIMapName(string.format("<v><b>Preguntas y Respuestas</b> <j># "..answerMaking.."<BL>\t|\t<N>Aun te quedan <j>%d <N>segundos para responder Apurate!<>",math.floor(timeForAnswer)))
  521.                 end
  522.             if modeGame == 3 then
  523.                 i = 0
  524.                 for _,prop in ipairs(safeZones) do 
  525.                     i = i + 1
  526.                     if opcionesRespuesta[i] then
  527.                         tfm.exec.addShamanObject(0, prop[2],prop[3]-prop[5]/2+50)
  528.                     end
  529.                 end
  530.             end
  531.         end
  532. end
  533.  
  534. function act(id,name)
  535.         if modeGame==1 then
  536.                 eventTextAreaCallback(id,name,"qmultiple")
  537.         elseif modeGame==2 then
  538.                 eventTextAreaCallback(id,name,"qsencilla")
  539.         elseif modeGame == 3 then
  540.             eventTextAreaCallback(id,name,"qplataforma")
  541.         end
  542. end
  543. function returnColor(name,name2)
  544.         if name2~=name then
  545.                 return ""
  546.         else
  547.                 return "<j>"
  548.         end
  549. end
  550.  
  551. function lose(name)
  552.     playersAlive = playersAlive - 1
  553.     data[name].perdioHoy = true;
  554.     for name,player in pairs(tfm.get.room.playerList) do
  555.         if admins[name] then
  556.                 ui.addTextArea(80000000, "<a href='event:qsencilla'>Sencilla</a> | <a href='event:qmultiple'>Multiple</a>", name,0,380,nil,20,color[1], color[2],nil,true)
  557.             end
  558.         end
  559.        
  560.     tfm.exec.removePhysicObject (data[name].idPiso)
  561.     tfm.exec.removePhysicObject (data[name].idPiso+1)
  562.     tfm.exec.removePhysicObject (data[name].idPiso+2)
  563.     ui.addPopup(1,0,"<p align='center'>Has perdido, lo lamentamos :(</p>",name,350,175,100,true)
  564.     leaderboard(nil)
  565. end
  566.  
  567. function eventPlayerLeft  (name)
  568.  
  569. lose(name)
  570. end
  571. function eventPopupAnswer(id, name, answer)
  572.         if id==1000 and answer:len()>0 then
  573.                 text=answer
  574.                 act(id,name)
  575.         end
  576.         if id==1001 and answer:len()>0 then
  577.                 opcionesRespuesta[editing]=answer
  578.                 act(id,name)
  579.         end
  580.         if id==1002 then
  581.                 if tonumber(answer) then
  582.                         timeForAnswer=tonumber(answer)
  583.                         act(id,name)
  584.                 else
  585.                         ui.addPopup(1,0,"<p align='center'>Invalido...</p>",name,350,175,100,true)
  586.                 end
  587.         end
  588.         if id==1003 then
  589.                 resp2=tostring(answer)
  590.                 act(id,name)
  591.         end
  592.         if id==1005 then
  593.                 if (answer==resp2) then
  594.                         index = #correctAnswer+1
  595.                         tfm.exec.playEmote (name, 6)
  596.                         correctoResponder[#correctoResponder+1] = name 
  597.                         correctAnswer[index] = "<BL>"..index..". <V>"..name .. " <j>"..math.abs(math.floor((prueba-os.time())/10)/100).." segs <N>"
  598.                         data[name].puntos = data[name].puntos + 1      
  599.                         data[name].racha = data[name].racha + 1
  600.                         data[name].respondio=true
  601.                        
  602.                         closeUIQuestions(name);
  603.                 else
  604.                         closeUIQuestions(name);                      
  605.                         incorrectAnswer[#incorrectAnswer+1] = name
  606.                 end
  607.         end
  608. end
  609.  
  610. main()
Advertisement
Add Comment
Please, Sign In to add comment