musugas

TFQ

Jan 4th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.69 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.  
  84. {"¿A cuál empresa pertenece Fortnite?",{"Riot Games", "Epic Games", "Mojang AB", "Rockstar Games"}, 2, 1, 6, 15},
  85. {"¿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},
  86. {"¿Por cuál simbolo son representados los mapas cooperativos?",{"Dos cañones", "Dos plumas", "Dos banderas", "Dos pinceles"}, 2, 1, 7, 15},
  87. {"¿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},
  88. {"¿Cuál de estos jugadores no forma parte del equipo de moderación?",{"Lezzly", "Tomatosin", "Yuloff", "Makis"}, 3, 1, 7, 15},
  89. {"¿Quién es el CCM de la comunidad española?",{"Zou", "Kura", "Galaktine", "Streaxx"}, 4, 1, 7, 15},
  90. {"¿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},
  91. {"¿A quién pertenece la obra Niño con paloma?",{"Tiziano", "Edvard Munch", "Pablo Ruiz Picasso", "Leonardo Da Vinci"}, 3, 1, 1, 15},
  92. {"¿Quién interpreta el tema Shape of you?",{"Paloma Mami", "Shakira", "Ed Sheeran", "Sia"}, 3, 1, 1, 15},
  93. {"¿En qué periodo se desarrolló la Guerra Fría?",{"1947 - 1953", "1950 - 1976", "1827 - 1900", "1762 - 1800"}, 1, 1, 4, 15},
  94. {"¿Qué es la Biología?",{"Estudio de la vida", "Estudio del universo", "Estudio de la biocenosis", "Estudio del ecosistema"}, 4, 1, 2, 15},
  95. {"¿Qué constituye la máxima evolución del universo?",{"El espacio", "El hombre", "La antimateria", "El tiempo"}, 2, 1, 2, 15},
  96. {"¿Con qué límita España al norte?",{"Francia", "Mar cantábrico", "Marruecos", "Mar mediterráneo"}, 2, 1, 3, 15},
  97. {"¿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},
  98. {"¿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},
  99. {"¿Cuál es la capitál de Pakistan?",{"Karachi", "Lahore", "Islamabad", "Quetta"}, 3, 1, 3, 15},
  100. {"¿En dónde está ubicado el Taj Mahal?",{"Jordania", "Armenia", "India", "Líbano"}, 3, 1, 3, 15},
  101. {"¿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},
  102. {"¿En dónde se originó el catolicismo?",{"Belén", "Judea", "Jerusalen", "Samaria"}, 3, 1, 3, 15},
  103. {"¿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},
  104. {"¿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},
  105. {"¿Durante qué años fue el mandato presidencial de George Walker Bush?",{"1889 - 1992", "1989 – 1993", "1762 - 1884", "1989 - 1996"}, 2, 1, 4, 15},
  106. {"¿A cuál empresa pertenece la consola PlayStation?",{"Nintendo", "Apple", "Sony", "Microsoft"}, 3, 1, 6, 15},
  107. {"¿Cuántos países tiene América?",{"21", "42", "35", "11"}, 3, 1, 3, 15},
  108. {"¿En qué año se originó la creación del primer computador?",{"1928", "1992", "1936", "1911"}, 3, 1, 4, 15}
  109. }
  110.  
  111. defaultData = function()
  112.     data = {
  113.         points = 0,
  114.         respondThistime = false,
  115.         miniCronometre = false,
  116.         needMiniCronometre = false,    
  117.         consecutiveAnswered  = 0,
  118.         consecutiveAnsweredRank = 0,
  119.         correct = false,
  120.         -- 1 = winners
  121.         -- 2 losers
  122.         -- 3 played    
  123.         firstAnswered = 0,     
  124.         rank = 0,
  125.         operacion = 0,
  126.         answered = 0,
  127.         played = 0,
  128.         losed = 0,
  129.         tr=1,
  130.         ta=1,
  131.         currentPage = 1,
  132.         isTorneos = 0,
  133.         img = "",
  134.         timeForImg = 0
  135.     }  
  136.     return data
  137. end
  138.  
  139.  
  140.  
  141.  
  142. finishForNewRound = function()
  143.     timeControlEndQuestion =0
  144.     finishRound = false
  145.     canShowCheckEndQuestion = true
  146.     canAnswersCheckEndQuestion = false
  147.     removeAnswersCheckEndQuestion = false
  148.     nextIdControlEndQuestion = 0
  149.     startIdControlEndQuestion = 1000000;
  150.     text,number = "\n<font size='15'>",1
  151.     if #winners > 0 then
  152.         for i=1, #winners do
  153.             if number == 1 then
  154.                 playerData[winners[i][1]].firstAnswered = playerData[winners[i][1]].firstAnswered + 1
  155.                 tfm.exec.chatMessage("<J>"..winners[i][1].." ha sido super veloz!", nil)
  156.             end
  157.             playerData[winners[i][1]].points = playerData[winners[i][1]].points + 1
  158.             --playerData[winners[i][1]].modesStats[currentMode][1] = playerData[winners[i][1]].modesStats[currentMode][1] + 1
  159.            
  160.             playerData[winners[i][1]].answered = playerData[winners[i][1]].answered  + 1
  161.             playerData[winners[i][1]].correct = true           
  162.             playerData[winners[i][1]].consecutiveAnswered= playerData[winners[i][1]].consecutiveAnswered + 1
  163.             if playerData[winners[i][1]].consecutiveAnswered > playerData[winners[i][1]].consecutiveAnsweredRank then
  164.                 playerData[winners[i][1]].consecutiveAnsweredRank= playerData[winners[i][1]].consecutiveAnswered
  165.             end
  166.             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)                
  167.              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)
  168.             tfm.exec.displayParticle(15,760, 370,0,-9,0,1,winners[i][1])
  169.             number = number + 1
  170.         end
  171.         appearPanel(false, name, 6000,"medium","<p align='center'><h4><font color='#264348'>Ganadores!</h4></p>", text ,50,50,true, "success",320)
  172.     else
  173.         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")
  174.     end
  175.    
  176.     for i=1, #losers do
  177.             playerData[losers[i]].losed = playerData[losers[i]].losed + 1
  178.         --playerData[losers[i]].modesStats[currentMode][2] = playerData[losers[i]].modesStats[currentMode][2] + 1
  179.     end
  180.     thisNewQuestion = currentQuestion+1
  181.    
  182.     newRound()
  183.    
  184.    
  185.  
  186. end
  187.  
  188. local splash = function(playerName)
  189.         remSplash[#remSplash + 1] = { id = tfm.exec.addImage("1681bdc4591.png", "&0", 100, 115, playerName), time = os.time() + duration }
  190. end
  191.  
  192.  
  193. handledStart = function()
  194.     tfm.exec.disableAutoNewGame(true)
  195.     tfm.exec.disableAutoTimeLeft(true)
  196.     tfm.exec.disableAutoShaman(true)
  197.     for i, command in ipairs ({"q","msg","pause","start", "save"}) do
  198.            system.disableChatCommandDisplay(command,true)
  199.      end
  200.     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!<>")
  201.     table.foreach(tfm.get.room.playerList, eventNewPlayer)
  202.     splash()
  203.     tfm.exec.newGame('@7558519')
  204.     tfm.exec.setGameTime(99999)
  205. end
  206.  
  207. newRound = function()
  208.     for name, player in pairs(playerData) do
  209.         if not player.correct then         
  210.              player.consecutiveAnswered = 0
  211.         end
  212.         player.respondThistime = false
  213.         player.needMiniCronometre=false
  214.         player.correct = false
  215.     end
  216.     if currentQuestion == #questions then
  217.    
  218.         tfm.exec.chatMessage("<J>Hemos terminado esta ronda de TransforQuiz, ¡Esperamos que te hayas divertido Yujuuuuuuuuu!")
  219.         getRank(nil,0,10)
  220.     else
  221.     currentQuestion = currentQuestion + 1  
  222.     addCronometre(15,0,string.format("<p align='center'>Categoria: %s",categories[questions[currentQuestion][5]]),drawQuestionSide)
  223.     end
  224. end
  225.  
  226. finishRoundFunc = function()
  227.     for name, player in pairs(playerData) do
  228.         if not player.respondThistime then
  229.             player.losed = player.losed + 1
  230. --          player.modesStats[currentMode][2] = player.modesStats[currentMode][2] + 1
  231.              player.consecutiveAnswered = 0
  232.         end    
  233.     end
  234.     for i=1,#allUIElements do
  235.         ui.removeTextArea(allUIElements[i],nil)
  236.     end
  237.     if currentMode == 2 then
  238.         ui.addPopup(8560,2,"",name,-8000,-800,300,true)
  239.     end
  240.     finishRound = true
  241. end
  242.  
  243. handledAnswerResponse  = function(name, response)
  244.     if not playerData[name].respondThistime then
  245.         playerData[name].respondThistime = true
  246.         if currentMode == 1 then
  247.             if correctAnswer == response then
  248.                
  249.                 tablu = {name,math.abs(math.floor((startTimeRound-os.time())/10)/100)}
  250.                 table.insert(winners, tablu)
  251.             else
  252.             table.insert(losers, name)
  253.             end        
  254.         elseif currentMode == 2 then
  255.             if response ==  questions[currentQuestion][2][1] then              
  256.                 tablu = {name,math.abs(math.floor((startTimeRound-os.time())/10)/100)}
  257.                 table.insert(winners, tablu)
  258.             else
  259.                 table.insert(losers, name)
  260.             end        
  261.             playerData[name].needMiniCronometre = true
  262.        
  263.         end
  264.             for i=1,#allUIElements do
  265.                 ui.removeTextArea(allUIElements[i],name)
  266.             end
  267.             ui.addPopup(8560,2,"",name,-255151,-1151,300,true)
  268.             playerData[name].played = playerData[name].played + 1
  269. --          playerData[name].modesStats[currentMode][3] = playerData[name].modesStats[currentMode][3] + 1
  270.     end
  271. end
  272. eventNewPlayer = function(name)
  273.      if (not playerData[name]) then
  274.         playerData[name] = defaultData()
  275.      end
  276.      tfm.exec.chatMessage("<J>¡Bienvenido a TransforQuiz! Creo que tu cerebro está un poco grande... veamoslo.", name)
  277.      tfm.exec.chatMessage("<J>Los puntos de la primera semana estan guardados en nuestros cerebros gigantes, ¡Se sumarán con los de la primera! No te preocupes", name)
  278.      splash(name)
  279.      ui.addTextArea(9999999999999, "<VP>$"..playerData[name].points.." <a href='event:ggcoins'><R>[+] ", name,750,380,50,nil,nil,0x324650,nil,true)
  280.     tfm.exec.respawnPlayer(name)
  281.     --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")   
  282. end
  283.  
  284.  
  285.  
  286.  
  287. drawQuestionSide = function ()
  288.     deleteGUIElement(6000)
  289.     startTimeRound = os.time()
  290.     winners = {}
  291.     losers = {}
  292.     question =  questions[currentQuestion]
  293.     correctAnswer = question[3]
  294.     title = question[1]
  295.     answers = question[2]
  296.     time = question[6] 
  297.     currentMode = question[4]
  298.     addCronometre(time,2,"",finishRoundFunc)
  299.     currentQuestionTitle = title
  300.     currentQuestionAnswers = answers
  301.    
  302.     appearBigWindow(false, 0, nil, "Responde a la pregunta", string.format("\n<p align='center'><h3>%s",title), false, "info","nada")  
  303.     if currentMode == 1 then
  304.         local coords = {{120,240},{420,240},{120,300},{420,300}}   
  305.         for i=1,#answers do        
  306.             appearWell(nil,i,answers[i], coords[i][1],coords[i][2], "primary",string.format("mianswer%d",i))   
  307.         end
  308.     elseif currentMode == 2 then
  309.         ui.addPopup(8560,2,"",name,250,250,300,true)
  310.     end
  311.     appearPanel(false, name, 9,"xsmall","<p align='center'><h5><font color='#264348'>Pasar</h5></p>", "",150,200,false, "warning")
  312.     appearPanel(false, name, 10,"xsmall","<p align='center'><h5><font color='#264348'>Rendirme</h5></p>", "",550,200,false, "danger")
  313. end
  314.  
  315.  
  316. eventPopupAnswer =function(id, name, answer)
  317.     if id==8560 then
  318.         handledAnswerResponse(name,answer:lower()) 
  319.     end
  320.  
  321. end
  322. --===================== UI FUNCTIONS
  323. --===================== Module: MNET UI API TFM
  324.  
  325. parserColor = function (type)
  326.     if type == "danger" then
  327.         color = 0xE74C3C
  328.     elseif type == "warning" then
  329.         color = 0xF39C12
  330.     elseif type == "primary" then
  331.         color = 0x0F424D
  332.     elseif type == "success" then
  333.         color = 0x149C82
  334.     elseif type == "white" then
  335.         color = 0xffebee
  336.         elseif type == "info" then
  337.         color = 0x269ABC
  338.     else
  339.         color = 0x0F424D
  340.     end
  341.    
  342. return color
  343. end
  344.  
  345. htmlParser =  function(content)
  346.     local PARSER_TABLE = {
  347.         {"<h1>" , "<font size='32'>"},
  348.         {"<h2>" , "<font size='24'>"},
  349.         {"<h3>" , "<font size='19'>"},
  350.         {"<h4>" , "<font size='16'>"},
  351.         {"<h5>" , "<font size='14'>"},
  352.         {"<h6>" , "<font size='13'>"},
  353.         {"</h(%d)>" , "</font>"}
  354.     }
  355.     for i=1,#PARSER_TABLE do   
  356.         content = content:gsub(PARSER_TABLE[i][1], PARSER_TABLE[i][2])
  357.     end
  358.     return content
  359. end
  360.  
  361. appearBigWindow = function(white,id1,name, title, text, close, type,event)
  362.     if white then
  363.         colorForBack = 0xffebee    
  364.     else
  365.         colorForBack =  0x43353D
  366.     end
  367.    
  368.     local id2 = id1+100000;
  369.     if name == nil then
  370.         table.insert(allUIElements,id2)
  371.         table.insert(allUIElements,id1)
  372.         table.insert(allUIElements,id1+900000)
  373.     end
  374.     color = parserColor(type)
  375.     title, text = htmlParser(title), htmlParser(text)
  376.     ui.addTextArea(id1,text,name,100,80,600,280,colorForBack,colorForBack,1,true)
  377.     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)
  378.     if close then  
  379.         if event then
  380.             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)
  381.         else
  382.             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)
  383.         end
  384.        
  385.     end
  386. end
  387.  
  388. appearPanel = function(white, name, id1,typeof,title, text,x,y,close, type,maxHeight, event)
  389.     local w;
  390.     local id2 = id1+100000;
  391.     local h = nil
  392.     if(maxHeight) then
  393.         h = maxHeight
  394.     end
  395.     color = parserColor(type)
  396.     if white then
  397.         colorForBack = 0xffebee    
  398.     else
  399.         colorForBack =  0x43353D
  400.     end
  401.     title, text = htmlParser(title), htmlParser(text)
  402.     if typeof=="big" then
  403.         w = 700
  404.     elseif typeof=="xbig" then
  405.         w = 600
  406.     elseif typeof=="medium" then
  407.         w = 500
  408.     elseif typeof=="xmedium" then
  409.         w = 300
  410.     elseif typeof=="small" then
  411.         w = 200
  412.     elseif typeof=="xsmall" then
  413.         w = 100
  414.     end
  415.    
  416.     if name == nil then
  417.         table.insert(allUIElements,id2)
  418.         table.insert(allUIElements,id1)
  419.         table.insert(allUIElements,id1+900000)
  420.     end
  421.     ui.addTextArea(id1,text,name,x,y,w,h,colorForBack,color,1,true)
  422.     ui.addTextArea(id2,title,name,x,y-20,w,nil,color, color,1,true)
  423.     if close then  
  424.         if event then
  425.             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)
  426.         else
  427.             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)
  428.         end
  429.     end
  430.    
  431. end
  432.  
  433. appearWell = function(name, id, text, x, y, type, event)   
  434.     color = parserColor(type)
  435.     if name == nil then
  436.         table.insert(allUIElements,id)     
  437.     end
  438.     if event~=nil then
  439.         text = string.format("<p align='center'><font color='#ffffff'><a href='event:%s'>%s</a></font></p>",event, text)
  440.     else
  441.         text = string.format("<p align='center'><font color='#ffffff'>%s</font></p>",text, event)
  442.     end
  443.         ui.addTextArea(id,text,name,x,y,250,40,color, color,1,true)
  444. end
  445.  
  446. getCronometro = function(seconds)  
  447.     color = "white"
  448.     hours = math.floor(seconds / 3600);
  449.     mins = math.floor((seconds - (hours*3600)) / 60);
  450.     secs = math.floor(seconds % 60);
  451.     if(seconds<120) then
  452.         color = "info" 
  453.     end
  454.     if(seconds<60) then
  455.         color = "success"  
  456.     end
  457.     if(seconds<30) then
  458.         color = "warning"  
  459.     end
  460.     if(seconds<5) then
  461.         color = "danger"   
  462.     end
  463.     if(mins < 10) then
  464.         mins = "0"..mins
  465.     end
  466.     if(secs<10) then
  467.         secs = "0"..secs
  468.     end
  469.     dada = {secs,mins, color}
  470.     return dada
  471. end
  472.  
  473. addCronometre = function(seconds, type, text,event)
  474.     cronometro = {seconds,type,text,event}
  475.     table.insert(cronometres, cronometro)
  476. end
  477.  
  478. handledCronometresFunction = function()
  479.     for i=1,#cronometres do
  480.         this_cronometre = cronometres[i]       
  481.         if this_cronometre[1] > 0 then
  482.             this_cronometre[1] = this_cronometre[1] - 0.5  
  483.             cronometreTypes(this_cronometre[2],this_cronometre[1],this_cronometre[3],this_cronometre[4])
  484.         else
  485.             ui.removeTextArea(8000000,nil)
  486.             ui.removeTextArea(8000001,nil)
  487.             table.remove(cronometres, i)
  488.         end
  489.     end
  490. end
  491.  
  492. cronometreTypes = function(type, seconds,text,func)
  493.     dates = getCronometro(seconds)
  494.    
  495.         if seconds==0 and func~=nil then           
  496.                 cronometres = {}
  497.                 func()         
  498.         end
  499.         for name, player in pairs(playerData) do
  500.             if type==0 and player.miniCronometre == false and player.needMiniCronometre==false then
  501.                 if seconds<5 and seconds%1 == 0 then
  502.                     appearPanel(false, name, 8000000,"small","", "\n",561501510,50,false, dates[3])
  503.                 else
  504.                     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])
  505.                 end
  506.             elseif type==1 and player.miniCronometre == false and player.needMiniCronometre==false then
  507.                 if seconds<5 and seconds%1 == 0 then
  508.                    
  509.                         appearPanel(false, name, 8000000,"small","", "\n",561501510,50,false, dates[3])    
  510.                         appearPanel(false, name, 8000001,"small","", "\n",561501510,50,false, dates[3])
  511.                    
  512.                 else
  513.                     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])
  514.                     appearPanel(false, name, 8000001,"small",string.format("<p align='center'><h3><font color='#264348'>%s</h3></p>",text), "",300,240,false, dates[3])
  515.                 end
  516.             elseif type==2 and player.miniCronometre == false and  player.respondThistime ==  false and player.needMiniCronometre==false then
  517.                 if seconds<5 and seconds%1 == 0 then
  518.                     appearPanel(false, name, 8000000,"small","", "\n",561501510,50,false, dates[3])
  519.                    
  520.                 else           
  521.                     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])
  522.  
  523.                 end    
  524.             elseif player.miniCronometre or player.respondThistime or player.needMiniCronometre then
  525.                 if seconds<5 and seconds%1 == 0 then
  526.                         appearPanel(false, name, 8000000,"small","", "\n",561501510,50,false, dates[3])
  527.                     else
  528.                         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])
  529.                     end
  530.                 end
  531.     end
  532. end
  533.  
  534.  
  535. --=============================================
  536.  
  537.  
  538. eventTextAreaCallback = function(id, name, cb)
  539.     tfm.exec.changePlayerSize(name,  math.random(0.1, 3))
  540.     if cb=="closethis" then
  541.         ui.removeTextArea(id, name)
  542.     end
  543.     if cb:find("closeMnetUI") then
  544.         id = cb:sub(12);
  545.         ui.removeTextArea(id, name);
  546.         ui.removeTextArea(id+900000, name);
  547.         ui.removeTextArea(id+100000, name);
  548.     end
  549.     if cb:sub(1,8)=="mianswer" then
  550.         handledAnswerResponse(name, cb:sub(9)+0)   
  551.         tfm.exec.playEmote ( name, math.random(24) )   
  552.     end    
  553.     if cb=="ggcoins" then
  554.        ggcoins = playerData[name].points * 5,3
  555.         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 )
  556.     end
  557.    
  558.    
  559.    
  560.    
  561.     if cb:sub(1,4) == "prev" or cb:sub(1,4) =="next" then
  562.         dataThis = playerData[name]
  563.         cbCurrent = cb:sub(5)
  564.         if cbCurrent == "rank" then
  565.             if cb:sub(1,4) =="next" and dataThis.ta ~= 5 then      
  566.                 dataThis.tr,dataThis.ta = dataThis.tr +10,dataThis.ta+1        
  567.             elseif cb:sub(1,4) =="prev" and dataThis.ta ~= 1 then  
  568.                 dataThis.tr,dataThis.ta,dataThis.currentPage = dataThis.tr -10,dataThis.ta-1,dataThis.currentPage-1
  569.             end        
  570.            
  571.             getRank(name,dataThis.tr,dataThis.ta*10)   
  572.         end
  573.     end
  574. end
  575.  
  576. deleteGUIElement = function(id)
  577.         ui.removeTextArea(id, name);
  578.         ui.removeTextArea(id+900000, name);
  579.         ui.removeTextArea(id+100000, name);
  580. end
  581.  
  582. handledEndQuestionEach = function()
  583.     timeControlEndQuestion = timeControlEndQuestion + 1
  584.     numeroForDisplayQuestions = #currentQuestionAnswers
  585.     if #currentQuestionAnswers == 2 then
  586.         numeroForDisplayQuestions =  2
  587.     end
  588.     if timeControlEndQuestion == 8 then
  589.         canShowCheckEndQuestion = false
  590.     elseif timeControlEndQuestion == (5*#currentQuestionAnswers)+5 then
  591.         removeAnswersCheckEndQuestion = true
  592.         canAnswersCheckEndQuestion = false     
  593.     elseif timeControlEndQuestion == 5 then
  594.             canAnswersCheckEndQuestion = true
  595.             appearPanel(false, name, 9,"medium","<p align='center'><h4><font color='#264348'>"..currentQuestionTitle.." </h4></p>", "",150,70,false, "white")
  596.     elseif timeControlEndQuestion%1 == 0 and canAnswersCheckEndQuestion and nextIdControlEndQuestion < #currentQuestionAnswers then
  597.             startIdControlEndQuestion = startIdControlEndQuestion + 1
  598.             nextIdControlEndQuestion = nextIdControlEndQuestion + 1
  599.             if nextIdControlEndQuestion == correctAnswer then
  600.                 appearWell(nil,startIdControlEndQuestion,currentQuestionAnswers[nextIdControlEndQuestion], 270,(nextIdControlEndQuestion * 60)+50, "success")
  601.             else
  602.                 appearWell(nil,startIdControlEndQuestion,currentQuestionAnswers[nextIdControlEndQuestion], 270,(nextIdControlEndQuestion * 60)+50, "danger")
  603.             end
  604.     elseif timeControlEndQuestion%1 == 0 and removeAnswersCheckEndQuestion and startIdControlEndQuestion > 1000000 then
  605.         ui.removeTextArea(startIdControlEndQuestion,nil)
  606.         startIdControlEndQuestion = startIdControlEndQuestion -1
  607.     elseif removeAnswersCheckEndQuestion and startIdControlEndQuestion == 1000000 then     
  608.         finishRound = false;
  609.         deleteGUIElement(9);
  610.         finishForNewRound()
  611.     elseif canShowCheckEndQuestion then
  612.        
  613.         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)])
  614.        
  615.        
  616.        
  617.     end
  618. end
  619.  
  620.  
  621. eventLoop = function()
  622.     handledCronometresFunction();
  623.     if finishRound == true then
  624.         handledEndQuestionEach()
  625.     end    
  626.     for i = 1, #remSplash do
  627.         if os.time() > remSplash[i].time then
  628.             tfm.exec.removeImage(remSplash[i].id)
  629.         else
  630.             for j = 1, i - 1 do
  631.                 table.remove(remSplash, j)
  632.             end
  633.             break
  634.         end
  635.     end
  636. end
  637.  
  638.  
  639. table.remove = function(list, pos)
  640.     local len, out = #list
  641.  
  642.     if not pos or pos == len then
  643.         out = list[len]
  644.         list[len] = nil
  645.     elseif pos < len then
  646.         local out = list[pos]
  647.         list[pos] = nil
  648.  
  649.         for i = pos, len do
  650.             list[i] = list[i + 1]
  651.         end
  652.     end
  653.     return out
  654. end
  655.  
  656.  
  657. eventChatCommand = function (name, command)
  658.     local args={}
  659.     for arg in command:gmatch("[^%s]+") do
  660.                 table.insert(args, arg)
  661.     end
  662.     if args[1] == "stats" or args[1] == "perfil" or args[1] == "profile" then
  663.         if playerData[capitalize(args[2])] or args[2] == "me" or args[2] == "" or not args[2] then
  664.             if playerData[capitalize(args[2])] then
  665.                 player = capitalize(args[2])
  666.             else
  667.                 args[2]= name
  668.                 player = name
  669.             end
  670.             sendprofile(player, name)
  671.         else
  672.        
  673.             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)
  674.         end
  675.     end
  676.  
  677.         if args[1]=="musupro" then
  678.             desbtitle(name,2)
  679.         end
  680.        
  681.     if args[1]=="title" then
  682.         if args[2] then
  683.             changetitle(name,args[2])
  684.         elseif not args[2] then            
  685.             appearPanel(false, name, 850,"xmedium","Titulos", returnTitles(name,true, 1,15,1),50,50,true, "success",320)
  686.         end
  687.        
  688.     end
  689.     if args[1]=="re" then
  690.         tfm.exec.respawnPlayer(name)
  691.     end
  692.    
  693.     if args[1]=="rank" then
  694.         getRank(name,0,10)
  695.     end
  696.  
  697.         if args[1] == "save" then
  698.             exportForG(name)
  699.         end
  700.         if args[1] == "start" then
  701.             cronometres = {}  
  702.             currentQuestion = 0;
  703.             addCronometre(startTime,1,"¡Falta poco para empezar!",newRound)  
  704.             tfm.exec.chatMessage("<J>¿Estás preparado/a? ¡Ya vamos a empezar!", nil)
  705.            
  706.         end
  707.         if args[1] == "stop" then
  708.             deleteGUIElement(8000000)
  709.             deleteGUIElement(8000001)
  710.             cronometres = {}        
  711.         end    
  712.     if args[1] == "pause" then
  713.             cronometres = {}  
  714.           addCronometre(args[2]+0 ,0,"¡Hagamos una pausa! Esperemos",newRound)    
  715.          
  716.         end
  717.    
  718.    
  719. end
  720.  
  721. sendprofile = function (name, requestUser)
  722. local player = playerData[name]
  723.     sumaRounds = player.played
  724.     sumaWins = player.answered
  725.     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)   
  726.    
  727.  
  728.     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)
  729.    
  730.     text = text.."\n\n<p align='center'>+"
  731.     appearPanel(false, requestUser, 850,"xmedium",string.format("<p align='center'><h4><font color='#264348'>%s</h4></p>",name), text,50,50,true, "success",320)
  732.    
  733.    
  734.    
  735.    
  736. end
  737.  
  738.  
  739.  
  740. capitalize = function(word)
  741.  if word then
  742.     if word:find("+") then  
  743.         return string.upper(word:sub(1,2)) .. string.lower (word:sub(3))
  744.     else
  745.      return string.upper(word:sub(1,1)) .. string.lower (word:sub(2))  
  746.     end
  747.  end
  748. end
  749.  
  750. function getRank(p,hola,pe)
  751.     if hola == nil then
  752.         hola,pe = 0,10
  753.     end
  754.     scoreall={}
  755.     info=""
  756.     for a,b in pairs(tfm.get.room.playerList)do
  757.         if playerData[a] and tfm.get.room.playerList[a] then
  758.             player = playerData[a]
  759.             sumaRounds = player.played
  760.             sumaWins = player.answered
  761.  
  762.         operacion = (sumaWins/sumaRounds) * 100
  763.         if type(operacion) ~= "number" or operacion < 0 or operacion == math.huge or  isnan(operacion) == true then
  764.             operacion = 0
  765.         end
  766.         player.operacion= operacion
  767.         table.insert(scoreall,{nombre=a,operacion=operacion,sumwins=sumaWins, jugadas=sumaRounds})
  768.         end
  769.     end
  770.     table.sort (scoreall,function (a,b)return a.sumwins>b.sumwins end) 
  771.      for i,b in pairs(scoreall)do
  772.         playerData[b.nombre].rank = i    
  773.        
  774.     end
  775.     for a=hola,pe do
  776.         if scoreall[a] then        
  777.             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) .."%")     
  778.                    
  779.         end
  780.        
  781.     end
  782.     if a then
  783.         if info=='' then
  784.             ex = "<J>No hay resultados para el rango ["..hola.." - "..pe.."]"
  785.         else
  786.             ex = "Rango de busqueda ["..hola.." - "..pe.."]"
  787.         end    
  788.        
  789.         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") 
  790.     end
  791. end
  792.  
  793. function isnan(x) return x ~= x end
  794.  
  795. function getRankName(number)
  796.     local as ="";
  797.     if number > 120 then
  798.         return  "<J>Aprendiz ★★★</J>"
  799.     elseif number > 100 then
  800.         return  "<J>Aprendiz ★★</J>"
  801.     elseif number > 80 then
  802.         return  "<J>Aprendiz ★</J>"
  803.     elseif number > 60 then
  804.         return  "<J>Aprendiz</J>"
  805.     elseif number > 50 then
  806.         return  "<v>Nerd ★★★</v>"
  807.     elseif number > 40 then
  808.         return  "<v>Nerd ★★</v>"   
  809.     elseif number > 30 then
  810.         return  "<v>Nerd ★</v>"  
  811.     elseif number > 20 then
  812.         return "<v>Nerd ★</v>"           
  813.     else
  814.         return "<V>Nerd</V>"
  815.     end
  816.    
  817.  
  818. end
  819.  
  820.  
  821. function exportForG(sendto)
  822.     local string = ""
  823.     i = 0
  824.     for name, player in pairs(playerData) do
  825.         i = i + 1
  826.         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)    
  827.         if(i == 6) then
  828.             tfm.exec.chatMessage(string, sendto)
  829.             print(string)
  830.             i = 0
  831.             string = ""
  832.         end
  833.     end
  834.    
  835.     tfm.exec.chatMessage(string, sendto)
  836.     print(string)
  837. end
  838.  
  839. function string.split(inputstr, sep)
  840.     if sep == nil then
  841.             sep = "%s"
  842.     end
  843.     local t={} ; i=1
  844.     for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  845.             t[i] = str
  846.             i = i + 1
  847.     end
  848.     return t
  849. end
  850.  
  851. function getColorForRanking(space)
  852.     a = ""
  853.     if space == 1 then     
  854.         a = "<J>"
  855.     elseif space == 2 then
  856.         a = "<N>"
  857.     elseif space == 3 then
  858.         a = "<VI>"
  859.     else
  860.         a = "<BL>"
  861.     end
  862.    
  863.     return a..space
  864. end
  865. handledStart()
  866.  
  867. function eventPlayerDied(name)
  868.     --tfm.exec.respawnPlayer(name)
  869.  
  870. end
  871.  
  872.  
  873. function g(name,wins, first, rounds, lose, points, torneos)
  874.     if not playerData[name] then
  875.         playerData[name] = defaultData()
  876.     end
  877.     player = playerData[name]
  878.    
  879.    
  880.     player.answered = (wins or 0) + 0
  881.     player.firstAnswered = (first or 0) + 0
  882.     player.played = (rounds or 0) + 0
  883.     player.losed = (lose or 0) + 0
  884.     player.points = (points or 0) + 0
  885.     player.isTorneos = torneos;
  886.    
  887.     ui.addTextArea(9999999999999, "<VP>$"..playerData[name].points.." <a href='event:ggcoins'><R>[+] ", name,750,380,50,nil,nil,0x324650,nil,true)
  888.  
  889.    
  890.      
  891. end
Add Comment
Please, Sign In to add comment