Slowmice

Quiz game [LUA] [RU]

Sep 29th, 2013
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.32 KB | None | 0 0
  1. tfm.exec.newGame("@3699797")
  2. tfm.exec.setGameTime(600, true)
  3. debug.disableEventLog(true)
  4.  
  5. adminNames = {"Finalnova","Shamousey"}
  6.  
  7. GreenTeam = { }
  8. YellowTeam = { }
  9. RedTeam = { }
  10. BlueTeam = { }
  11. TeamDelay = os.time()
  12. TeamRound = os.time()
  13. RoundTime = 15000
  14. TeamRs = false
  15. TeamSc = 0
  16.  
  17. --[[Question list]]--
  18. --[Вопрос, ответ]--
  19. Q = { }
  20. Q[0] = { "What colour is the sky?","Blue" }
  21. Q[1] = {"Who draws the art for Transformice?","Melibellule"}
  22. Q[2] = {"What is the chemical compound for regular water?","H20"}
  23. Q[3] = {"What year did Transformice open?","2010"}
  24. Q[4] = {"What was the predecessor game to Transformice called?","Poisson"}
  25. Q[5] = {"What\'s the name of the company that owns Transformice?","Atelier 801"}
  26. Q[6] = {"How many nipples do most people have?","2"}
  27. Q[6] = {"What\'s the name of the main developer for Transformice?","Tigrounette"}
  28. Q[7] = {"What\'s the name of Google\'s browser?","Chrome"}
  29. Q[8] = {"What physics engine is Transformice based on?","Box2D"}
  30. QMax = 8
  31. QCurrent = math.random(0,QMax)
  32.  
  33. --[[Question list end]]--
  34.  
  35. function eventNewGame()
  36.     GreenTeam = { }
  37.     YellowTeam = { }
  38.     RedTeam = { }
  39.     BlueTeam = { }
  40.     TeamDelay = os.time()
  41.     TeamRound = os.time()
  42.     RoundTime = 15000        
  43.     TeamRs = false
  44.     TeamSc = math.random(1,4)
  45.     tfm.exec.chatMessage("<ROSE><B>A new round has started!</B>")
  46. end  
  47.  
  48. function eventLoop(time)
  49.    
  50.     --[[ Team placer ]]--
  51.    
  52.     if (TeamDelay + 5000 < os.time()) then
  53.         for playerName,player in pairs(tfm.get.room.playerList) do
  54.                 if (player.x > 0 and player.x < 165) then
  55.                         tfm.exec.chatMessage("<T><b>You're on the green team.</b>",playerName)
  56.                         table.insert(GreenTeam,1,playerName)
  57.                 elseif (player.x > 165 and player.x < 365) then
  58.                         tfm.exec.chatMessage("<J><b>You're on the yellow team.</b>",playerName)
  59.                         table.insert(YellowTeam,1,playerName)
  60.                 elseif (player.x > 365 and player.x < 565) then
  61.                         tfm.exec.chatMessage("<R><b>You're on the red team.</b>",playerName)
  62.                         table.insert(RedTeam,1,playerName)
  63.                 elseif (player.x > 565 and player.x < 800) then
  64.                         tfm.exec.chatMessage("<BV><b>You're on the blue team.</b>",playerName)
  65.                         table.insert(BlueTeam,1,playerName)
  66.                 end
  67.         end
  68.         TeamDelay = os.time() + 600000
  69.        
  70.         TeamRs = true
  71.     end
  72.    
  73.     --[[ What happens each round ]]--
  74.    
  75.     if TeamRs == true then
  76.         if TeamSc == 1 then
  77.             for index,playerName in pairs(GreenTeam) do
  78.                 tfm.exec.chatMessage("<T>It is your turn to answer a question.", playerName)
  79.                 tfm.exec.chatMessage("<ROSE><b>" ..Q[QCurrent][1].. "</b>", playerName)
  80.             end
  81.         elseif TeamSc == 2 then
  82.             for index,playerName in pairs(YellowTeam) do
  83.                 tfm.exec.chatMessage("<J>It is your turn to answer a question.", playerName)
  84.                 tfm.exec.chatMessage("<ROSE><b>" ..Q[QCurrent][1].. "</b>", playerName)
  85.             end
  86.         elseif TeamSc == 3 then
  87.             for index,playerName in pairs(RedTeam) do
  88.                 tfm.exec.chatMessage("<R>It is your turn to answer a question.", playerName)
  89.                 tfm.exec.chatMessage("<ROSE><b>" ..Q[QCurrent][1].. "</b>", playerName)
  90.             end
  91.         elseif TeamSc == 4 then
  92.             for index,playerName in pairs(BlueTeam) do
  93.                 tfm.exec.chatMessage("<BV>It is your turn to answer a question.", playerName)
  94.                 tfm.exec.chatMessage("<ROSE><b>" ..Q[QCurrent][1].. "</b>", playerName)
  95.             end
  96.         end
  97.         TeamRs = false
  98.         TeamSc = TeamSc + 1
  99.         if (TeamSc == 5) then
  100.             TeamSc = 1
  101.         end
  102.    
  103.     --[[ The time each round ]]--
  104.    
  105.         elseif (TeamRound + RoundTime < os.time()) then
  106.         TeamRs = true
  107.         TeamRound = os.time()
  108.     end
  109. end
  110.  
  111.  
  112. function eventChat(name , command)
  113.     command=command:lower()
  114.     if command == 'help' then
  115.         tfm.exec.chatMessage([[<J>Welcome to Team Quiz, this is a game where you have to answer questions with your team.]], name)
  116.     end
  117.    
  118.     for index,playerName in pairs(adminNames) do
  119.         if (command == 'newgame' and playerName == name) then
  120.             tfm.exec.newGame('@3699797')
  121.             tfm.exec.setGameTime(600, true)
  122.         end
  123.         if command == 'tgreen' then
  124.             tfm.exec.movePlayer(playerName,91,330,0,0,0,0)
  125.         end
  126.         if command == 'tyellow' then
  127.             tfm.exec.movePlayer(playerName,291,330,0,0,0,0)
  128.         end
  129.         if command == 'tred' then
  130.             tfm.exec.movePlayer(playerName,491,330,0,0,0,0)
  131.         end
  132.         if command == 'tblue' then
  133.             tfm.exec.movePlayer(playerName,691,330,0,0,0,0)
  134.         end
  135.  
  136.     end
  137.    
  138.     if command == 'test' then
  139.         for index,playerName in pairs(BlueTeam) do
  140.                 tfm.exec.chatMessage("It is your turn to answer a question.", playerName)
  141.         end
  142.     end
  143.    
  144. end
  145.  
  146. function eventNewPlayer(name)
  147.     tfm.exec.chatMessage("<J><b>Welcome to Team Quiz, type</b> <ROSE><b>!help</b> <J><b>into the chat if you're stuck. This is not complete yet, so if it seems like features are missing, they probably are.</b>", name)
  148. end
Advertisement
Add Comment
Please, Sign In to add comment