Advertisement
sparkychild

Untitled

Jun 18th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. trivia: function(arg, by, room){
  2. if(room.charAt(',') === 0)return false;
  3. if(!this.hasRank(by, '@#~')) return false;
  4. if(triviaON){this.say( room, 'A trivia game cannot be started, as it is going on in another room.'); return false;}
  5. triviaON = true;
  6. triviaRoom = room;
  7. triviaPoints = [];
  8. triviaA = '';
  9. this.say( room, 'Hosting a game of trivia\. First to 10 points wins! use \+ta or \+triviaanswer to submit your answer\.');
  10. triviaTimer = setInterval( function() {
  11. if(triviaA){this.say(room, 'The correct answer is: ' + triviaA);}
  12. var TQN = 2*(Math.floor(triviaQuestions.length*Math.random()/2))
  13. triviaQ = triviaQuestions[TQN];
  14. triviaA = triviaQuestions[TQN+ 1];
  15. this.say( room, 'Question: __' + triviaQ + '__');
  16. }.bind(this), 17000);
  17.  
  18. },
  19. ta: 'triviaanswer',
  20. triviaanswer: function(arg, by, room){
  21. if(room !== triviaRoom) return false;
  22. arg = toId(arg);
  23. if (!arg) return false;
  24. var user = toId(by);
  25. // this.say(room, arg + ' answer: ' + triviaA);
  26. if(arg === triviaA){
  27. if (triviaPoints.indexOf(user) > -1){
  28. triviaA = '';
  29. triviaPoints[triviaPoints.indexOf(user) + 1] = triviaPoints[triviaPoints.indexOf(user) + 1] + 1;
  30. if (triviaPoints[triviaPoints.indexOf(user) + 1] >= 10) {
  31. clearInterval(triviaTimer);
  32. this.say( room, 'Congrats to ' + by + ' for winning!');
  33. triviaON = false;
  34. return false;
  35. }
  36. this.say(room, '' + by.slice(1, by.length) + ' got the right answer, and has ' + triviaPoints[triviaPoints.indexOf(user) + 1] + ' points!');
  37. } else {
  38. triviaA = '';
  39. triviaPoints[triviaPoints.length] = user;
  40. triviaPoints[triviaPoints.length] = 1;
  41. this.say(room, '' + by.slice(1, by.length) + ' got the right answer, and has ' + triviaPoints[triviaPoints.indexOf(user) + 1] + ' point!');
  42. }
  43. }
  44. },
  45. triviaend: function(arg, by, room){
  46. if(room !== triviaRoom)return false;
  47. if(!triviaON) return false;
  48. if(!this.hasRank(by, '@#~'))return false;
  49. clearInterval(triviaTimer);
  50. this.say(room, 'The game of trivia has been ended.');
  51. triviaON = false;
  52. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement