mIRC Home    About    Download    Register    News    Help

Print Thread
#123715 27/06/05 12:58 AM
Joined: Jun 2005
Posts: 44
B
BNX Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Jun 2005
Posts: 44
Let's say I wanted to make a quiz with 2 questions..

Something like:
Code:
 
on *:TEXT:!quiz:#: {
   /msg # starting 2 questions
   /quiz.1
}

alias -l quiz.1 {
  /msg # what is 1 + 1?
  on *:TEXT:2:#: /msg right!
  /quiz.2
}

alias -l quiz.2 {
  /msg # what is 2 + 2?
  on *:TEXT:4:#: /msg right!
  /halt
}
 


now... it is very obvious what I want to do...

how do I make it WAIT for the user to enter a correct response before moving on to question 2?

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
Here's a simple one


Code:
 on *:TEXT:!quiz:[color:red]#CHANNEL[/color]: {
  if ( !%quizn ) {
    msg $chan Starting $lines(quiz.txt) questions
    start.quiz $chan
  }
}

on *:TEXT:*:[color:red]#CHANNEL[/color]: {
  if ($1- == %answer) {
    unset %answer
    msg $chan $nick $+ : You got the right answer -> $1- <-
    msg $chan Get ready for the next question
    .timerquiz.start 1 5 start.quiz $chan
  } 
}

alias start.quiz {
  inc %quizn
  if ( $read(quiz.txt,%quizn) ) {
    var %chan = $1
    tokenize 42 $v1
    set %answer $2
    msg %chan $1 ?
    .timerquiz.answer 1 60 unset %answer $(|, ) msg %chan Times up! 
    .timerquiz.start 1 5 start.quiz %chan
  }
  else { 
    msg $1 There's no more questions
    unset %quizn %answer
  }
}
 


You would need to put your questions in a text file called quiz.txt so you could just add questions next time. The format of the question & answer in the file should be like this "question*answer". See sample below...


1 + 1*2
1 + 2*3
2 + 2*4

**Change #Channel in red

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Improved the on text a slight bit, and corrected the timmer before the next question.
beyond that looks real good.

Code:
on *:TEXT:!quiz:[color:red]#CHANNEL[/color]: {
  if ( !%quizn ) {
    msg $chan Starting $lines(quiz.txt) questions
    start.quiz $chan
  }
}
on *:TEXT:%answer:[color:red]#CHANNEL[/color]: {
  unset %answer
  msg $chan $nick $+ : You got the right answer -> $1- <-
  msg $chan Get ready for the next question
  .timerquiz.answer off
  .timerquiz.start 1 5 start.quiz $chan
}

alias start.quiz {
  inc %quizn
  if ( $read(quiz.txt,%quizn) ) {
    var %chan = $1
    tokenize 42 $v1
    set %answer $2
    msg %chan $1 ?
    .timerquiz.answer 1 60 msg %chan Times up! It was % $+ answer $(|, ) unset %answer 
    .timerquiz.start 1 65 start.quiz %chan
  }
  else { 
    msg $1 There's no more questions
    unset %quizn %answer
  }
}


Link Copied to Clipboard