Advertisement
Bolodefchoco_LUAXML

[Script/Funcorp] Quiz / Images

Apr 19th, 2019
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.22 KB | None | 0 0
  1. local questions = {
  2.     -- Question
  3.     -- Option1
  4.     -- Option2
  5.     -- Answer (1 / 2)
  6.     {
  7.         "lalala",
  8.         { "16596fac6cc.png", -40, 0 },
  9.         { "16596f88c25.png", 0, -100 },
  10.         1
  11.     },
  12.     {
  13.         { "lululu", "1659779901e.png", -200, 0 },
  14.         { "16596fac6cc.png", 10, -10 },
  15.         { "16596f88c25.png", 20, -40 },
  16.         2
  17.     },
  18.     {
  19.         "ojksadjiopdfjiop",
  20.         "iojsadjiasdjiosa",
  21.         { "16596f88c25.png", 20, 30 },
  22.         2
  23.     }
  24. }
  25.  
  26. local gameTimer, newGameTimer, respawn = -1, -1, false
  27.  
  28. local toDel = { }
  29.  
  30. local question
  31. local displayQuestion = function()
  32.     for i = 3, 4 do
  33.         ui.removeTextArea(i)
  34.     end
  35.  
  36.     for player, data in next, tfm.get.room.playerList do
  37.         tfm.exec.movePlayer(player, 400, 320)
  38.     end
  39.  
  40.     question = questions[math.random(#questions)]
  41.  
  42.     for i = 1, #toDel do
  43.         tfm.exec.removeImage(toDel[i])
  44.     end
  45.     toDel = { }
  46.  
  47.     local quest = question[1]
  48.     if type(quest) == "table" then
  49.         quest = question[1][1]
  50.         local x, y = 400 + question[1][3], 200 + question[1][4]
  51.         toDel[#toDel + 1] = tfm.exec.addImage(question[1][2], "&0", x, y)
  52.     end
  53.     ui.addTextArea(0, "<p align='center'><font size='20'><CEP>" .. quest, nil, 5, 25, 790, nil, 1, 1, 1, true)
  54.    
  55.     for i = 0, 1 do
  56.         if type(question[i + 2]) == "table" then
  57.             toDel[#toDel + 1] = tfm.exec.addImage(question[i + 2][1], "&0", 215 + (i * 420) + question[i + 2][2], 120 + question[i + 2][3])
  58.             ui.removeTextArea(i + 1)
  59.         else
  60.             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)
  61.         end
  62.     end
  63.  
  64.     gameTimer = 10.5
  65. end
  66.  
  67. local displayAnswer = function()
  68.     local add = 0
  69.  
  70.     for i = 1, 2 do
  71.         if question[4] == i then
  72.             local x = 5 + ((i - 1) * 420)
  73.  
  74.             if type(question[i + 1]) == "string" then
  75.                 ui.updateTextArea(i, "<p align='center'><font size='20'><VP>" .. question[i + 1])
  76.             end
  77.  
  78.             local counter, alivePlayer = 0
  79.             for player, data in next, tfm.get.room.playerList do
  80.                 if not data.isDead then
  81.                     if data.x > (x + 370) or data.x < x then
  82.                         tfm.exec.killPlayer(player)
  83.                     else
  84.                         counter = counter + 1
  85.                         alivePlayer = player
  86.                     end
  87.                 end
  88.             end
  89.  
  90.             if counter == 0 then
  91.                 tfm.exec.chatMessage("<J>No winners.")
  92.             elseif counter == 1 then
  93.                 tfm.exec.setPlayerScore(alivePlayer, 5, true)
  94.                 tfm.exec.chatMessage("<G>" .. alivePlayer .. " <J>wins.")
  95.             end
  96.  
  97.             if counter < 2 then
  98.                 add = 3
  99.                 respawn = true
  100.             end
  101.         end
  102.     end
  103.  
  104.     newGameTimer = 4.5 + add
  105. end
  106.  
  107. eventNewGame = function()
  108.     newGameTimer = 4.5
  109. end
  110.  
  111. eventLoop = function()
  112.     if respawn then
  113.         for player, data in next, tfm.get.room.playerList do
  114.             if data.isDead then
  115.                 tfm.exec.respawnPlayer(player)
  116.             end
  117.             tfm.exec.movePlayer(player, 400, 320)
  118.         end
  119.     end
  120.  
  121.     if newGameTimer >= 0 then
  122.         newGameTimer = newGameTimer - .5
  123.         if newGameTimer == 0 then
  124.             respawn = false
  125.             displayQuestion(true)
  126.         else
  127.             ui.setMapName("Quiz   <G>|   <N>New game in : <V>" .. math.max(0, math.floor(newGameTimer)) .. "<")
  128.         end
  129.     elseif gameTimer >= 0 then
  130.         gameTimer = gameTimer - .5
  131.         if gameTimer == 0 then
  132.             ui.setMapName("Quiz<")
  133.             displayAnswer()
  134.         else
  135.             ui.setMapName("Quiz   <G>|   <N>Time left to choose a side : <V>" .. math.max(0, math.floor(gameTimer)) .. "<")
  136.         end
  137.     end
  138. end
  139.  
  140. eventNewPlayer = function(player)
  141.     tfm.exec.lowerSyncDelay(player)
  142. end
  143. table.foreach(tfm.get.room.playerList, eventNewPlayer)
  144.  
  145. tfm.exec.disableAutoNewGame()
  146. tfm.exec.disableAutoShaman()
  147. tfm.exec.disableAutoScore()
  148. tfm.exec.disablePhysicalConsumables()
  149.  
  150. for player, data in next, tfm.get.room.playerList do
  151.     tfm.exec.setPlayerScore(player, 0)
  152. end
  153.  
  154. 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