Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --! TORNEOS.GG S.A.S
- -- SÓLO PARA EL USO INTERNO, O CONFERIDO PARA EL USO.
- --
- --
- --
- --
- --
- -- Author: TORNEOS.GG S.A.S
- -- Date: 03/01/2019
- -- Version: 0.1
- -- Minigame: TRANSFORQUIZ#001
- --
- --
- -- ♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛♛
- local admins = {Musugas = true}
- ---VARS, DONT TOUCH
- local cronometres = {}
- local timeControlEndQuestion =0
- local finishRound = false
- local canShowCheckEndQuestion = true
- local canAnswersCheckEndQuestion = false
- nextIdControlEndQuestion = 0
- local startIdControlEndQuestion = 1000000;
- local phrasesControlEndQuestion = {"Veamos...","¿Habrás ganado?","¿Habrás perdido?","¿Quizás fuiste el mejor?","Todo un@ Einstein?","¿super-mega-inteligentisisisismo?"}
- local namesForModes = {"Multiple","Escribela","Plataforma"}
- local colorTags = {"warning","danger","success","info","white"}
- local respuestas = {"15","32","18","25"}
- local correctAnswer = 3
- local allUIElements = {}
- local removeAnswersCheckEndQuestion = false
- local currentQuestion = 0
- local startTime = 30;
- local currentCategorie = 0
- local currentMode = 0
- local currentQuestionTitle = ""
- local currentQuestionAnswers = {}
- local playerData = {}
- local winners = {}
- local losers = {}
- local titleIdLocal = 98565020
- local startTimeRound = os.time()
- local categories = {"Arte","Ciencia","Geografia","Historia","Entretenimiento","Videojuegos", "Atelier801"}
- local duration = 5 * 1000 -- 5s
- local remSplash = { }
- local errors= {
- [0] = "Error",
- "Unidentified profile",
- "Unidentified command",
- "We could not find the language",
- "You cannot use that",
- "Forbidden",
- "You are disqualified",
- "You cannot report %s",
- "<R>You do not have that title",
- "You have the maximum level",
- "The action [%s] could not be found"}
- ---============= GUIA
- --[[
- 1 valor = Pregunta
- 2 valor = Respuestas MAXIMO SOLO 4
- 3 valor = Numero de la respuesta correcta
- 4 valor = Tipo - Modo
- 5 valor = Categoria
- 6 valor = Tiempo en formato 60 (1 minuto = 60 segundos)
- TIPOS DISPONIBLES:
- 1 = multiple.
- ]]
- local questions = {
- {"¿A cuál empresa pertenece Fortnite?",{"Riot Games", "Epic Games", "Mojang AB", "Rockstar Games"}, 2, 1, 6, 15},
- {"¿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},
- {"¿Por cuál simbolo son representados los mapas cooperativos?",{"Dos cañones", "Dos plumas", "Dos banderas", "Dos pinceles"}, 2, 1, 7, 15},
- {"¿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},
- {"¿Cuál de estos jugadores no forma parte del equipo de moderación?",{"Lezzly", "Tomatosin", "Yuloff", "Makis"}, 3, 1, 7, 15},
- {"¿Quién es el CCM de la comunidad española?",{"Zou", "Kura", "Galaktine", "Streaxx"}, 4, 1, 7, 15},
- {"¿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},
- {"¿A quién pertenece la obra Niño con paloma?",{"Tiziano", "Edvard Munch", "Pablo Ruiz Picasso", "Leonardo Da Vinci"}, 3, 1, 1, 15},
- {"¿Quién interpreta el tema Shape of you?",{"Paloma Mami", "Shakira", "Ed Sheeran", "Sia"}, 3, 1, 1, 15},
- {"¿En qué periodo se desarrolló la Guerra Fría?",{"1947 - 1953", "1950 - 1976", "1827 - 1900", "1762 - 1800"}, 1, 1, 4, 15},
- {"¿Qué es la Biología?",{"Estudio de la vida", "Estudio del universo", "Estudio de la biocenosis", "Estudio del ecosistema"}, 4, 1, 2, 15},
- {"¿Qué constituye la máxima evolución del universo?",{"El espacio", "El hombre", "La antimateria", "El tiempo"}, 2, 1, 2, 15},
- {"¿Con qué límita España al norte?",{"Francia", "Mar cantábrico", "Marruecos", "Mar mediterráneo"}, 2, 1, 3, 15},
- {"¿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},
- {"¿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},
- {"¿Cuál es la capitál de Pakistan?",{"Karachi", "Lahore", "Islamabad", "Quetta"}, 3, 1, 3, 15},
- {"¿En dónde está ubicado el Taj Mahal?",{"Jordania", "Armenia", "India", "Líbano"}, 3, 1, 3, 15},
- {"¿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},
- {"¿En dónde se originó el catolicismo?",{"Belén", "Judea", "Jerusalen", "Samaria"}, 3, 1, 3, 15},
- {"¿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},
- {"¿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},
- {"¿Durante qué años fue el mandato presidencial de George Walker Bush?",{"1889 - 1992", "1989 – 1993", "1762 - 1884", "1989 - 1996"}, 2, 1, 4, 15},
- {"¿A cuál empresa pertenece la consola PlayStation?",{"Nintendo", "Apple", "Sony", "Microsoft"}, 3, 1, 6, 15},
- {"¿Cuántos países tiene América?",{"21", "42", "35", "11"}, 3, 1, 3, 15},
- {"¿En qué año se originó la creación del primer computador?",{"1928", "1992", "1936", "1911"}, 3, 1, 4, 15}
- }
- defaultData = function()
- data = {
- points = 0,
- respondThistime = false,
- miniCronometre = false,
- needMiniCronometre = false,
- consecutiveAnswered = 0,
- consecutiveAnsweredRank = 0,
- correct = false,
- -- 1 = winners
- -- 2 losers
- -- 3 played
- firstAnswered = 0,
- rank = 0,
- operacion = 0,
- answered = 0,
- played = 0,
- losed = 0,
- tr=1,
- ta=1,
- currentPage = 1,
- isTorneos = 0,
- img = "",
- timeForImg = 0
- }
- return data
- end
- finishForNewRound = function()
- timeControlEndQuestion =0
- finishRound = false
- canShowCheckEndQuestion = true
- canAnswersCheckEndQuestion = false
- removeAnswersCheckEndQuestion = false
- nextIdControlEndQuestion = 0
- startIdControlEndQuestion = 1000000;
- text,number = "\n<font size='15'>",1
- if #winners > 0 then
- for i=1, #winners do
- if number == 1 then
- playerData[winners[i][1]].firstAnswered = playerData[winners[i][1]].firstAnswered + 1
- tfm.exec.chatMessage("<J>"..winners[i][1].." ha sido super veloz!", nil)
- end
- playerData[winners[i][1]].points = playerData[winners[i][1]].points + 1
- --playerData[winners[i][1]].modesStats[currentMode][1] = playerData[winners[i][1]].modesStats[currentMode][1] + 1
- playerData[winners[i][1]].answered = playerData[winners[i][1]].answered + 1
- playerData[winners[i][1]].correct = true
- playerData[winners[i][1]].consecutiveAnswered= playerData[winners[i][1]].consecutiveAnswered + 1
- if playerData[winners[i][1]].consecutiveAnswered > playerData[winners[i][1]].consecutiveAnsweredRank then
- playerData[winners[i][1]].consecutiveAnsweredRank= playerData[winners[i][1]].consecutiveAnswered
- end
- 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)
- 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)
- tfm.exec.displayParticle(15,760, 370,0,-9,0,1,winners[i][1])
- number = number + 1
- end
- appearPanel(false, name, 6000,"medium","<p align='center'><h4><font color='#264348'>Ganadores!</h4></p>", text ,50,50,true, "success",320)
- else
- 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")
- end
- for i=1, #losers do
- playerData[losers[i]].losed = playerData[losers[i]].losed + 1
- --playerData[losers[i]].modesStats[currentMode][2] = playerData[losers[i]].modesStats[currentMode][2] + 1
- end
- thisNewQuestion = currentQuestion+1
- newRound()
- end
- local splash = function(playerName)
- remSplash[#remSplash + 1] = { id = tfm.exec.addImage("1681bdc4591.png", "&0", 100, 115, playerName), time = os.time() + duration }
- end
- handledStart = function()
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoTimeLeft(true)
- tfm.exec.disableAutoShaman(true)
- for i, command in ipairs ({"q","msg","pause","start", "save"}) do
- system.disableChatCommandDisplay(command,true)
- end
- 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!<>")
- table.foreach(tfm.get.room.playerList, eventNewPlayer)
- splash()
- tfm.exec.newGame('@7558519')
- tfm.exec.setGameTime(99999)
- end
- newRound = function()
- for name, player in pairs(playerData) do
- if not player.correct then
- player.consecutiveAnswered = 0
- end
- player.respondThistime = false
- player.needMiniCronometre=false
- player.correct = false
- end
- if currentQuestion == #questions then
- tfm.exec.chatMessage("<J>Hemos terminado esta ronda de TransforQuiz, ¡Esperamos que te hayas divertido Yujuuuuuuuuu!")
- getRank(nil,0,10)
- else
- currentQuestion = currentQuestion + 1
- addCronometre(15,0,string.format("<p align='center'>Categoria: %s",categories[questions[currentQuestion][5]]),drawQuestionSide)
- end
- end
- finishRoundFunc = function()
- for name, player in pairs(playerData) do
- if not player.respondThistime then
- player.losed = player.losed + 1
- -- player.modesStats[currentMode][2] = player.modesStats[currentMode][2] + 1
- player.consecutiveAnswered = 0
- end
- end
- for i=1,#allUIElements do
- ui.removeTextArea(allUIElements[i],nil)
- end
- if currentMode == 2 then
- ui.addPopup(8560,2,"",name,-8000,-800,300,true)
- end
- finishRound = true
- end
- handledAnswerResponse = function(name, response)
- if not playerData[name].respondThistime then
- playerData[name].respondThistime = true
- if currentMode == 1 then
- if correctAnswer == response then
- tablu = {name,math.abs(math.floor((startTimeRound-os.time())/10)/100)}
- table.insert(winners, tablu)
- else
- table.insert(losers, name)
- end
- elseif currentMode == 2 then
- if response == questions[currentQuestion][2][1] then
- tablu = {name,math.abs(math.floor((startTimeRound-os.time())/10)/100)}
- table.insert(winners, tablu)
- else
- table.insert(losers, name)
- end
- playerData[name].needMiniCronometre = true
- end
- for i=1,#allUIElements do
- ui.removeTextArea(allUIElements[i],name)
- end
- ui.addPopup(8560,2,"",name,-255151,-1151,300,true)
- playerData[name].played = playerData[name].played + 1
- -- playerData[name].modesStats[currentMode][3] = playerData[name].modesStats[currentMode][3] + 1
- end
- end
- eventNewPlayer = function(name)
- if (not playerData[name]) then
- playerData[name] = defaultData()
- end
- tfm.exec.chatMessage("<J>¡Bienvenido a TransforQuiz! Creo que tu cerebro está un poco grande... veamoslo.", name)
- 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)
- splash(name)
- ui.addTextArea(9999999999999, "<VP>$"..playerData[name].points.." <a href='event:ggcoins'><R>[+] ", name,750,380,50,nil,nil,0x324650,nil,true)
- tfm.exec.respawnPlayer(name)
- --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")
- end
- drawQuestionSide = function ()
- deleteGUIElement(6000)
- startTimeRound = os.time()
- winners = {}
- losers = {}
- question = questions[currentQuestion]
- correctAnswer = question[3]
- title = question[1]
- answers = question[2]
- time = question[6]
- currentMode = question[4]
- addCronometre(time,2,"",finishRoundFunc)
- currentQuestionTitle = title
- currentQuestionAnswers = answers
- appearBigWindow(false, 0, nil, "Responde a la pregunta", string.format("\n<p align='center'><h3>%s",title), false, "info","nada")
- if currentMode == 1 then
- local coords = {{120,240},{420,240},{120,300},{420,300}}
- for i=1,#answers do
- appearWell(nil,i,answers[i], coords[i][1],coords[i][2], "primary",string.format("mianswer%d",i))
- end
- elseif currentMode == 2 then
- ui.addPopup(8560,2,"",name,250,250,300,true)
- end
- appearPanel(false, name, 9,"xsmall","<p align='center'><h5><font color='#264348'>Pasar</h5></p>", "",150,200,false, "warning")
- appearPanel(false, name, 10,"xsmall","<p align='center'><h5><font color='#264348'>Rendirme</h5></p>", "",550,200,false, "danger")
- end
- eventPopupAnswer =function(id, name, answer)
- if id==8560 then
- handledAnswerResponse(name,answer:lower())
- end
- end
- --===================== UI FUNCTIONS
- --===================== Module: MNET UI API TFM
- parserColor = function (type)
- if type == "danger" then
- color = 0xE74C3C
- elseif type == "warning" then
- color = 0xF39C12
- elseif type == "primary" then
- color = 0x0F424D
- elseif type == "success" then
- color = 0x149C82
- elseif type == "white" then
- color = 0xffebee
- elseif type == "info" then
- color = 0x269ABC
- else
- color = 0x0F424D
- end
- return color
- end
- htmlParser = function(content)
- local PARSER_TABLE = {
- {"<h1>" , "<font size='32'>"},
- {"<h2>" , "<font size='24'>"},
- {"<h3>" , "<font size='19'>"},
- {"<h4>" , "<font size='16'>"},
- {"<h5>" , "<font size='14'>"},
- {"<h6>" , "<font size='13'>"},
- {"</h(%d)>" , "</font>"}
- }
- for i=1,#PARSER_TABLE do
- content = content:gsub(PARSER_TABLE[i][1], PARSER_TABLE[i][2])
- end
- return content
- end
- appearBigWindow = function(white,id1,name, title, text, close, type,event)
- if white then
- colorForBack = 0xffebee
- else
- colorForBack = 0x43353D
- end
- local id2 = id1+100000;
- if name == nil then
- table.insert(allUIElements,id2)
- table.insert(allUIElements,id1)
- table.insert(allUIElements,id1+900000)
- end
- color = parserColor(type)
- title, text = htmlParser(title), htmlParser(text)
- ui.addTextArea(id1,text,name,100,80,600,280,colorForBack,colorForBack,1,true)
- 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)
- if close then
- if event then
- 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)
- else
- 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)
- end
- end
- end
- appearPanel = function(white, name, id1,typeof,title, text,x,y,close, type,maxHeight, event)
- local w;
- local id2 = id1+100000;
- local h = nil
- if(maxHeight) then
- h = maxHeight
- end
- color = parserColor(type)
- if white then
- colorForBack = 0xffebee
- else
- colorForBack = 0x43353D
- end
- title, text = htmlParser(title), htmlParser(text)
- if typeof=="big" then
- w = 700
- elseif typeof=="xbig" then
- w = 600
- elseif typeof=="medium" then
- w = 500
- elseif typeof=="xmedium" then
- w = 300
- elseif typeof=="small" then
- w = 200
- elseif typeof=="xsmall" then
- w = 100
- end
- if name == nil then
- table.insert(allUIElements,id2)
- table.insert(allUIElements,id1)
- table.insert(allUIElements,id1+900000)
- end
- ui.addTextArea(id1,text,name,x,y,w,h,colorForBack,color,1,true)
- ui.addTextArea(id2,title,name,x,y-20,w,nil,color, color,1,true)
- if close then
- if event then
- 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)
- else
- 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)
- end
- end
- end
- appearWell = function(name, id, text, x, y, type, event)
- color = parserColor(type)
- if name == nil then
- table.insert(allUIElements,id)
- end
- if event~=nil then
- text = string.format("<p align='center'><font color='#ffffff'><a href='event:%s'>%s</a></font></p>",event, text)
- else
- text = string.format("<p align='center'><font color='#ffffff'>%s</font></p>",text, event)
- end
- ui.addTextArea(id,text,name,x,y,250,40,color, color,1,true)
- end
- getCronometro = function(seconds)
- color = "white"
- hours = math.floor(seconds / 3600);
- mins = math.floor((seconds - (hours*3600)) / 60);
- secs = math.floor(seconds % 60);
- if(seconds<120) then
- color = "info"
- end
- if(seconds<60) then
- color = "success"
- end
- if(seconds<30) then
- color = "warning"
- end
- if(seconds<5) then
- color = "danger"
- end
- if(mins < 10) then
- mins = "0"..mins
- end
- if(secs<10) then
- secs = "0"..secs
- end
- dada = {secs,mins, color}
- return dada
- end
- addCronometre = function(seconds, type, text,event)
- cronometro = {seconds,type,text,event}
- table.insert(cronometres, cronometro)
- end
- handledCronometresFunction = function()
- for i=1,#cronometres do
- this_cronometre = cronometres[i]
- if this_cronometre[1] > 0 then
- this_cronometre[1] = this_cronometre[1] - 0.5
- cronometreTypes(this_cronometre[2],this_cronometre[1],this_cronometre[3],this_cronometre[4])
- else
- ui.removeTextArea(8000000,nil)
- ui.removeTextArea(8000001,nil)
- table.remove(cronometres, i)
- end
- end
- end
- cronometreTypes = function(type, seconds,text,func)
- dates = getCronometro(seconds)
- if seconds==0 and func~=nil then
- cronometres = {}
- func()
- end
- for name, player in pairs(playerData) do
- if type==0 and player.miniCronometre == false and player.needMiniCronometre==false then
- if seconds<5 and seconds%1 == 0 then
- appearPanel(false, name, 8000000,"small","", "\n",561501510,50,false, dates[3])
- else
- 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])
- end
- elseif type==1 and player.miniCronometre == false and player.needMiniCronometre==false then
- if seconds<5 and seconds%1 == 0 then
- appearPanel(false, name, 8000000,"small","", "\n",561501510,50,false, dates[3])
- appearPanel(false, name, 8000001,"small","", "\n",561501510,50,false, dates[3])
- else
- 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])
- appearPanel(false, name, 8000001,"small",string.format("<p align='center'><h3><font color='#264348'>%s</h3></p>",text), "",300,240,false, dates[3])
- end
- elseif type==2 and player.miniCronometre == false and player.respondThistime == false and player.needMiniCronometre==false then
- if seconds<5 and seconds%1 == 0 then
- appearPanel(false, name, 8000000,"small","", "\n",561501510,50,false, dates[3])
- else
- 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])
- end
- elseif player.miniCronometre or player.respondThistime or player.needMiniCronometre then
- if seconds<5 and seconds%1 == 0 then
- appearPanel(false, name, 8000000,"small","", "\n",561501510,50,false, dates[3])
- else
- 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])
- end
- end
- end
- end
- --=============================================
- eventTextAreaCallback = function(id, name, cb)
- tfm.exec.changePlayerSize(name, math.random(0.1, 3))
- if cb=="closethis" then
- ui.removeTextArea(id, name)
- end
- if cb:find("closeMnetUI") then
- id = cb:sub(12);
- ui.removeTextArea(id, name);
- ui.removeTextArea(id+900000, name);
- ui.removeTextArea(id+100000, name);
- end
- if cb:sub(1,8)=="mianswer" then
- handledAnswerResponse(name, cb:sub(9)+0)
- tfm.exec.playEmote ( name, math.random(24) )
- end
- if cb=="ggcoins" then
- ggcoins = playerData[name].points * 5,3
- 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 )
- end
- if cb:sub(1,4) == "prev" or cb:sub(1,4) =="next" then
- dataThis = playerData[name]
- cbCurrent = cb:sub(5)
- if cbCurrent == "rank" then
- if cb:sub(1,4) =="next" and dataThis.ta ~= 5 then
- dataThis.tr,dataThis.ta = dataThis.tr +10,dataThis.ta+1
- elseif cb:sub(1,4) =="prev" and dataThis.ta ~= 1 then
- dataThis.tr,dataThis.ta,dataThis.currentPage = dataThis.tr -10,dataThis.ta-1,dataThis.currentPage-1
- end
- getRank(name,dataThis.tr,dataThis.ta*10)
- end
- end
- end
- deleteGUIElement = function(id)
- ui.removeTextArea(id, name);
- ui.removeTextArea(id+900000, name);
- ui.removeTextArea(id+100000, name);
- end
- handledEndQuestionEach = function()
- timeControlEndQuestion = timeControlEndQuestion + 1
- numeroForDisplayQuestions = #currentQuestionAnswers
- if #currentQuestionAnswers == 2 then
- numeroForDisplayQuestions = 2
- end
- if timeControlEndQuestion == 8 then
- canShowCheckEndQuestion = false
- elseif timeControlEndQuestion == (5*#currentQuestionAnswers)+5 then
- removeAnswersCheckEndQuestion = true
- canAnswersCheckEndQuestion = false
- elseif timeControlEndQuestion == 5 then
- canAnswersCheckEndQuestion = true
- appearPanel(false, name, 9,"medium","<p align='center'><h4><font color='#264348'>"..currentQuestionTitle.." </h4></p>", "",150,70,false, "white")
- elseif timeControlEndQuestion%1 == 0 and canAnswersCheckEndQuestion and nextIdControlEndQuestion < #currentQuestionAnswers then
- startIdControlEndQuestion = startIdControlEndQuestion + 1
- nextIdControlEndQuestion = nextIdControlEndQuestion + 1
- if nextIdControlEndQuestion == correctAnswer then
- appearWell(nil,startIdControlEndQuestion,currentQuestionAnswers[nextIdControlEndQuestion], 270,(nextIdControlEndQuestion * 60)+50, "success")
- else
- appearWell(nil,startIdControlEndQuestion,currentQuestionAnswers[nextIdControlEndQuestion], 270,(nextIdControlEndQuestion * 60)+50, "danger")
- end
- elseif timeControlEndQuestion%1 == 0 and removeAnswersCheckEndQuestion and startIdControlEndQuestion > 1000000 then
- ui.removeTextArea(startIdControlEndQuestion,nil)
- startIdControlEndQuestion = startIdControlEndQuestion -1
- elseif removeAnswersCheckEndQuestion and startIdControlEndQuestion == 1000000 then
- finishRound = false;
- deleteGUIElement(9);
- finishForNewRound()
- elseif canShowCheckEndQuestion then
- 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)])
- end
- end
- eventLoop = function()
- handledCronometresFunction();
- if finishRound == true then
- handledEndQuestionEach()
- end
- for i = 1, #remSplash do
- if os.time() > remSplash[i].time then
- tfm.exec.removeImage(remSplash[i].id)
- else
- for j = 1, i - 1 do
- table.remove(remSplash, j)
- end
- break
- end
- end
- end
- table.remove = function(list, pos)
- local len, out = #list
- if not pos or pos == len then
- out = list[len]
- list[len] = nil
- elseif pos < len then
- local out = list[pos]
- list[pos] = nil
- for i = pos, len do
- list[i] = list[i + 1]
- end
- end
- return out
- end
- eventChatCommand = function (name, command)
- local args={}
- for arg in command:gmatch("[^%s]+") do
- table.insert(args, arg)
- end
- if args[1] == "stats" or args[1] == "perfil" or args[1] == "profile" then
- if playerData[capitalize(args[2])] or args[2] == "me" or args[2] == "" or not args[2] then
- if playerData[capitalize(args[2])] then
- player = capitalize(args[2])
- else
- args[2]= name
- player = name
- end
- sendprofile(player, name)
- else
- 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)
- end
- end
- if args[1]=="musupro" then
- desbtitle(name,2)
- end
- if args[1]=="title" then
- if args[2] then
- changetitle(name,args[2])
- elseif not args[2] then
- appearPanel(false, name, 850,"xmedium","Titulos", returnTitles(name,true, 1,15,1),50,50,true, "success",320)
- end
- end
- if args[1]=="re" then
- tfm.exec.respawnPlayer(name)
- end
- if args[1]=="rank" then
- getRank(name,0,10)
- end
- if args[1] == "save" then
- exportForG(name)
- end
- if args[1] == "start" then
- cronometres = {}
- currentQuestion = 0;
- addCronometre(startTime,1,"¡Falta poco para empezar!",newRound)
- tfm.exec.chatMessage("<J>¿Estás preparado/a? ¡Ya vamos a empezar!", nil)
- end
- if args[1] == "stop" then
- deleteGUIElement(8000000)
- deleteGUIElement(8000001)
- cronometres = {}
- end
- if args[1] == "pause" then
- cronometres = {}
- addCronometre(args[2]+0 ,0,"¡Hagamos una pausa! Esperemos",newRound)
- end
- end
- sendprofile = function (name, requestUser)
- local player = playerData[name]
- sumaRounds = player.played
- sumaWins = player.answered
- 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)
- 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)
- text = text.."\n\n<p align='center'>+"
- appearPanel(false, requestUser, 850,"xmedium",string.format("<p align='center'><h4><font color='#264348'>%s</h4></p>",name), text,50,50,true, "success",320)
- end
- capitalize = function(word)
- if word then
- if word:find("+") then
- return string.upper(word:sub(1,2)) .. string.lower (word:sub(3))
- else
- return string.upper(word:sub(1,1)) .. string.lower (word:sub(2))
- end
- end
- end
- function getRank(p,hola,pe)
- if hola == nil then
- hola,pe = 0,10
- end
- scoreall={}
- info=""
- for a,b in pairs(tfm.get.room.playerList)do
- if playerData[a] and tfm.get.room.playerList[a] then
- player = playerData[a]
- sumaRounds = player.played
- sumaWins = player.answered
- operacion = (sumaWins/sumaRounds) * 100
- if type(operacion) ~= "number" or operacion < 0 or operacion == math.huge or isnan(operacion) == true then
- operacion = 0
- end
- player.operacion= operacion
- table.insert(scoreall,{nombre=a,operacion=operacion,sumwins=sumaWins, jugadas=sumaRounds})
- end
- end
- table.sort (scoreall,function (a,b)return a.sumwins>b.sumwins end)
- for i,b in pairs(scoreall)do
- playerData[b.nombre].rank = i
- end
- for a=hola,pe do
- if scoreall[a] then
- 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) .."%")
- end
- end
- if a then
- if info=='' then
- ex = "<J>No hay resultados para el rango ["..hola.." - "..pe.."]"
- else
- ex = "Rango de busqueda ["..hola.." - "..pe.."]"
- end
- 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")
- end
- end
- function isnan(x) return x ~= x end
- function getRankName(number)
- local as ="";
- if number > 120 then
- return "<J>Aprendiz ★★★</J>"
- elseif number > 100 then
- return "<J>Aprendiz ★★</J>"
- elseif number > 80 then
- return "<J>Aprendiz ★</J>"
- elseif number > 60 then
- return "<J>Aprendiz</J>"
- elseif number > 50 then
- return "<v>Nerd ★★★</v>"
- elseif number > 40 then
- return "<v>Nerd ★★</v>"
- elseif number > 30 then
- return "<v>Nerd ★</v>"
- elseif number > 20 then
- return "<v>Nerd ★</v>"
- else
- return "<V>Nerd</V>"
- end
- end
- function exportForG(sendto)
- local string = ""
- i = 0
- for name, player in pairs(playerData) do
- i = i + 1
- 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)
- if(i == 6) then
- tfm.exec.chatMessage(string, sendto)
- print(string)
- i = 0
- string = ""
- end
- end
- tfm.exec.chatMessage(string, sendto)
- print(string)
- end
- function string.split(inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t={} ; i=1
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- t[i] = str
- i = i + 1
- end
- return t
- end
- function getColorForRanking(space)
- a = ""
- if space == 1 then
- a = "<J>"
- elseif space == 2 then
- a = "<N>"
- elseif space == 3 then
- a = "<VI>"
- else
- a = "<BL>"
- end
- return a..space
- end
- handledStart()
- function eventPlayerDied(name)
- --tfm.exec.respawnPlayer(name)
- end
- function g(name,wins, first, rounds, lose, points, torneos)
- if not playerData[name] then
- playerData[name] = defaultData()
- end
- player = playerData[name]
- player.answered = (wins or 0) + 0
- player.firstAnswered = (first or 0) + 0
- player.played = (rounds or 0) + 0
- player.losed = (lose or 0) + 0
- player.points = (points or 0) + 0
- player.isTorneos = torneos;
- ui.addTextArea(9999999999999, "<VP>$"..playerData[name].points.." <a href='event:ggcoins'><R>[+] ", name,750,380,50,nil,nil,0x324650,nil,true)
- end
Add Comment
Please, Sign In to add comment