Advertisement
Bolodefchoco_LUAXML

[Game] Quiz Faster

Apr 3rd, 2016
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 03/04/2016
  3. --Last update: 26/05/2016
  4. --[[ Notes:
  5.     Does:
  6.         Vence aquele que responder todas as perguntas corretamente mais rápido
  7.     Adding questions:
  8.         Na tabela P:
  9.             [Número da questão] = {"Pergunta","Resposta"},
  10.                 { [Número da alternativa] = {"Letra da alternativa","Texto da Alternativa"},
  11.                 [Número da alternativa] = {"Letra da alternativa","Texto da Alternativa"},
  12.             };
  13. ]]--
  14.  
  15. P = {
  16.     [1] = {
  17.         {"Por que o Bolodefchoco cobra caro?","C"},
  18.             {   [1] = {"A","Por motivos pessoais"},
  19.                 [2] = {"B","Por que quer"},
  20.                 [3] = {"C","Por que você depende dele"},
  21.             }
  22.     };
  23.     [2] = {
  24.         {"Satã é viado?","A"},
  25.             {   [1] = {"A","Nunca"},
  26.                 [2] = {"B","Sim"},
  27.             }
  28.     };
  29. }
  30. mice={}
  31. eventNewPlayer=function(n)
  32.     mice[n]={points = 0}
  33.     tfm.exec.setPlayerScore(n,mice[n].points)
  34. end
  35. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  36. done = false
  37. displayQuestion=function(n)
  38.     for id = #P,1,-1 do
  39.         local answ = ""
  40.         for i,v in next,P[id][2] do
  41.             answ = answ .. tostring(P[id][2][i][1])..") <a href='event:"..tostring(P[id][2][i][1]).."'>"..P[id][2][i][2].."</a>\n"
  42.         end
  43.         ui.addTextArea(id,P[id][1][1]..'\n\n'..answ,n,200,50,400,300)
  44.     end
  45. end
  46. table.foreach(tfm.get.room.playerList,function(n) displayQuestion(n) end)
  47. eventTextAreaCallback=function(i,n,c)
  48.     if not done then
  49.         if P[i][1][2] == c then
  50.             mice[n].points = mice[n].points + 1
  51.             tfm.exec.setPlayerScore(n,mice[n].points)
  52.         end
  53.         ui.removeTextArea(i,n)
  54.         if i == #P then
  55.             if mice[n].points < #P then
  56.                 mice[n].points = 0
  57.                 tfm.exec.setPlayerScore(n,mice[n].points)
  58.                 displayQuestion(n)
  59.             else
  60.                 ui.addTextArea(100*100,"\n\n\n<font size='50'><R>"..n.." <V>venceu!",nil,5,25,795,400)
  61.                 done = false
  62.             end
  63.         end
  64.     end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement