Advertisement
taZe

trivia

Oct 25th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.20 KB | None | 0 0
  1. local randomQuestions = {
  2. { // Questions about the Jail Break gamemode
  3. {question="Name the three primary colours.",answer="Red, Yellow and Blue"},
  4. {question="What is the oldest surviving printed book in the world?",answer="The Diamond Sutra"},
  5. {question="What colour is Absynthe?",answer="Green"},
  6. {question="Who created the first version of Jail Break for Garry's Mod?",answer="excl"},
  7. {question="What does LR stand for?",answer="last request"},
  8. {question="Who is the person in charge of the prison?",answer="warden"},
  9. {question="In video gaming, what is the name of the princess whom Mario repeatedly stops Bowser from kidnapping?",answer="Princess Peach"},
  10. {question="In the game ‘Mortal Kombat’, what phrase is heard when Scorpion uses his spear?",answer="Get over here"},
  11. {question="How many rows of aliens are there usually at the start of a ‘Space Invaders’ game?",answer="5"},
  12. {question="What is the name of the fictional English archaeologist in the game ‘Tomb Raider’?",answer="Lara Croft"},
  13. {question="Which 1986 Nintendo game is set in the fantasy land of Hyrule, and centers on a boy named Link?",answer="Zelda"},
  14. {question="In video games, what colour is Pac-Man?",answer="yellow"},
  15. {question="‘Black Ops’ is the subtitle of which game?",answer="Call of Duty"},
  16. {question="Pikachu is one of the species of creatures in which series of games?",answer="Pokemon"},
  17. {question="Jumpman’s goal is to save the Lady from the giant ape in which 1981 arcade game?",answer="Donkey Kong"},
  18. {question="The Covenant are fictional military alien races in which game series?",answer="Halo"},
  19. {question="What color is the most autistic video game hedgehog?",answer="blue"},
  20. {question="When was IrishMayhem founded?",answer="2016"},
  21. {question="What is the name of the first gen Pokemon starter class that uses the element of fire?",answer="Charmander"},
  22. {question="Damn, Daniel's back at it again with the _____! Fill in the blank.",answer="white vans"},
  23. {question="How many states are there in the USA?",answer="50"},
  24. {question="How many bones does an adult human have?",answer="206"},
  25. {question="Who is the meth addict in GTA Vs protaganists?",answer="Trevor"},
  26. },
  27. { // Questions about human subjects, such as history and geography
  28. {question="Name the world's biggest island",answer="Greenland"},
  29. {question="What is the diameter of Earth?",answer="8000 miles"},
  30. {question="Which country is Prague in?",answer="Czech Republic"},
  31. {question="What country is to the east of poland?",answer="Ukraine"},
  32. {question="What is the capital of Spain?",answer="Madrid"},
  33. {question="Name a game in which two teams kick a ball around.",answer="football"},
  34. {question="When was Elvis' first ever concert?",answer="1954"},
  35. {question="In which city is Hollywood?",answer="Los Angeles"},
  36. {question="Who was the director of the film 'Psycho'?",answer="Hitchcock"},
  37. {question="What's the smallest country in the world?",answer="Vatican City"},
  38. {question="What's the capital of Finland?",answer="Helsinki"},
  39. {question="How many legs has a spider got?",answer="8"},
  40. },
  41. "mathproblem"
  42. };
  43.  
  44. local question,answer;
  45.  
  46. _RTN_RUNSTRING_JB_LR_TRIVIA_QUESTION = 0;
  47.  
  48. local winner_found = false;
  49. local LR = JB.CLASS_LR();
  50. LR:SetName("Trivia");
  51. LR:SetDescription("After the countdown, a random question about a random subject will be asked. The first person to answer this question correctly in chat will win the last request, the loser will be killed.");
  52. LR:SetStartCallback(function(prisoner,guard)
  53. local subject = randomQuestions[math.random(1,#randomQuestions)];
  54.  
  55. if type("subject") == "string" and subject == "mathproblem" then
  56. local operationsFirst = {" + "," - "};
  57. local operationsSecond = {" * "};
  58.  
  59. question=tostring(math.random(1,10));
  60.  
  61. local typ = math.random(1,4);
  62. if typ == 1 or typ == 2 then
  63. question=question..table.Random(operationsFirst)..tostring(math.random(1,10));
  64. end
  65.  
  66. local div = 0;
  67.  
  68. if typ == 2 or typ == 3 or typ == 4 then
  69. div = math.random(1,10);
  70. question=question..table.Random(operationsSecond)..(typ == 4 and "( " or "")..tostring(div);
  71. end
  72.  
  73. if typ == 3 then
  74. question=question..table.Random(operationsSecond)..tostring(math.random(1,10))
  75. elseif typ == 4 then
  76. local sec = math.random(-10,10);
  77. if div-sec == 0 then
  78. sec = sec+math.random(1,5);
  79. end
  80. question=question..table.Random(operationsFirst)..sec.." )";
  81. end
  82.  
  83. RunString("_RTN_RUNSTRING_JB_LR_TRIVIA_QUESTION = "..question..";");
  84. answer = _RTN_RUNSTRING_JB_LR_TRIVIA_QUESTION;
  85. question=question.." = "
  86.  
  87. elseif type(subject) == "table" then
  88. local rnd = table.Random(subject);
  89. question = rnd.question; // TODO: add more questions
  90. answer = rnd.answer;
  91. end
  92.  
  93. winner_found = false;
  94.  
  95. net.Start("JB.LR.Trivia.SendQuestion");
  96. net.WriteString(question);
  97. net.Broadcast();
  98. end)
  99.  
  100. LR:SetSetupCallback(function(prisoner,guard)
  101. net.Start("JB.LR.Trivia.SendPrepare");
  102. net.WriteEntity(prisoner);
  103. net.WriteEntity(guard);
  104. net.Broadcast();
  105.  
  106. return false; // don't halt setup
  107. end)
  108.  
  109. LR:SetIcon(Material("icon16/rosette.png"))
  110.  
  111. local id = LR();
  112.  
  113. if SERVER then
  114. util.AddNetworkString("JB.LR.Trivia.SendQuestion");
  115. util.AddNetworkString("JB.LR.Trivia.SendPrepare");
  116. util.AddNetworkString("JB.LR.Trivia.SendWinner");
  117.  
  118. hook.Add( "PlayerSay", "JB.PlayerSay.LR.Trivia", function( ply, text, team )
  119. if JB.LastRequest == id and table.HasValue(JB.LastRequestPlayers,ply) and string.find(string.lower(text),string.lower(answer)) and not winner_found then
  120. timer.Simple(0,function()
  121. net.Start("JB.LR.Trivia.SendWinner");
  122. net.WriteEntity(ply);
  123. net.Broadcast();
  124. end);
  125.  
  126. for k,v in ipairs(JB.LastRequestPlayers)do
  127. if IsValid(v) and v ~= ply then
  128. v:Kill();
  129. end
  130. end
  131. winner_found = true;
  132. end
  133. end )
  134. elseif CLIENT then
  135. hook.Add("PlayerBindPress", "JB.PlayerBindPress.LR.TriviaNoSayBindsFuckYou", function(pl, bind, pressed) // Not the safest way, but it requires the least amount of touching code outside of this file (without using nasty hacky methods)
  136. if JB.LastRequest == id and table.HasValue(JB.LastRequestPlayers,pl) and string.find( bind,"say" ) then
  137. return true;
  138. end
  139. end)
  140.  
  141. net.Receive("JB.LR.Trivia.SendPrepare",function()
  142. local guard,prisoner = net.ReadEntity(),net.ReadEntity();
  143.  
  144. if not JB.Util.isValid(guard,prisoner) then return end
  145.  
  146. chat.AddText( JB.Color["#bbb"], "Quizmaster", JB.Color.white, ": Hello ", guard, JB.Color.white, " and ", prisoner, JB.Color.white, ", prepare to give your answer via chat." );
  147. timer.Simple(2,function()
  148. chat.AddText( JB.Color["#bbb"], "Quizmaster", JB.Color.white, ": The first person to answer correctly will win this game of Trivia." );
  149. end);
  150. end);
  151. net.Receive("JB.LR.Trivia.SendQuestion",function()
  152. local question = net.ReadString() or "ERROR";
  153. chat.AddText( JB.Color["#bbb"], "Quizmaster", JB.Color.white, ": "..question );
  154. end);
  155. net.Receive("JB.LR.Trivia.SendWinner",function()
  156. local winner = net.ReadEntity();
  157.  
  158. if not IsValid(winner) then return end
  159.  
  160. chat.AddText( JB.Color["#bbb"], "Quizmaster", JB.Color.white, ": That is correct! ", winner, JB.Color.white, " wins." );
  161. end);
  162. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement