mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Code:
 on @*:text:!abductme:#:{
  set %question $calc($hfind(AS,$+(*,$address),0,w) + 1)
  if %question <= $lines(questions.txt) {
    .enable #input
    set %chan $chan
    question $nick $address %question
  }
  else .mode # +v $nick
}
#input off
alias question {
  set %address $2
  .msg $1 $read(questions.txt,$3)
  set %entry $gettok($read(questions.txt,$3),-1,32)
}
on *:text:*:?:{
  if %address = $address {
    .hadd -m AS $+(%entry,.,$address) $1-
    inc %question
    while %question <= $lines(questions.txt) {
      question $nick $address %question 
      inc %question
    }
    .disable #input
    .close -m $nick
    .mode %chan +v $nick
  }
}
#input end
 


I've narrowed down the problem area to that shown in the above code.

Basically the problem is that after the bot asks the first question and gets a reply, it then asks all 3 of the remaining questions without waiting for responses.

If the problem is not in this area, I will post the full code.

Last edited by RusselB; 14/03/06 04:01 AM.
Joined: Mar 2003
Posts: 32
P
Pap Offline
Ameglian cow
Offline
Ameglian cow
P
Joined: Mar 2003
Posts: 32
I'm looking at your code, not really understanding what's going on, but this striked me as odd:

Code:
    inc %question
    while %question <= $lines(questions.txt) {
      question $nick $address %question 
      inc %question
    }


Is that sequence what you intended?

Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
that looks correct. The questions (at the moment) are on lines 1-4 of questions.txt
If there is no data stored in the hash table for the person going through the questions, then %question is actually a 0 value, so to get the first line, I increase the value of %question outside of the loop.
If there is data stored, then this also ensures that the first question put to the person corresponds with the first location in the hash table that doesn't have an entry.

Then we get the loop which calls the alias question and relays the question to the person for them to answer.

Once they've answered the question, then the information is stored in the hash table and control of the script returns to the while loop, where %question is increased, then checked against the number of lines in questions.txt

A complicated answer, but hopefully one that will explain what I think should be happening.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
The last poster was right, you were looping through all remaining questions sending them one after another. in the on *:text:? event. ( bit odd you didnt see it my man that flu must have taken you down alot frown )

Anyway Try this....

Code:
on @*:text:!abductme:#:{
  set %question $calc($hfind(AS,$+(*,$address),0,w) + 1)
  if %question <= $lines(questions.txt) {
    .enable #input
    set %chan $chan
    question $nick $address %question
  }
  else .mode # +v $nick
}
#input off
alias question {
  set %address $2
  .msg $1 $read(questions.txt,$3)
  set %entry $gettok($read(questions.txt,$3),-1,32)
}
on *:text:*:?:{
  if %address = $address {
    .hadd -m AS $+(%entry,.,$address) $1-
    inc %question
    if (%question <= $lines(questions.txt)) {
      question $nick $address %question 
    }
    else {
      .disable #input
      .close -m $nick
      .mode %chan +v $nick
    }
  }
}
#input end

Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Thanks Dave. That works perfectly. And you can change the word flu to pneumonia frown

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
i new it was something more complexe, but i cant spell that and also dont know what it means. :]

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245


Link Copied to Clipboard