Advertisement
Bolodefchoco_LUAXML

[Game] Perguntas & Respostas

Dec 4th, 2015
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.42 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 04/12/2015
  3. --Last update: 21/05/2016
  4. --[[ Notes:
  5.     Does:
  6.         Um jogo de quizes
  7.     Commands:
  8.         /
  9.             skip --> Quanto metade da sala digitar /skip a pergunta será pulada
  10. ]]--
  11.  
  12. asks = {
  13.     easy = {
  14.         news = {
  15.             {"Em que estado ocorreu o ataque terrorista das torres gêmeas?",{"new york","nova york","nova iorque"}},
  16.             {"Qual o nome dos terroristas que atacaram a França em 2015?",{"isis","estado islamico","islamicos"}},
  17.             {"Como se chama a moeda oficial usada nos Estados Unidos da América?",{"dollar","dolar"}},
  18.         };
  19.         sci = {
  20.             {"Onde o embrião se desenvolve no corpo da mãe?",{"utero","barriga"}},
  21.             {"Como se chama o médico que cuida do olhos?",{"oftalmologista"}},
  22.             {"Quantos planetas têm no Sistema Solar?",{'8','9','10'}},
  23.         };
  24.         hist = {
  25.             {"Qual o nome do povo que vivia no Brasil antes dos portugueses?",{"indigenas","indios"}},
  26.             {"Em qual lugar da fazenda ficavam alojados os escravos?",{"senzala"}},
  27.         };
  28.         entert = {
  29.             {"Qual o nome da revista sensual mais vendida do mundo?",{"playboy"}},
  30.             {"Em Harry Potter e a Pedra Filosofal que casa ganhou a taça das casas?",{"grifinoria"}},
  31.         };
  32.         pt = {
  33.             {"Adjetivos são usados para dar____",{"qualidade","qualidades","caracteristica","caracteristicas"}},
  34.             {"Qual dessas duas formas é a correta: min ou mim?",{"mim"}},
  35.             {"Qual o coletivo de porcos?",{"vara"}},
  36.             {"Qual o coletivo de lobos?",{"alcateia"}},
  37.         };
  38.         quiz = {
  39.             {"Ema ema ema, qual o nome da clara do ovo?",{"clara"}},
  40.             {"Bob Esponja _______ ________",{"calça quadrada"},{"square pants"}},
  41.         };
  42.         geo = {
  43.             {"A Itália fica em qual continente?",{"europeu","europa"}},
  44.             {"Qual a moeda do Japão?",{"iene"}},
  45.             {"Quantos oceanos existem na Terra?",{'3'}},
  46.         };
  47.     };
  48.     medium = {
  49.         news = {
  50.             {"Qual dos anões de Branca de Neve é mudo?",{"dunga"}},
  51.             {"Quantos são os pecados capitais?",{'7'}},
  52.         };
  53.         sci = {
  54.             {"Como se chama a primeira ovelha clonada?",{"dolly"}},
  55.             {"Qual é a fórmula mais famosa de Einstein?",{"e=mc²","e=mc2","e=m*c^2","mc²","mc2"}},
  56.             {"Como se chama a unidade de medida do som?",{"decibel","decibeis"}},
  57.             {"Em que parte do nosso corpo existe um osso chamado Martelo?",{"ouvido","orelha"}},
  58.         };
  59.         hist = {
  60.             {"Em que ano foi dado o golpe que instituiu o regime militar no Brasil?",{'1964'}},
  61.             {"Em que ano foi descoberto a América?",{'1492'}},
  62.             {"Em que ano foi descoberto o Brasil?",{'1500'}},
  63.         };
  64.         entert = {
  65.             {"Qual o nome do cantor com mais views no youtube?",{"psy"}},
  66.             {"Quem criou o Menino Maluquinho?",{"ziraldo"}},
  67.             {"Sam e Dean são personagens de qual seriado?",{"sobrenatural","supernatural"}},
  68.         };
  69.         pt = {
  70.             {"Qual região a palavra JERIMUM significa ABÓBORA?",{"nordeste"}},
  71.             {"Qual o plural da palavra troféu?",{"trofeus"}},
  72.         };
  73.         quiz = {
  74.             {"Minha mãe tinha quatro filhas: Joana, Maria, Joaquina, Marta e, por fim, Eu. O que sou Eu?",{"adotada"}},
  75.             {"O que é que tem QUATRO letras e tirando duas fica ONZE?",{"taxi","xixi"}},
  76.             {"Quem faz saltos sensacionais sem tirar os pés do chão?",{"sapateiro","engraxate"}},
  77.         };
  78.         geo = {
  79.             {"Qual o nome dos dois países que ficam na Península Ibérica?",{"portugal","espanha","portugal e espanha","espanha e portugal"}},
  80.             {"Qual a maior ilha do mundo?",{"groenlandia"}},
  81.         };
  82.     };
  83.     hard = {
  84.         news = {
  85.             {"Qual foi a primeira emissora de TV no Brasil?",{"tupi","tv tupi"}},
  86.             {"Quem liderava os três mosqueteiros?",{"d artagnan","d. artagnan","artagnan"}},
  87.             {"O cantor Mick Jagger pertence a qual banda de rock?",{"rolling stones","the rolling stones"}},
  88.         };
  89.         sci = {
  90.             {"Qual é a sigla da estação espacial internacional?",{"iss"}},
  91.             {"Como se chama o médico especializado em tratamento de doenças da pele?",{"dermatologista"}},
  92.             {"Qual o mamífero que voa?",{"morcego"}},
  93.         };
  94.         hist = {
  95.             {"Qual o nome do primeiro presidente do Brasil?",{"marechal deodoro da fonseca","marechal deodoro","marechal fonseca"}},
  96.             {"Como se chamou o primeiro avião feito por Santos Dumont?",{"14 bis"}},
  97.             {"\"Saio da vida para entrar na história\". Quem escreveu essa frase em sua corta-testamento?",{"getulio vargas","vargas"}},
  98.         };
  99.         entert = {
  100.             {"Smaug pertence a que filme/saga?",{"hobbit","o hobbit","the hobbit"}},
  101.             {"Quem matou Fish na série Gotham?",{"pinguim","o pinguim"}},
  102.         };
  103.         pt = {
  104.             {"Qual é o nome dado aos verbos que não podem ser conjugados na primeira pessoa?",{"defectivos","verbos defectivos"}},
  105.             {"Qual o plural de \"calça cor-de-rosa\"?",{"calças cor-de-rosa"}},
  106.         };
  107.         quiz = {
  108.             {string.reverse("1 + 1 - 1 + 2 - 1 + 2 + 3?"),{'7'}},
  109.             {"Como fica uma vaca que faz muito exercício físico?",{"malhada","fica malhada"}},
  110.         };
  111.         geo = {
  112.             {"Qual a composição do granito?",{"mica","quartzo","feldspato"}},
  113.         };
  114.     };
  115. }
  116.  
  117. math.percent=function(number1,number2,t)
  118.     number1,number2=tonumber(number1),tonumber(number2)
  119.     return ((t==0 or not t) and number1/number2*100 or t==1 and (number1/100)*number2)
  120. end
  121.  
  122. string.replace=function(str,listi,listo)
  123.     for k,v in next,listi do
  124.         for i=1,#listo do
  125.             str=str:gsub(k,listo[v])
  126.         end
  127.     end
  128.     return str
  129. end
  130.  
  131. deactivateAccents=function(str,f)
  132.     local letters = {a = {"á","à","ä","â","ã"},e = {"é","è","ë","ê"},i = {"í","ì","î","ï"},o = {"ó","ò","ö","ô","õ"},u = {"ú","ù","ü","û"}}
  133.     for k,v in next,letters do
  134.         for i = 1,#v do
  135.             str = str:gsub(v[i],tostring(k))
  136.         end
  137.     end
  138.     return f and str:gsub('.',f) or str
  139. end
  140.  
  141. string.split=function(str,id,split)
  142.     local list={}
  143.     for val in string.gmatch(str,(id==0 and '[^'..(split or '%s')..']+' or id==1 and split)) do
  144.         table.insert(list,val)
  145.     end
  146.     return list
  147. end
  148.  
  149. string.equal=function(str1,str2)
  150.     local equal2=function(str1,str2)
  151.         local len = #str1
  152.         local dif = 0
  153.         local i = 0
  154.         while i < len do
  155.             i = i + .5
  156.             if str1:sub(i,i) ~= str2:sub(i,i) then
  157.                 dif = dif + 1
  158.             end
  159.         end
  160.         return 1 - dif/len
  161.     end
  162.     if #str1 ~= #str2 then
  163.         local dif = #str1-#str2
  164.         local len = math.max(#str1,#str2)
  165.         local big,small,auxi
  166.         if len == #str1 then
  167.             big = str1
  168.             small = str2
  169.         else
  170.             big = str2
  171.             small = str1
  172.         end
  173.         local fSim,mSimi = 1.4E-45,1.4E-45
  174.         local i = 0
  175.         while i <= #small do
  176.             i = i + 1
  177.             auxi = small:sub(0,i) .. big:sub(0,i+dif) .. small:sub(i)
  178.             fSim = equal2(big,auxi)
  179.             if fSim > mSimi then
  180.                 mSimi = fSim
  181.             end
  182.         end
  183.         return math.abs(mSimi - dif/len)
  184.     else
  185.         return math.abs(equal2(str1,str2))
  186.     end
  187. end
  188.  
  189. local ask,answer
  190. message = ""
  191. generateRandomQuestion=function(dif,cat)
  192.     dif,cat = dif or 0, cat or 0
  193.     local lvl = {"easy","medium","hard"}
  194.     local tp = {"news","sci","hist","entert","pt","quiz","geo"}
  195.     if dif > 0 then
  196.         dif = lvl[dif]
  197.     else
  198.         dif = lvl[math.random(#lvl)]
  199.     end
  200.     if cat > 0 then
  201.         cat = tp[cat]
  202.     else
  203.         cat = tp[math.random(#tp)]
  204.     end
  205.     local choice = asks[dif][cat][math.random(#asks[dif][cat])]
  206.     ask = choice[1]
  207.     answer = choice[2]
  208. end
  209.  
  210. ui.chat = function(name,message,title,x,y,w,h)
  211.     _G.message = message or ""
  212.     x,y,w,h = x or 300-150/2,y or 80,w or 350,h or 200
  213.     title = title or "Chat"
  214.     name = name or nil
  215.     ui.addPopup(0,2,"",name,x-1,y+200,w+1,true)
  216.     ui.addTextArea(0,"",n,x,y,w,h,0x324650,0x212E35,1,true)
  217.     ui.addTextArea(1,message,n,x+4,y+5,w-9,h-10,1,1,0,true)
  218.     ui.addTextArea(2,"<font face='Lucida Console'><p align='center'><V>"..title,n,x-1,y-15,w+1,h-185,0x212E35,0x212E35,1,true)
  219. end
  220.  
  221. mice={}
  222. eventNewPlayer=function(n)
  223.     if not mice[n] then mice[n]={skip=false} end
  224.     ui.chat(n,message,"Quiz")
  225. end
  226. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  227.  
  228. newQuestion,canAnswer,skip = true,false,0
  229. eventPopupAnswer=function(i,n,a)
  230.     if i == 0 then
  231.         a = a:gsub("http",''):gsub("<","&lt;"):gsub("://",":\\\\")
  232.         if a ~= "" and a:sub(1,1)~="/" then
  233.             if canAnswer then
  234.                 local done,almost = false,nil
  235.                 for k,v in next,answer do
  236.                     if done then break end
  237.                     if deactivateAccents(a,string.lower) == deactivateAccents(v,string.lower) then
  238.                         done = true
  239.                     end
  240.                     if #a>4 and string.equal(deactivateAccents(a,string.lower),deactivateAccents(v,string.lower)) then
  241.                         almost = true
  242.                     end
  243.                 end
  244.                 if done then
  245.                     ui.chat(n,"<V>["..n.."] <VP>"..a.."\n"..message,"Quiz")
  246.                     ui.chat(n,"<ROSE>[Chat] <PT>"..n.." +1\n"..message,"Quiz")
  247.                     tfm.exec.setPlayerScore(n,1,true)
  248.                     newQuestion = true
  249.                     canAnswer = false
  250.                 else
  251.                     ui.chat(n,"<V>["..n.."] <R>"..a.."\n"..message,"Quiz")
  252.                     if almost then
  253.                         ui.chat(n,"<ROSE>[Chat] <PT>Você está quase lá, <J>"..n.."\n"..message,"Quiz")
  254.                     end
  255.                 end
  256.             end
  257.         else
  258.             if a == "/skip" and not mice[n].skip then
  259.                 mice[n].skip = true
  260.                 skip = skip + 1
  261.                 local players = 0
  262.                 for k in next,tfm.get.room.playerList do players = players + 1 end
  263.                 if skip >= math.percent(50,players,1) then
  264.                     ui.chat(n,"<ROSE>[Chat] ** Skip ** <PT> - As respostas possíveis eram: \""..table.concat(answer,', ').."\"\n"..message,"Quiz")
  265.                     newQuestion = true
  266.                     canAnswer = false
  267.                 end
  268.             else
  269.                 ui.chat(n,message,"Quiz")
  270.             end
  271.         end
  272.         if #message > 1990 then
  273.             ui.chat(n,"<ROSE>[Chat] <V>#2000 <J>Clear","Quiz")
  274.             newQuestion = true
  275.             canAnswer = false
  276.         end
  277.     end
  278. end
  279.  
  280. eventLoop=function()
  281.     if newQuestion then
  282.         generateRandomQuestion(0,0)
  283.         ui.chat(nil,"<ROSE>[Chat] <PT><B>"..ask.."</B>\n"..message,"Quiz")
  284.         newQuestion = false
  285.         canAnswer = true
  286.         skip = 0
  287.         for n in next,tfm.get.room.playerList do mice[n].skip = false end
  288.     end
  289. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement