musugas

TFQ

Jan 4th, 2019
1,267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.20 KB | None | 0 0
  1. --! TORNEOS.GG S.A.S
  2. -- SÓLO PARA EL USO INTERNO, O CONFERIDO PARA EL USO.
  3. --
  4. --
  5. --
  6. --
  7. --
  8. -- Author: TORNEOS.GG S.A.S
  9. -- Date: 03/01/2019
  10. -- Version: 0.1
  11. -- Minigame: TRANSFORQUIZ#001
  12. --
  13. --
  14. -- ♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛
  15.  
  16. local admins = {Musugas = true}
  17.  
  18. ---VARS, DONT TOUCH
  19. local cronometres = {}
  20. local  timeControlEndQuestion =0
  21. local finishRound = false
  22. local canShowCheckEndQuestion = true
  23. local canAnswersCheckEndQuestion = false
  24. nextIdControlEndQuestion = 0
  25. local startIdControlEndQuestion = 1000000;
  26. local phrasesControlEndQuestion = {"Veamos...","¿Habrás ganado?","¿Habrás perdido?","¿Quizás fuiste el mejor?","Todo un@ Einstein?","¿super-mega-inteligentisisisismo?"}
  27. local namesForModes  = {"Multiple","Escribela","Plataforma"}
  28. local colorTags = {"warning","danger","success","info","white"}
  29. local respuestas = {"15","32","18","25"}
  30. local correctAnswer = 3
  31. local allUIElements = {}
  32. local removeAnswersCheckEndQuestion = false
  33. local currentQuestion = 0
  34. local startTime = 30;
  35. local currentCategorie = 0
  36. local currentMode = 0
  37. local currentQuestionTitle = ""
  38. local currentQuestionAnswers = {}
  39. local playerData = {}
  40. local winners  = {}
  41. local losers = {}
  42. local titleIdLocal = 98565020
  43. local startTimeRound = os.time()
  44. local categories = {"Arte","Ciencia","Geografia","Historia","Entretenimiento","Videojuegos", "Atelier801"}
  45. local duration = 5 * 1000 -- 5s
  46.  
  47. local remSplash = { }
  48.  
  49.  
  50.  
  51.  
  52.  
  53. local errors= {
  54.     [0] = "Error",
  55.     "Unidentified profile",
  56.     "Unidentified command",
  57.     "We could not find the language",
  58.     "You cannot use that",
  59.     "Forbidden",
  60.     "You are disqualified",
  61.     "You cannot report %s",
  62.     "<R>You do not have that title",
  63.     "You have the maximum level",
  64.     "The action [%s] could not be found"}
  65.  
  66.  
  67. ---============= GUIA
  68. --[[
  69. 1 valor = Pregunta
  70. 2 valor = Respuestas MAXIMO SOLO 4
  71. 3 valor = Numero de la respuesta correcta
  72. 4 valor = Tipo - Modo
  73. 5 valor = Categoria
  74. 6 valor = Tiempo en formato 60 (1 minuto = 60 segundos)
  75.  
  76. TIPOS DISPONIBLES:
  77. 1 = multiple.
  78.  
  79. ]]
  80.  
  81.  
  82. local questions = {
  83. {"¿A cuál empresa pertenece Fortnite?",{"Riot Games", "Epic Games", "Mojang AB", "Rockstar Games"}, 2, 1, 6, 15},
  84. {"¿Cuándo fue el lanzamiento oficial de Transformice?",{"14 de mayo de 2010", "1 de mayo de 2010", "25 de junio de 2010", "15 de diciembre de 2010"}, 2, 1, 7, 15},
  85. {"¿Por cuál simbolo son representados los mapas cooperativos?",{"Dos cañones", "Dos plumas", "Dos banderas", "Dos pinceles"}, 2, 1, 7, 15},
  86. {"¿Quiénes son los centinelas de la comunidad española?",{"Bog, Obemice, Ratacp", "Obemice, Warfenix, Hispano", "Tomatosin, Bog, Ratacp", "Jefitou, Illy, Bog"}, 1, 1, 7, 15},
  87. {"¿Cuál de estos jugadores no forma parte del equipo de moderación?",{"Lezzly", "Tomatosin", "Yuloff", "Makis"}, 3, 1, 7, 15},
  88. {"¿Quién es el CCM de la comunidad española?",{"Zou", "Kura", "Galaktine", "Streaxx"}, 4, 1, 7, 15},
  89. {"¿Cuándo se estrenó la película Avengers: Infinity War?",{"23 de abril de 2018", "26 de marzo de 2015", "03 de enero de 2018", "15 de diciembre de 2018"}, 1, 1, 5, 15},
  90. {"¿A quién pertenece la obra Niño con paloma?",{"Tiziano", "Edvard Munch", "Pablo Ruiz Picasso", "Leonardo Da Vinci"}, 3, 1, 1, 15},
  91. {"¿Quién interpreta el tema Shape of you?",{"Paloma Mami", "Shakira", "Ed Sheeran", "Sia"}, 3, 1, 1, 15},
  92. {"¿En qué periodo se desarrolló la Guerra Fría?",{"1947 - 1953", "1950 - 1976", "1827 - 1900", "1762 - 1800"}, 1, 1, 4, 15},
  93. {"¿Qué es la Biología?",{"Estudio de la vida", "Estudio del universo", "Estudio de la biocenosis", "Estudio del ecosistema"}, 4, 1, 2, 15},
  94. {"¿Qué constituye la máxima evolución del universo?",{"El espacio", "El hombre", "La antimateria", "El tiempo"}, 2, 1, 2, 15},
  95. {"¿Con qué límita España al norte?",{"Francia", "Mar cantábrico", "Marruecos", "Mar mediterráneo"}, 2, 1, 3, 15},
  96. {"¿Cuándo murió la ratoncita Elise?",{"2 de diciembre de 2012", "25 de marzo de 2015", "2 de noviembre de 2011", "15 de agosto de 2012"}, 3, 1, 7, 15},
  97. {"¿Cuál es el mayor problema cosmolóico?",{"Resolver el origen y la forma del universo", "Delinear la geometría de los agujeros negros", "Conocer la mecánica de los quasares", "Cuantificar las estrellas de la vía láctea."}, 1, 1, 2, 15},
  98. {"¿Cuál es la capitál de Pakistan?",{"Karachi", "Lahore", "Islamabad", "Quetta"}, 3, 1, 3, 15},
  99. {"¿En dónde está ubicado el Taj Mahal?",{"Jordania", "Armenia", "India", "Líbano"}, 3, 1, 3, 15},
  100. {"¿Cuál de estos actores no forma parte del elenco de la serie Élite?",{"Itzán Escamilla", "Danna Paola", "Miguel Herrán", "Brad Pitt"}, 4, 1, 5, 15},
  101. {"¿En dónde se originó el catolicismo?",{"Belén", "Judea", "Jerusalen", "Samaria"}, 3, 1, 3, 15},
  102. {"¿Dónde nació Angelina Jolie?",{"San Francisco, California, Estados Unidos", "Los Angeles, California, Estados Unidos", "San Diego, California, Estados Unidos", "Pasadena, California, Estados Unidos"}, 2, 1, 5, 15},
  103. {"¿Cuándo fue lanzado FIFA 95?",{"21 de julio de 1994", "3 de enero de 1992", "25 de diciembre de 1995", "8 de julio de 1994"}, 4, 1, 6, 15},
  104. {"¿Durante qué años fue el mandato presidencial de George Walker Bush?",{"1889 - 1992", "1989 – 1993", "1762 - 1884", "1989 - 1996"}, 2, 1, 4, 15},
  105. {"¿A cuál empresa pertenece la consola PlayStation?",{"Nintendo", "Apple", "Sony", "Microsoft"}, 3, 1, 6, 15},
  106. {"¿Cuántos países tiene América?",{"21", "42", "35", "11"}, 3, 1, 3, 15},
  107. {"¿En qué año se originó la creación del primer computador?",{"1928", "1992", "1936", "1911"}, 3, 1, 4, 15}
  108. }
  109.  
  110. defaultData = function()
  111.     data = {
  112.         points = 0,
  113.         respondThistime = false,
  114.         miniCronometre = false,
  115.         needMiniCronometre = false,    
  116.         consecutiveAnswered  = 0,
  117.         consecutiveAnsweredRank = 0,
  118.         correct = false,
  119.         -- 1 = winners
  120.         -- 2 losers
  121.         -- 3 played    
  122.         firstAnswered = 0,     
  123.         rank = 0,
  124.         operacion = 0,
  125.         answered = 0,
  126.         played = 0,
  127.         losed = 0,
  128.         tr=1,
  129.         ta=1,
  130.         currentPage = 1,
  131.         isTorneos = 0,
  132.         img = "",
  133.         timeForImg = 0
  134.     }  
  135.     return data
  136. end
  137.  
  138.  
  139.  
  140.  
  141. finishForNewRound = function()
  142.     timeControlEndQuestion =0
  143.     finishRound = false
  144.     canShowCheckEndQuestion = true
  145.     canAnswersCheckEndQuestion = false
  146.     removeAnswersCheckEndQuestion = false
  147.     nextIdControlEndQuestion = 0
  148.     startIdControlEndQuestion = 1000000;
  149.     text,number = "\n<font size='15'>",1
  150.     if #winners > 0 then
  151.         for i=1, #winners do
  152.             if number == 1 then
  153.                 playerData[winners[i][1]].firstAnswered = playerData[winners[i][1]].firstAnswered + 1
  154.                 tfm.exec.chatMessage("<J>"..winners[i][1].." ha sido super veloz!", nil)
  155.             end
  156.             playerData[winners[i][1]].points = playerData[winners[i][1]].points + 1
  157.             --playerData[winners[i][1]].modesStats[currentMode][1] = playerData[winners[i][1]].modesStats[currentMode][1] + 1
  158.            
  159.             playerData[winners[i][1]].answered = playerData[winners[i][1]].answered  + 1
  160.             playerData[winners[i][1]].correct = true           
  161.             playerData[winners[i][1]].consecutiveAnswered= playerData[winners[i][1]].consecutiveAnswered + 1
  162.             if playerData[winners[i][1]].consecutiveAnswered > playerData[winners[i][1]].consecutiveAnsweredRank then
  163.                 playerData[winners[i][1]].consecutiveAnsweredRank= playerData[winners[i][1]].consecutiveAnswered
  164.             end
  165.             text = text..string.format("<j>%d. <v><b>%s</b> - <bl>%s segs.  <bl> - Racha: <v>%s\n", number, winners[i][1], winners[i][2],playerData[winners[i][1]].consecutiveAnswered)                
  166.              ui.addTextArea(9999999999999, "<VP><p align='center'>$"..playerData[winners[i][1]].points.." <a href='event:ggcoins'><R>[+] ",winners[i][1],750,380,50,nil,nil,0x324650,nil,true)
  167.             tfm.exec.displayParticle(15,760, 370,0,-9,0,1,winners[i][1])
  168.             number = number + 1
  169.         end
  170.         appearPanel(false, name, 6000,"medium","<p align='center'><h4><font color='#264348'>Ganadores!</h4></p>", text ,50,50,true, "success",320)
  171.     else
  172.         appearPanel(false, name, 6000,"small","<p align='center'><h3><font color='#264348'>¡Ooooops!</h3></p>", "\n<n><p align='center'>Nadie respondio correctamente! ",300,200,true, "warning")
  173.     end
  174.    
  175.     for i=1, #losers do
  176.             playerData[losers[i]].losed = playerData[losers[i]].losed + 1
  177.         --playerData[losers[i]].modesStats[currentMode][2] = playerData[losers[i]].modesStats[currentMode][2] + 1
  178.     end
  179.     thisNewQuestion = currentQuestion+1
  180.    
  181.     newRound()
  182.    
  183.    
  184.  
  185. end
  186.  
  187. local splash = function(playerName)
  188.         remSplash[#remSplash + 1] = { id = tfm.exec.addImage("1681bdc4591.png", "&0", 100, 115, playerName), time = os.time() + duration }
  189. end
  190.  
  191.  
  192. handledStart = function()
  193.     tfm.exec.disableAutoNewGame(true)
  194.     tfm.exec.disableAutoTimeLeft(true)
  195.     tfm.exec.disableAutoShaman(true)
  196.     for i, command in ipairs ({"q","msg","pause","start", "save"}) do
  197.            system.disableChatCommandDisplay(command,true)
  198.      end
  199.     tfm.exec.setUIMapName("<font color='#EACA54'><b>TransforQuiz</b>\ | </font><font color='#67c7d3'>Torneos.GG\t\t\t<j>Recuerda, ¡Acumula y reclama tus puntos por premios!<>")
  200.     table.foreach(tfm.get.room.playerList, eventNewPlayer)
  201.     splash()
  202. end
  203.  
  204. newRound = function()
  205.     for name, player in pairs(playerData) do
  206.         if not player.correct then         
  207.              player.consecutiveAnswered = 0
  208.         end
  209.         player.respondThistime = false
  210.         player.needMiniCronometre=false
  211.         player.correct = false
  212.     end
  213.     if currentQuestion == #questions then
  214.         getRank()
  215.         tfm.exec.chatMessage("<J>Hemos terminado esta ronda de TransforQuiz, ¡Esperamos que te hayas divertido Yujuuuuuuuuu!")
  216.     else
  217.     currentQuestion = currentQuestion + 1  
  218.     addCronometre(15,0,string.format("<p align='center'>Categoria: %s",categories[questions[currentQuestion][5]]),drawQuestionSide)
  219.     end
  220. end
  221.  
  222. finishRoundFunc = function()
  223.     for name, player in pairs(playerData) do
  224.         if not player.respondThistime then
  225.             player.losed = player.losed + 1
  226. --          player.modesStats[currentMode][2] = player.modesStats[currentMode][2] + 1
  227.              player.consecutiveAnswered = 0
  228.         end    
  229.     end
  230.     for i=1,#allUIElements do
  231.         ui.removeTextArea(allUIElements[i],nil)
  232.     end
  233.     if currentMode == 2 then
  234.         ui.addPopup(8560,2,"",name,-8000,-800,300,true)
  235.     end
  236.     finishRound = true
  237. end
  238.  
  239. handledAnswerResponse  = function(name, response)
  240.     if not playerData[name].respondThistime then
  241.         playerData[name].respondThistime = true
  242.         if currentMode == 1 then
  243.             if correctAnswer == response then
  244.                
  245.                 tablu = {name,math.abs(math.floor((startTimeRound-os.time())/10)/100)}
  246.                 table.insert(winners, tablu)
  247.             else
  248.             table.insert(losers, name)
  249.             end        
  250.         elseif currentMode == 2 then
  251.             if response ==  questions[currentQuestion][2][1] then              
  252.                 tablu = {name,math.abs(math.floor((startTimeRound-os.time())/10)/100)}
  253.                 table.insert(winners, tablu)
  254.             else
  255.                 table.insert(losers, name)
  256.             end        
  257.             playerData[name].needMiniCronometre = true
  258.        
  259.         end
  260.             for i=1,#allUIElements do
  261.                 ui.removeTextArea(allUIElements[i],name)
  262.             end
  263.             ui.addPopup(8560,2,"",name,-255151,-1151,300,true)
  264.             playerData[name].played = playerData[name].played + 1
  265. --          playerData[name].modesStats[currentMode][3] = playerData[name].modesStats[currentMode][3] + 1
  266.     end
  267. end
  268. eventNewPlayer = function(name)
  269.      if (not playerData[name]) then
  270.         playerData[name] = defaultData()
  271.      end
  272.      tfm.exec.chatMessage("<J>¡Bienvenido a TransforQuiz! Creo que tu cerebro está un poco grande... veamoslo.", name)
  273.      splash(name)
  274.      ui.addTextArea(9999999999999, "<VP>$"..playerData[name].points.." <a href='event:ggcoins'><R>[+] ", name,750,380,50,nil,nil,0x324650,nil,true)
  275.     --appearBigWindow(false, 0, name, "¡Bienvenido!", "\n<p align='center'>Hola, ¡Estamos en la beta de transforbrainy!\nPrueba usar !p + nombre para previsualizar el perfil de un usuario", true, "warning")   
  276. end
  277.  
  278.  
  279.  
  280.  
  281. drawQuestionSide = function ()
  282.     deleteGUIElement(6000)
  283.     startTimeRound = os.time()
  284.     winners = {}
  285.     losers = {}
  286.     question =  questions[currentQuestion]
  287.     correctAnswer = question[3]
  288.     title = question[1]
  289.     answers = question[2]
  290.     time = question[6] 
  291.     currentMode = question[4]
  292.     addCronometre(time,2,"",finishRoundFunc)
  293.     currentQuestionTitle = title
  294.     currentQuestionAnswers = answers
  295.    
  296.     appearBigWindow(false, 0, nil, "Responde a la pregunta", string.format("\n<p align='center'><h3>%s",title), false, "info","nada")  
  297.     if currentMode == 1 then
  298.         local coords = {{120,240},{420,240},{120,300},{420,300}}   
  299.         for i=1,#answers do        
  300.             appearWell(nil,i,answers[i], coords[i][1],coords[i][2], "primary",string.format("mianswer%d",i))   
  301.         end
  302.     elseif currentMode == 2 then
  303.         ui.addPopup(8560,2,"",name,250,250,300,true)
  304.     end
  305.     appearPanel(false, name, 9,"xsmall","<p align='center'><h5><font color='#264348'>Pasar</h5></p>", "",150,200,false, "warning")
  306.     appearPanel(false, name, 10,"xsmall","<p align='center'><h5><font color='#264348'>Rendirme</h5></p>", "",550,200,false, "danger")
  307. end
  308.  
  309.  
  310. eventPopupAnswer =function(id, name, answer)
  311.     if id==8560 then
  312.         handledAnswerResponse(name,answer:lower()) 
  313.     end
  314.  
  315. end
  316. --===================== UI FUNCTIONS
  317. --===================== Module: MNET UI API TFM
  318.  
  319. parserColor = function (type)
  320.     if type == "danger" then
  321.         color = 0xE74C3C
  322.     elseif type == "warning" then
  323.         color = 0xF39C12
  324.     elseif type == "primary" then
  325.         color = 0x0F424D
  326.     elseif type == "success" then
  327.         color = 0x149C82
  328.     elseif type == "white" then
  329.         color = 0xffebee
  330.         elseif type == "info" then
  331.         color = 0x269ABC
  332.     else
  333.         color = 0x0F424D
  334.     end
  335.    
  336. return color
  337. end
  338.  
  339. htmlParser =  function(content)
  340.     local PARSER_TABLE = {
  341.         {"<h1>" , "<font size='32'>"},
  342.         {"<h2>" , "<font size='24'>"},
  343.         {"<h3>" , "<font size='19'>"},
  344.         {"<h4>" , "<font size='16'>"},
  345.         {"<h5>" , "<font size='14'>"},
  346.         {"<h6>" , "<font size='13'>"},
  347.         {"</h(%d)>" , "</font>"}
  348.     }
  349.     for i=1,#PARSER_TABLE do   
  350.         content = content:gsub(PARSER_TABLE[i][1], PARSER_TABLE[i][2])
  351.     end
  352.     return content
  353. end
  354.  
  355. appearBigWindow = function(white,id1,name, title, text, close, type,event)
  356.     if white then
  357.         colorForBack = 0xffebee    
  358.     else
  359.         colorForBack =  0x43353D
  360.     end
  361.    
  362.     local id2 = id1+100000;
  363.     if name == nil then
  364.         table.insert(allUIElements,id2)
  365.         table.insert(allUIElements,id1)
  366.         table.insert(allUIElements,id1+900000)
  367.     end
  368.     color = parserColor(type)
  369.     title, text = htmlParser(title), htmlParser(text)
  370.     ui.addTextArea(id1,text,name,100,80,600,280,colorForBack,colorForBack,1,true)
  371.     ui.addTextArea(id2,string.format("<p align='center'><font size='30' color='#ffffff'>%s</font></p>",title),name,95,40,610,40,color,color, 1,true)
  372.     if close then  
  373.         if event then
  374.             ui.addTextArea(id1+900000,string.format("<font color='#00000'><a href='%s'>X", event),name,100+605-15,40,nil,nil,color,color,1,true)
  375.         else
  376.             ui.addTextArea(id1+900000,string.format("<font color='#00000'><a href='event:closeMnetUI%d'>X", id1),name,100+605-15,40,nil,nil,color,color,1,true)
  377.         end
  378.        
  379.     end
  380. end
  381.  
  382. appearPanel = function(white, name, id1,typeof,title, text,x,y,close, type,maxHeight, event)
  383.     local w;
  384.     local id2 = id1+100000;
  385.     local h = nil
  386.     if(maxHeight) then
  387.         h = maxHeight
  388.     end
  389.     color = parserColor(type)
  390.     if white then
  391.         colorForBack = 0xffebee    
  392.     else
  393.         colorForBack =  0x43353D
  394.     end
  395.     title, text = htmlParser(title), htmlParser(text)
  396.     if typeof=="big" then
  397.         w = 700
  398.     elseif typeof=="xbig" then
  399.         w = 600
  400.     elseif typeof=="medium" then
  401.         w = 500
  402.     elseif typeof=="xmedium" then
  403.         w = 300
  404.     elseif typeof=="small" then
  405.         w = 200
  406.     elseif typeof=="xsmall" then
  407.         w = 100
  408.     end
  409.    
  410.     if name == nil then
  411.         table.insert(allUIElements,id2)
  412.         table.insert(allUIElements,id1)
  413.         table.insert(allUIElements,id1+900000)
  414.     end
  415.     ui.addTextArea(id1,text,name,x,y,w,h,colorForBack,color,1,true)
  416.     ui.addTextArea(id2,title,name,x,y-20,w,nil,color, color,1,true)
  417.     if close then  
  418.         if event then
  419.             ui.addTextArea(id1+900000,string.format("<font color='#00000'><a href='event:%s'>X", event),name,x+w-15,y-20,nil,nil,color,color,1,true)
  420.         else
  421.             ui.addTextArea(id1+900000,string.format("<font color='#00000'><a href='event:closeMnetUI%d'>X", id1),name,x+w-15,y-20,nil,nil,color,color,1,true)
  422.         end
  423.     end
  424.    
  425. end
  426.  
  427. appearWell = function(name, id, text, x, y, type, event)   
  428.     color = parserColor(type)
  429.     if name == nil then
  430.         table.insert(allUIElements,id)     
  431.     end
  432.     if event~=nil then
  433.         text = string.format("<p align='center'><font color='#ffffff'><a href='event:%s'>%s</a></font></p>",event, text)
  434.     else
  435.         text = string.format("<p align='center'><font color='#ffffff'>%s</font></p>",text, event)
  436.     end
  437.         ui.addTextArea(id,text,name,x,y,250,40,color, color,1,true)
  438. end
  439.  
  440. getCronometro = function(seconds)  
  441.     color = "white"
  442.     hours = math.floor(seconds / 3600);
  443.     mins = math.floor((seconds - (hours*3600)) / 60);
  444.     secs = math.floor(seconds % 60);
  445.     if(seconds<120) then
  446.         color = "info" 
  447.     end
  448.     if(seconds<60) then
  449.         color = "success"  
  450.     end
  451.     if(seconds<30) then
  452.         color = "warning"  
  453.     end
  454.     if(seconds<5) then
  455.         color = "danger"   
  456.     end
  457.     if(mins < 10) then
  458.         mins = "0"..mins
  459.     end
  460.     if(secs<10) then
  461.         secs = "0"..secs
  462.     end
  463.     dada = {secs,mins, color}
  464.     return dada
  465. end
  466.  
  467. addCronometre = function(seconds, type, text,event)
  468.     cronometro = {seconds,type,text,event}
  469.     table.insert(cronometres, cronometro)
  470. end
  471.  
  472. handledCronometresFunction = function()
  473.     for i=1,#cronometres do
  474.         this_cronometre = cronometres[i]       
  475.         if this_cronometre[1] > 0 then
  476.             this_cronometre[1] = this_cronometre[1] - 0.5  
  477.             cronometreTypes(this_cronometre[2],this_cronometre[1],this_cronometre[3],this_cronometre[4])
  478.         else
  479.             ui.removeTextArea(8000000,nil)
  480.             ui.removeTextArea(8000001,nil)
  481.             table.remove(cronometres, i)
  482.         end
  483.     end
  484. end
  485.  
  486. cronometreTypes = function(type, seconds,text,func)
  487.     dates = getCronometro(seconds)
  488.    
  489.         if seconds==0 and func~=nil then           
  490.                 cronometres = {}
  491.                 func()         
  492.         end
  493.         for name, player in pairs(playerData) do
  494.             if type==0 and player.miniCronometre == false and player.needMiniCronometre==false then
  495.                 if seconds<5 and seconds%1 == 0 then
  496.                     appearPanel(false, name, 8000000,"small","", "\n",561501510,50,false, dates[3])
  497.                 else
  498.                     appearPanel(false, name, 8000000,"small",string.format("<p align='center'><h3><font color='#264348'>%s:%s</h3></p>",dates[2],dates[1]), "\n"..text,600,50,false, dates[3])
  499.                 end
  500.             elseif type==1 and player.miniCronometre == false and player.needMiniCronometre==false then
  501.                 if seconds<5 and seconds%1 == 0 then
  502.                    
  503.                         appearPanel(false, name, 8000000,"small","", "\n",561501510,50,false, dates[3])    
  504.                         appearPanel(false, name, 8000001,"small","", "\n",561501510,50,false, dates[3])
  505.                    
  506.                 else
  507.                     appearPanel(false, name, 8000000,"xsmall",string.format("<p align='center'><h3><font color='#264348'>%s:%s</h3></p>",dates[2],dates[1]), "\n",350,200,false, dates[3])
  508.                     appearPanel(false, name, 8000001,"small",string.format("<p align='center'><h3><font color='#264348'>%s</h3></p>",text), "",300,240,false, dates[3])
  509.                 end
  510.             elseif type==2 and player.miniCronometre == false and  player.respondThistime ==  false and player.needMiniCronometre==false then
  511.                 if seconds<5 and seconds%1 == 0 then
  512.                     appearPanel(false, name, 8000000,"small","", "\n",561501510,50,false, dates[3])
  513.                    
  514.                 else           
  515.                     appearPanel(false, name, 8000000,"small",string.format("<p align='center'><h3><font color='#264348'>%s:%s</h3></p>",dates[2],dates[1]), "\n"..text,300,200,false, dates[3])
  516.  
  517.                 end    
  518.             elseif player.miniCronometre or player.respondThistime or player.needMiniCronometre then
  519.                 if seconds<5 and seconds%1 == 0 then
  520.                         appearPanel(false, name, 8000000,"small","", "\n",561501510,50,false, dates[3])
  521.                     else
  522.                         appearPanel(false, name, 8000000,"small",string.format("<p align='center'><h3><font color='#264348'>%s:%s</h3></p>",dates[2],dates[1]), "\n<p align='center'>"..text,600,50,false, dates[3])
  523.                     end
  524.                 end
  525.     end
  526. end
  527.  
  528.  
  529. --=============================================
  530.  
  531.  
  532. eventTextAreaCallback = function(id, name, cb)
  533.     if cb=="closethis" then
  534.         ui.removeTextArea(id, name)
  535.     end
  536.     if cb:find("closeMnetUI") then
  537.         id = cb:sub(12);
  538.         ui.removeTextArea(id, name);
  539.         ui.removeTextArea(id+900000, name);
  540.         ui.removeTextArea(id+100000, name);
  541.     end
  542.     if cb:sub(1,8)=="mianswer" then
  543.         handledAnswerResponse(name, cb:sub(9)+0)       
  544.     end    
  545.     if cb=="ggcoins" then
  546.        ggcoins = playerData[name].points * 5,3
  547.         ui.addPopup ( 0, 0, "<p align='center'><font size='20' face='Comic Sans MS' color='#67c7d3'>GGCOINS</font></p><br>Recuerda que puedes intercambiar tus puntos por GGCoins, la moneda virtual de TorneosGG que te permitirá canjear por increibles premios en la ShopGG, ¡de manera gratuita!<br><br><br><p align='center'><font size='15' color='#54e680'>".. playerData[name].points .." puntos</font> = <font size='15' color='#EACA54'>"..ggcoins.." GGCoins</font></p><br><br><font size='10'>Para poder intercambiar tus puntos por GGCOINS debes tener una cuenta activa y registrada en www.torneos.gg. Torneos.GG S.A.S. Creemeos en el mundo de los esports", name, 200, 100, 400, true )
  548.     end
  549.    
  550.    
  551.    
  552.    
  553.     if cb:sub(1,4) == "prev" or cb:sub(1,4) =="next" then
  554.         dataThis = playerData[name]
  555.         cbCurrent = cb:sub(5)
  556.         if cbCurrent == "rank" then
  557.             if cb:sub(1,4) =="next" and dataThis.ta ~= 5 then      
  558.                 dataThis.tr,dataThis.ta = dataThis.tr +10,dataThis.ta+1        
  559.             elseif cb:sub(1,4) =="prev" and dataThis.ta ~= 1 then  
  560.                 dataThis.tr,dataThis.ta,dataThis.currentPage = dataThis.tr -10,dataThis.ta-1,dataThis.currentPage-1
  561.             end        
  562.            
  563.             getRank(name,dataThis.tr,dataThis.ta*10)   
  564.         end
  565.     end
  566. end
  567.  
  568. deleteGUIElement = function(id)
  569.         ui.removeTextArea(id, name);
  570.         ui.removeTextArea(id+900000, name);
  571.         ui.removeTextArea(id+100000, name);
  572. end
  573.  
  574. handledEndQuestionEach = function()
  575.     timeControlEndQuestion = timeControlEndQuestion + 1
  576.     numeroForDisplayQuestions = #currentQuestionAnswers
  577.     if #currentQuestionAnswers == 2 then
  578.         numeroForDisplayQuestions =  2
  579.     end
  580.     if timeControlEndQuestion == 8 then
  581.         canShowCheckEndQuestion = false
  582.     elseif timeControlEndQuestion == (5*#currentQuestionAnswers)+5 then
  583.         removeAnswersCheckEndQuestion = true
  584.         canAnswersCheckEndQuestion = false     
  585.     elseif timeControlEndQuestion == 5 then
  586.             canAnswersCheckEndQuestion = true
  587.             appearPanel(false, name, 9,"medium","<p align='center'><h4><font color='#264348'>"..currentQuestionTitle.." </h4></p>", "",150,70,false, "white")
  588.     elseif timeControlEndQuestion%1 == 0 and canAnswersCheckEndQuestion and nextIdControlEndQuestion < #currentQuestionAnswers then
  589.             startIdControlEndQuestion = startIdControlEndQuestion + 1
  590.             nextIdControlEndQuestion = nextIdControlEndQuestion + 1
  591.             if nextIdControlEndQuestion == correctAnswer then
  592.                 appearWell(nil,startIdControlEndQuestion,currentQuestionAnswers[nextIdControlEndQuestion], 270,(nextIdControlEndQuestion * 60)+50, "success")
  593.             else
  594.                 appearWell(nil,startIdControlEndQuestion,currentQuestionAnswers[nextIdControlEndQuestion], 270,(nextIdControlEndQuestion * 60)+50, "danger")
  595.             end
  596.     elseif timeControlEndQuestion%1 == 0 and removeAnswersCheckEndQuestion and startIdControlEndQuestion > 1000000 then
  597.         ui.removeTextArea(startIdControlEndQuestion,nil)
  598.         startIdControlEndQuestion = startIdControlEndQuestion -1
  599.     elseif removeAnswersCheckEndQuestion and startIdControlEndQuestion == 1000000 then     
  600.         finishRound = false;
  601.         deleteGUIElement(9);
  602.         finishForNewRound()
  603.     elseif canShowCheckEndQuestion then
  604.        
  605.         appearPanel(false, name, 9,"medium","<p align='center'><h1><font color='#264348'>"..phrasesControlEndQuestion[math.random(#phrasesControlEndQuestion)].."</h1></p>", "",150,200,false, colorTags[math.random(#colorTags)])
  606.        
  607.        
  608.        
  609.     end
  610. end
  611.  
  612.  
  613. eventLoop = function()
  614.     handledCronometresFunction();
  615.     if finishRound == true then
  616.         handledEndQuestionEach()
  617.     end    
  618.     for i = 1, #remSplash do
  619.         if os.time() > remSplash[i].time then
  620.             tfm.exec.removeImage(remSplash[i].id)
  621.         else
  622.             for j = 1, i - 1 do
  623.                 table.remove(remSplash, j)
  624.             end
  625.             break
  626.         end
  627.     end
  628. end
  629.  
  630.  
  631. table.remove = function(list, pos)
  632.     local len, out = #list
  633.  
  634.     if not pos or pos == len then
  635.         out = list[len]
  636.         list[len] = nil
  637.     elseif pos < len then
  638.         local out = list[pos]
  639.         list[pos] = nil
  640.  
  641.         for i = pos, len do
  642.             list[i] = list[i + 1]
  643.         end
  644.     end
  645.     return out
  646. end
  647.  
  648.  
  649. eventChatCommand = function (name, command)
  650.     local args={}
  651.     for arg in command:gmatch("[^%s]+") do
  652.                 table.insert(args, arg)
  653.     end
  654.     if args[1] == "stats" or args[1] == "perfil" or args[1] == "profile" then
  655.         if playerData[capitalize(args[2])] or args[2] == "me" or args[2] == "" or not args[2] then
  656.             if playerData[capitalize(args[2])] then
  657.                 player = capitalize(args[2])
  658.             else
  659.                 args[2]= name
  660.                 player = name
  661.             end
  662.             sendprofile(player, name)
  663.         else
  664.        
  665.             ui.addPopup(0, 0, string.format("El jugador %s nunca ha jugado TransforQuiz. <b>¿¡Por qué no le invitas a jugar con nosotros!?",capitalize(args[2]) ), name, 300, 175, nil)
  666.         end
  667.     end
  668.  
  669.         if args[1]=="musupro" then
  670.             desbtitle(name,2)
  671.         end
  672.        
  673.     if args[1]=="title" then
  674.         if args[2] then
  675.             changetitle(name,args[2])
  676.         elseif not args[2] then            
  677.             appearPanel(false, name, 850,"xmedium","Titulos", returnTitles(name,true, 1,15,1),50,50,true, "success",320)
  678.         end
  679.        
  680.     end
  681.    
  682.     if args[1]=="alltitles" then
  683.                 appearPanel(false, name, 850,"xmedium","Titulos", returnTitles(nil,true, 1,15,1),50,50,true, "success",320)
  684.  
  685.         end
  686.     if args[1]=="rank" then
  687.         getRank(name,0,10)
  688.     end
  689.  
  690.         if args[1] == "save" then
  691.             exportForG(name)
  692.         end
  693.         if args[1] == "start" then
  694.             cronometres = {}  
  695.             currentQuestion = 0;
  696.             addCronometre(startTime,1,"¡Falta poco para empezar!",newRound)  
  697.             tfm.exec.chatMessage("<J>¿Estás preparado/a? ¡Ya vamos a empezar!", nil)
  698.            
  699.         end
  700.         if args[1] == "stop" then
  701.             deleteGUIElement(8000000)
  702.             deleteGUIElement(8000001)
  703.             cronometres = {}        
  704.         end    
  705.     if args[1] == "pause" then
  706.             cronometres = {}  
  707.           addCronometre(args[2]+0 ,0,"¡Hagamos una pausa! Esperemos",newRound)    
  708.          
  709.         end
  710.    
  711.    
  712. end
  713.  
  714. sendprofile = function (name, requestUser)
  715. local player = playerData[name]
  716.     sumaRounds = player.played
  717.     sumaWins = player.answered
  718.     local text = string.format("<font size='15'>\n<j><p align='center'>«%s»</p>\n%s\n\n<G>Rank: <j>%d\n<bl>", getRankName(player.answered), "<BV>User TorneosGG<BV>", player.rank)   
  719.    
  720.  
  721.     text = text..string.format("Preguntas respondidas: <v>%d\n<bl>Preguntas correctas: <v>%d\n<bl>Racha máxima: <v>%d\n<bl>Respondidas de primero: <v>%d", sumaRounds, sumaWins, player.consecutiveAnsweredRank,player.firstAnswered)
  722.    
  723.     text = text.."\n\n<p align='center'>+"
  724.     appearPanel(false, requestUser, 850,"xmedium",string.format("<p align='center'><h4><font color='#264348'>%s</h4></p>",name), text,50,50,true, "success",320)
  725.    
  726.    
  727.    
  728.    
  729. end
  730.  
  731.  
  732.  
  733. capitalize = function(word)
  734.  if word then
  735.     if word:find("+") then  
  736.         return string.upper(word:sub(1,2)) .. string.lower (word:sub(3))
  737.     else
  738.      return string.upper(word:sub(1,1)) .. string.lower (word:sub(2))  
  739.     end
  740.  end
  741. end
  742.  
  743. function getRank(p,hola,pe)
  744.     if hola == nil then
  745.         hola,pe = 0,10
  746.     end
  747.     scoreall={}
  748.     info=""
  749.     for a,b in pairs(tfm.get.room.playerList)do
  750.         if playerData[a] and tfm.get.room.playerList[a] then
  751.             player = playerData[a]
  752.             sumaRounds = player.played
  753.             sumaWins = player.answered
  754.  
  755.         operacion = (sumaWins/sumaRounds) * 100
  756.         if type(operacion) ~= "number" or operacion < 0 or operacion == math.huge or  isnan(operacion) == true then
  757.             operacion = 0
  758.         end
  759.         player.operacion= operacion
  760.         table.insert(scoreall,{nombre=a,operacion=operacion,sumwins=sumaWins, jugadas=sumaRounds})
  761.         end
  762.     end
  763.     table.sort (scoreall,function (a,b)return a.operacion>b.operacion end) 
  764.      for i,b in pairs(scoreall)do
  765.         playerData[b.nombre].rank = i    
  766.        
  767.     end
  768.     for a=hola,pe do
  769.         if scoreall[a] then        
  770.             info = info..string.format("<BL>%s.- <V>%s   <j>%s | %s | %s\n",getColorForRanking(playerData[scoreall[a].nombre].rank),scoreall[a].nombre:sub(1,10), scoreall[a].sumwins,scoreall[a].jugadas ,tostring(scoreall[a].operacion):sub(1,5) .."%")     
  771.                    
  772.         end
  773.        
  774.     end
  775.     if a then
  776.         if info=='' then
  777.             ex = "<J>No hay resultados para el rango ["..hola.." - "..pe.."]"
  778.         else
  779.             ex = "Rango de busqueda ["..hola.." - "..pe.."]"
  780.         end    
  781.        
  782.         appearBigWindow(false, 0, p, "¡Ranking!", "\n<BL>#.- Nombre - Correctas - Jugadas - Porcentaje<font size='13'>\n\n"..info.."\n<p align='center'>"..ex.."\n<BL><font size='13'><BL><a href='event:prevrank'><B>←</B> (Prev) </a><a href='event:nextrank'>(Next)<B>→</B>", true, "warning") 
  783.     end
  784. end
  785.  
  786. function isnan(x) return x ~= x end
  787.  
  788. function getRankName(number)
  789.     local as ="";
  790.     if number > 120 then
  791.         return  "<J>Aprendiz ★★★</J>"
  792.     elseif number > 100 then
  793.         return  "<J>Aprendiz ★★</J>"
  794.     elseif number > 80 then
  795.         return  "<J>Aprendiz ★</J>"
  796.     elseif number > 60 then
  797.         return  "<J>Aprendiz</J>"
  798.     elseif number > 50 then
  799.         return  "<v>Nerd ★★★</v>"
  800.     elseif number > 40 then
  801.         return  "<v>Nerd ★★</v>"   
  802.     elseif number > 30 then
  803.         return  "<v>Nerd ★</v>"  
  804.     elseif number > 20 then
  805.         return "<v>Nerd ★</v>"           
  806.     else
  807.         return "<V>Nerd</V>"
  808.     end
  809.    
  810.  
  811. end
  812.  
  813.  
  814. function exportForG(name)
  815.     local string = ""
  816.     for name, player in pairs(playerData) do       
  817.         string = string..string.format("g(\"%s\",%s,%s,%s,%s,%s,%s);",name, player.answered,player.firstAnswered, player.played, player.losed, player.points, player.isTorneos)    
  818.     end
  819.     tfm.exec.chatMessage(string, name)
  820.     print(string)
  821. end
  822.  
  823. function string.split(inputstr, sep)
  824.     if sep == nil then
  825.             sep = "%s"
  826.     end
  827.     local t={} ; i=1
  828.     for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  829.             t[i] = str
  830.             i = i + 1
  831.     end
  832.     return t
  833. end
  834.  
  835. function getColorForRanking(space)
  836.     a = ""
  837.     if space == 1 then     
  838.         a = "<J>"
  839.     elseif space == 2 then
  840.         a = "<N>"
  841.     elseif space == 3 then
  842.         a = "<VI>"
  843.     else
  844.         a = "<BL>"
  845.     end
  846.    
  847.     return a..space
  848. end
  849. handledStart()
  850.  
  851. function g(name,wins, first, rounds, lose, points, torneos)
  852.     if not playerData[name] then
  853.         playerData[name] = defaultData()
  854.     end
  855.     player = playerData[name]
  856.    
  857.    
  858.     player.answered = (wins or 0) + 0
  859.     player.firstAnswered = (first or 0) + 0
  860.     player.played = (rounds or 0) + 0
  861.     player.losed = (lose or 0) + 0
  862.     player.points = (points or 0) + 0
  863.     player.isTorneos = torneos;
  864.    
  865.     ui.addTextArea(9999999999999, "<VP>$"..playerData[name].points.." <a href='event:ggcoins'><R>[+] ", name,750,380,50,nil,nil,0x324650,nil,true)
  866.  
  867.    
  868.      
  869. end
Advertisement
Add Comment
Please, Sign In to add comment