Advertisement
Bolodefchoco_LUAXML

[Script/Funcorp] Quiz

Apr 18th, 2019
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.43 KB | None | 0 0
  1. local questions = {
  2.     -- Question
  3.     -- Option1
  4.     -- Option2
  5.     -- Answer (1 / 2)
  6.     {
  7.         "What is the color of the Sky?",
  8.         "Blue",
  9.         "Pink",
  10.         1
  11.     },
  12.     {
  13.         "Are there trees in the Hell?",
  14.         "Yes",
  15.         "No",
  16.         2
  17.     },
  18. }
  19.  
  20. local gameTimer, newGameTimer, respawn = -1, -1, false
  21.  
  22. local question
  23. local displayQuestion = function()
  24.     for i = 3, 4 do
  25.         ui.removeTextArea(i)
  26.     end
  27.  
  28.     for player, data in next, tfm.get.room.playerList do
  29.         tfm.exec.movePlayer(player, 400, 320)
  30.     end
  31.  
  32.     question = questions[math.random(#questions)]
  33.  
  34.     ui.addTextArea(0, "<p align='center'><font size='20'><CEP>" .. question[1], nil, 5, 25, 790, nil, 1, 1, 1, true)
  35.     for i = 0, 1 do
  36.         ui.addTextArea(i + 1, "<p align='center'><font size='20' color='#FFFFFF'>" .. question[i + 2], nil, 5 + (i * 420), 120, 370, nil, 1, 1, 0, true)
  37.     end
  38.  
  39.     gameTimer = 10.5
  40. end
  41.  
  42. local displayAnswer = function()
  43.     local add = 0
  44.  
  45.     for i = 1, 2 do
  46.         if question[4] == i then
  47.             local x = 5 + ((i - 1) * 420)
  48.  
  49.             ui.updateTextArea(i, "<p align='center'><font size='20'><VP>" .. question[i + 1])
  50.  
  51.             local counter, alivePlayer = 0
  52.             for player, data in next, tfm.get.room.playerList do
  53.                 if not data.isDead then
  54.                     if data.x > (x + 370) or data.x < x then
  55.                         tfm.exec.killPlayer(player)
  56.                     else
  57.                         counter = counter + 1
  58.                         alivePlayer = player
  59.                     end
  60.                 end
  61.             end
  62.  
  63.             if counter == 0 then
  64.                 tfm.exec.chatMessage("<J>No winners.")
  65.             elseif counter == 1 then
  66.                 tfm.exec.setPlayerScore(alivePlayer, 5, true)
  67.                 tfm.exec.chatMessage("<G>" .. alivePlayer .. " <J>wins.")
  68.             end
  69.  
  70.             if counter < 2 then
  71.                 add = 3
  72.                 respawn = true
  73.             end
  74.         end
  75.     end
  76.  
  77.     newGameTimer = 4.5 + add
  78. end
  79.  
  80. eventNewGame = function()
  81.     newGameTimer = 4.5
  82. end
  83.  
  84. eventLoop = function()
  85.     if respawn then
  86.         for player, data in next, tfm.get.room.playerList do
  87.             if data.isDead then
  88.                 tfm.exec.respawnPlayer(player)
  89.             end
  90.             tfm.exec.movePlayer(player, 400, 320)
  91.         end
  92.     end
  93.  
  94.     if newGameTimer >= 0 then
  95.         newGameTimer = newGameTimer - .5
  96.         if newGameTimer == 0 then
  97.             respawn = false
  98.             displayQuestion(true)
  99.         else
  100.             ui.setMapName("Quiz   <G>|   <N>New game in : <V>" .. math.max(0, math.floor(newGameTimer)) .. "<")
  101.         end
  102.     elseif gameTimer >= 0 then
  103.         gameTimer = gameTimer - .5
  104.         if gameTimer == 0 then
  105.             ui.setMapName("Quiz<")
  106.             displayAnswer()
  107.         else
  108.             ui.setMapName("Quiz   <G>|   <N>Time left to choose a side : <V>" .. math.max(0, math.floor(gameTimer)) .. "<")
  109.         end
  110.     end
  111. end
  112.  
  113. eventNewPlayer = function(player)
  114.     tfm.exec.lowerSyncDelay(player)
  115. end
  116. table.foreach(tfm.get.room.playerList, eventNewPlayer)
  117.  
  118. tfm.exec.disableAutoNewGame()
  119. tfm.exec.disableAutoShaman()
  120. tfm.exec.disableAutoScore()
  121.  
  122. for player, data in next, tfm.get.room.playerList do
  123.     tfm.exec.setPlayerScore(player, 0)
  124. end
  125.  
  126. tfm.exec.newGame('<C><P /><Z><S><S L="40" H="100" X="400" Y="380" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="800" X="400" H="40" Y="400" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="40" X="400" H="100" Y="380" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="800" H="40" X="400" Y="406" T="0" P="0,0,0.3,0.2,180,0,0,0" /><S L="800" H="40" X="400" Y="413" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="40" H="310" X="400" Y="160" T="1" P="0,0,0,0.2,180,0,0,0" /><S L="40" X="400" H="310" Y="160" T="1" P="0,0,0,0.2,180,0,0,0" /><S L="10" X="0" H="380" Y="190" T="12" P="0,0,0,0,0,0,0,0" /><S L="10" H="380" X="800" Y="190" T="12" P="0,0,0,0,0,0,0,0" /></S><D><DS Y="320" X="400" /></D><O /></Z></C>')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement