Advertisement
Bolodefchoco_LUAXML

[Script] Quiz

Sep 18th, 2018
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.35 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.     local i = question[4]
  46.     local x = 5 + ((i - 1) * 420)
  47.  
  48.     ui.updateTextArea(i, "<p align='center'><font size='20'><VP>" .. question[i + 1])
  49.  
  50.     local counter, alivePlayer = 0
  51.     for player, data in next, tfm.get.room.playerList do
  52.         if not data.isDead then
  53.             if data.x > (x + 370) or data.x < x then
  54.                 tfm.exec.killPlayer(player)
  55.             else
  56.                 counter = counter + 1
  57.                 alivePlayer = player
  58.             end
  59.         end
  60.     end
  61.  
  62.     if counter == 0 then
  63.         tfm.exec.chatMessage("<J>No winners.")
  64.     elseif counter == 1 then
  65.         tfm.exec.setPlayerScore(alivePlayer, 5, true)
  66.         tfm.exec.chatMessage("<G>" .. alivePlayer .. " <J>wins.")
  67.     end
  68.  
  69.     if counter < 2 then
  70.         add = 3
  71.         respawn = true
  72.     end
  73.  
  74.     newGameTimer = 4.5 + add
  75. end
  76.  
  77. eventNewGame = function()
  78.     newGameTimer = 4.5
  79. end
  80.  
  81. eventLoop = function()
  82.     if respawn then
  83.         for player, data in next, tfm.get.room.playerList do
  84.             if data.isDead then
  85.                 tfm.exec.respawnPlayer(player)
  86.             end
  87.             tfm.exec.movePlayer(player, 400, 320)
  88.         end
  89.     end
  90.  
  91.     if newGameTimer >= 0 then
  92.         newGameTimer = newGameTimer - .5
  93.         if newGameTimer == 0 then
  94.             respawn = false
  95.             displayQuestion(true)
  96.         else
  97.             ui.setMapName("Quiz   <G>|   <N>New game in : <V>" .. math.max(0, math.floor(newGameTimer)) .. "<")
  98.         end
  99.     elseif gameTimer >= 0 then
  100.         gameTimer = gameTimer - .5
  101.         if gameTimer == 0 then
  102.             ui.setMapName("Quiz<")
  103.             displayAnswer()
  104.         else
  105.             ui.setMapName("Quiz   <G>|   <N>Time left to choose a side : <V>" .. math.max(0, math.floor(gameTimer)) .. "<")
  106.         end
  107.     end
  108. end
  109.  
  110. eventNewPlayer = function(player)
  111.     tfm.exec.lowerSyncDelay(player)
  112. end
  113. table.foreach(tfm.get.room.playerList, eventNewPlayer)
  114.  
  115. tfm.exec.disableAutoNewGame()
  116. tfm.exec.disableAutoShaman()
  117. tfm.exec.disableAutoScore()
  118.  
  119. for player, data in next, tfm.get.room.playerList do
  120.     tfm.exec.setPlayerScore(player, 0)
  121. end
  122.  
  123. 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