Hi,

I couldnt resist it, so i went ahead and made u this offline trivia bot. As you will see it is the most basic thing, with a minimal of features lol. The trivia will appear in your Status Window.

**** Read this before using ****

Before running the bot, you have to create a text file called: questions.txt which you have to put in your main mirc folder.
In this file, put your questions and answers in the following syntax: question~answer

For example:
who am i~fiberoptics
what is my favorite color~blue
how do you say "four" in japanese~shi or yon

Note: do not use the '~' character in a question or answer, as it is needed to seperate the questions from
the answers!!!

Note: make sure you add more than 5 questions before starting the script! I've added a piece of code
where the script will check if a question has been asked within the last 5 times. If it has, then it will ask another
question instead. You can change this number of repetitions by changing the variable %trivia.rep in the alias trivia.load

Note: you are free to make whatever change u want to make the colors and the way text is presented much nicer. I just
provided the structure, up to you to make it fancy smile

Note: In the alias trivia.load you will find some variables like:

set %trivia.rep 5 <--- sets how many questions you want to be asked before a previously asked question is re-asked
set %trivia.avaltime 60 <---- sets the amount of seconds you have to answer a question correctly
set %trivia.interval 10 <--- sets the amound of seconds until a new question is asked after the last question is finished

---> You can change these values to your likings.

Note: There are only 4 commands available:
1) /trivia.load
2) /trivia.unload
3) !hint
4) !!hint

As you will see when the trivia is running, when a question is asked, it will give u a small hint as follows: all letters will be replaced by *. For example: trivia turns into --> ******

The second type of hint is triggered when u type !hint. The script will only show the vowels from the answer. For example: trivia turns into ---> **i*ia

The third type hint is triggered when u type !!hint. The script will then show you all letters but in scrambled order. For example: trivia turns into something like ---> airtvi

*****************

Put the following code in a new remote file (and don't forget to make sure questions.txt is in you mirc directory with atleast 5 questions in it)

To start up the bot type /trivia.load
To stop the bot type /trivia.unload

Code:
on *:INPUT:*:{
  if (/* !iswm $1) {
    if ($active == status window) { haltdef | echo -s $+(&lt;,$me,&gt;) $1- }
    if (%trivia.status == on) {
      if (%trivia.answer == $strip($1-)) trivia.win $ifmatch 
      elseif ($1 == !hint) trivia.echo Second Hint: $hint(%trivia.answer).2
      elseif ($1 == !!hint) trivia.echo Third Hint: $hint(%trivia.answer).3
    } 
  }
}

alias trivia.echo { echo -s 04&lt;Trivia&gt; 10 $+ $1- }

alias trivia.win {
  var %time = $calc(($ticks - %trivia.ticks) / 1000)
  var %wpm = $ceil($calc(($len(%trivia.answer) / %time) * 12))
  inc %trivia.streak 
  trivia.echo &lt;&lt; $me &gt;&gt; found the right answer &lt;&lt; %trivia.answer &gt;&gt; in %time seconds, and average WPM of %wpm
  trivia.echo $me has won %trivia.streak times in a row
  trivia.nextQ
}

alias trivia.nextQ {
  %trivia.status = off
  .timertrivia.failQ off 
  .timertrivia.askQ 1 %trivia.interval trivia.askQ
  trivia.echo Next question coming in %trivia.interval seconds, get ready!
  trivia.echo $chr(160)
}

alias trivia.failQ {
  %trivia.streak = 0 
  trivia.echo You didn't find the right answer: %trivia.answer
  trivia.nextQ
}

alias trivia.askQ {

  :begin
  var %data = $read(%trivia.questions)
  var %number = $readn

  if ($istok(%trivia.repeat,%number,46)) goto begin 
  %trivia.repeat = $addtok(%trivia.repeat,%number,46)
  if ($numtok(%trivia.repeat,46) &gt; %trivia.rep) %trivia.repeat = $deltok(%trivia.repeat,1,46) 

  tokenize 126 %data

  %trivia.status = on
  %trivia.answer = $2
  %trivia.ticks = $ticks

  .timertrivia.failQ 1 %trivia.avaltime trivia.failQ 

  trivia.echo Question $chr(35) $+ %number - $1 ?
  trivia.echo First hint: $hint($2).1
  trivia.echo $chr(160)
}

alias hint {
  if ($prop == 1) {
    var %t = $chr(42)
    return $lower($replace($1-,a,%t,b,%t,c,%t,d,%t,e,%t,f,%t,g,%t,h,%t,i,%t,j,%t,k,%t,l,%t,m,%t,n,%t,o,%t,p,%t,q,%t,r,%t,s,%t,t,%t,u,%t,v,%t,w,%t,x,%t,y,%t,z,%t,0,%t,1,%t,2,%t,3,%t,4,%t,5,%t,6,%t,7,%t,8,%t,9,%t))
  }
  elseif ($prop == 2) {
    var %t = $chr(42)
    return $lower($replace($1-,b,%t,c,%t,d,%t,f,%t,g,%t,h,%t,k,%t,l,%t,m,%t,n,%t,p,%t,q,%t,r,%t,s,%t,t,%t,v,%t,w,%t,x,%t,y,%t,z,%t,1,%t,2,%t,3,%t,4,%t,5,%t,6,%t,7,%t,8,%t,9,%t))
  }
  elseif ($prop == 3) {
    tokenize 32 $1-

    var %x = 1
    var %word, %newword, %comma, %hint

    while (%x &lt;= $0) { 

      %word = $ [ $+ [ %x ] ]
      if ($right(%word,1) == $chr(44)) { %comma = $ifmatch | %word = $left(%word,-1) }

      while ($len(%word)) {

        if ($rand(1,2) == 1) %newword = $right(%word,1) $+ %newword 
        else %newword = %newword $+ $right(%word,1) 
        %word = $left(%word,-1) 
      }
      %hint = %hint %newword $+ %comma
      %newword = $null
      %comma = $null
      inc %x
    }
    return $lower(%hint)
  }
}

alias trivia.load {
  set %trivia.questions $+(",$scriptdir,questions.txt,")
  set %trivia.rep 5
  set %trivia.status off
  set %trivia.avaltime 60
  set %trivia.interval 10
  .timertrivia.askQ 1 10 trivia.askQ
  trivia.echo Trivia starting in 10 seconds, get ready!
}

alias trivia.unload {
  unset %trivia.*
  .timertrivia.* off
  trivia.echo Trivia has been fully stopped. Type /trivia.load to start it back up.
} 


Here's what it looks like:
<Trivia> Question #3 - how do you say "four" in japanese ?
<Trivia> First hint: *** ** ***
<Trivia>  
<FiberOPtics> !hint
<Trivia> Second Hint: **i o* *o*
<FiberOPtics> !!hint
<Trivia> Third Hint: sih or yno
<FiberOPtics> shi or yon
<Trivia> << FiberOPtics >> found the right answer << shi or yon >> in 8.329 seconds, and average WPM of 15
<Trivia> FiberOPtics has won 3 times in a row
<Trivia> Next question coming in 10 seconds, get ready!
<Trivia>  

Enjoy cool


Last edited by FiberOPtics; 24/04/04 05:46 PM.

Gone.