Administrators chain Posted December 21, 2022 Administrators Report Share Posted December 21, 2022 Trivia game this is the first script I'm posting I couldn't find a good trivia script so I made my own it's pretty basic but I hope everyone enjoys it! Note: if you don't use either !addquestion and !addanswer or the menu option to add the trivia questions it won't work proper. Edit: added top10 scores, fixed timer issue on $*:text:/^[@!.](trivia)?triviatop10$/Si:#:{ var %x, %i = $hget(triviascores,0).item, %o while (%i) { %x = $instok(%x,$hget(triviascores,$hget(triviascores,%i).item),0,32) dec %i } %x = $sorttok(%x,32,nr) %i = 1 while (%i <= 10) { if (!$hget(triviascores,%i).item) break %o = $addtok(%o,$ord(%i) $+ : $hfind(triviascores,$gettok(%x,%i,32),$calc($findtok(%o,$gettok(%x,%i,32),0,32) +1)).data - $bytes($gettok(%x,%i,32),b) |,32) inc %i } $iif($left($1,1) == @,msg #,msg $chan triviastop10) $left(%o,-1) } on *:text:!triviahelp:#: { notice $nick to start a trivia game use !trivia notice $nick to add a question to the trivia list use !addquestion (use !addanswer to add a answer to the question) notice $nick use !answer to answer the question notice $nick you can see who has the most trivia points by using !triviatop10 } on *:text:!trivia:#: { if (%trivia != $null) { notice $nick there is already a game in progress on %triviachan | msg $chan the question was $read(questions.txt, n, %trivia) you have %answering tries left | halt } else { set %trivia $rand(1,%questionnum)) set %trivianick $nick set %triviachan $chan msg $chan $read(questions.txt, n, %trivia) .timertrivia 1 30 msg $chan 30 seconds left to guess the answer .timerending 1 60 msg $chan Trivia time up! the answer was $read(answers.txt, n, %trivia) .timerunset 1 60 unset %trivia .timerunset1 1 60 unset %answering set %answering 5 } } menu channel { Trivia .Add trivia:write questions.txt $$?="Enter question:" | inc %questionnum 1 | write answers.txt $$?="Enter answer:" | inc %answernum 1 } on *:text:!Addquestion*:#: { var %addquestion = $read(questions.txt, w, $$2-) if (( %addquestion != $null )) { msg $chan $nick That question is already in the list | halt } elseif (%questionnum !isnum) { set %questionnum 0 } elseif (%questionnum != %answernum) { msg $chan $nick you first need to give a answer to the question $read(questions.txt, n, %questionnum) use 4,2!addanswer to add a answer to it | halt } write questions.txt $2 $3- inc %questionnum 1 msg $chan 7,1you have added $2 $3- to trivia questions. msg $chan 4,2use !addanswer to add the answer to the trivia question } on *:text:!addanswer*:#: { var %addanswer = $read(answers.txt, w, $$2-) if (( %addanswer != $null )) { msg $chan $nick That answer is already in the list | halt } elseif (%answernum !isnum) { set %answernum 0 } write answers.txt $2 $3- inc %answernum 1 msg $chan 7,1you have added $2 $3- to trivia answer. msg $chan 4,2it will be the answer to $read(questions.txt, n, %questionnum) } on *:text:!triviapoints:#: { msg $chan You have $hget(triviascores,$nick) points $nick $+ ! msg $chan You have guessed wrong 2,4 $hget(triviamistakes,$nick) times } on *:text:!triviapoints*:#: { msg $chan $2 has 2,4 $hget(triviascores,$2) points $nick $+ ! msg $chan $2 has guessed wrong 2,4 $hget(triviascores,$2) times } on *:text:!endtrivia:%triviachan: { if (%trivianick != $nick) { notice $nick only %trivianick can end trivia game | halt } elseif (%trivianick == $nick) { msg $chan Trivia has been ended by $nick the answer was $read(answers.txt, n, %trivia) unset %trivia unset %answering timertrivia off timerunset1 off timerending off timerunset off } } on *:text:!answer*:#: { if (%trivia == $null) { notice $nick you need to start the game with !trivia first | halt } elseif ($2- == $read(answers.txt, n, %trivia)) { msg $chan you got the answer right $nick $+ ! | timertrivia off | timerunset1 off | timerending off | timerunset off | hinc triviascores $nick | unset %trivia | unset %answering | msg $chan $nick now has $hget(triviascores,$nick) points! | halt } if (%answering == 0) { msg $chan you're out of tries! the answer was 1,2 $read(answers.txt, n, %trivia) | unset %trivia | unset %answering | halt } else { hinc triviamistakes $nick //dec %answering 1 msg $chan 7,4wrong answer $nick $+ ! } } on *:text:!tries:#: { msg $chan There is %answering attempts left $+ ! } Quote Link to comment Share on other sites More sharing options...