mIRC Homepage
Posted By: Kriminal Loop (Please Help) - 23/02/04 08:22 AM
on *:TEXT:*#:{ if (%kaos.bot == yes) { search $strip($1-,c) } }
alias search { var %x = 1
while (%x <= $lines(answers.txt)) { if ($1- isin $read(answers.txt,%x)) { notice $nick $talker(Too late, Someone else got that answer!) }
if ($1- !isin $read(answers.txt,%x)) { search2 $strip($1-,c) }
inc %x
}
}
alias search2 { var %x = 1
while (%z <= $lines(%question)) { notice $nick $talker(Point Added!) | write answers.txt $1-
inc %x
}
}
--Variables--
%queston is: Eminem.txt
%kaos.bot is: yes
%left is: 12,1(
%text is: 15,1
%right is: 12,1)
Anyone see a problem with that?
Posted By: tidy_trax Re: Loop. - 23/02/04 08:23 AM
in the second one you have while %z <= ..., change z to x
Posted By: Kriminal Re: Loop. - 23/02/04 08:30 AM
New(est) Code:
on *:TEXT:*:#Kaos:{ if (%kaos.bot == yes) { search $strip($1-,c) }
}
alias search { var %x = 1
while (%x <= $lines(answers.txt)) { if ($1- isin $read(answers.txt,%x)) { notice $nick $talker(Too late, Someone else got that answer!) }
if ($1- !isin $read(answers.txt,%x)) { search2 $strip($1-,c) }
inc %x
}
}
alias search2 { var %x = 1
while (%x <= $lines(%question)) { notice $nick $talker(Point Added!) | write answers.txt $1-
inc %x
}
}
--
--Still not working.
Posted By: DaveC Re: Loop. - 23/02/04 09:53 AM
I think its working fine, I just doubt its doing what you want it to do.

What is it that you expected to happen when someone typed something.
Give maybe 3 or 4 examples with each producing differnt results.
Posted By: Kriminal Re: Loop. - 23/02/04 10:05 AM
Say you said Bully in the channel
It's supposed to say: Blah blah you got it blah blah and write it in answers.txt
and say someone else tried to do it
It would msg the person with "Already Used" or something like that and wouldn't write it in answers.txt
~Krim
Posted By: Kriminal Re: Loop. - 23/02/04 10:37 AM
on *:TEXT:*:#Kaos:{ if (%kaos.bot == yes) { search $strip($1-,c) }
}
alias search { var %x = 1
while (%x <= $lines(answers.txt)) { if ($1- isin $read(answers.txt,%x)) { notice $nick $talker(Too late, Someone else got that answer!) }
if ($1- !isin $read(answers.txt,%x)) { search2 $strip($1-,c) }
inc %x
}
}
alias search2 { var %x = 1
while (%x <= $lines(Eminem.txt)) { if ($1- isin $read(Eminem.txt,%x)) { notice $nick $talker(Point Added!) | write answers.txt $1- }
inc %x
}
}
Updated;
I replaced %question with Eminem.txt to see
and I added a "if" statement in the search2 alias, still not working, Any clue why anyone? =/
Posted By: billythekid Re: Loop. - 23/02/04 10:46 AM
i dont think $nick returns anything in an alias just in a remote, try settin the nick as a variable and calling that.
Posted By: Doqnach Re: Loop. - 23/02/04 10:53 AM
you are right, as soon as you leave the event, $nick has no value.

from the aliasses you can't use identifiers as $chan or $nick

best is to pass $nick as the first parameter...

here is a sample:
Code:
{ search $nick $strip($1-,c) }

alias search { var %x = 1
while (%x &lt;= $lines(answers.txt)) { if ($2- isin $read(answers.txt,%x)) { notice $1 $talker(Too late, Someone else got that answer!) }
if ($2- !isin $read(answers.txt,%x)) { search2 $1 $strip($2-,c) }
inc %x
}
}
Posted By: Kriminal Re: Loop. - 23/02/04 11:13 AM
Newest Update:
on *:TEXT:*:#Kaos:{ if (%kaos.bot == yes) { search $nick $strip($1-,c) }
}
alias search { var %x = 1
while (%x <= $lines(answers.txt)) { if ($2- isin $read(answers.txt,%x)) { notice $1 $talker(Too late, Someone else got that answer!) }
if ($2- !isin $read(answers.txt,%x)) { search2 $1 $strip($2-,c) }
inc %x
}
}
alias search2 { var %x = 1
while (%x <= $lines(Eminem.txt)) { if ($2- isin $read(Eminem.txt,%x)) { notice $1 $talker(Point Added!) | write answers.txt $2- }
inc %x
}
}

-What Works:
If the Answer is already in answers.txt (I put it in manually) The notice works. (Im sure the $nick wasn't the problem) - but it wont do search2 part.
~Krim
Posted By: billythekid Re: Loop. - 23/02/04 11:22 AM
Code:
 
alias search { var %x = 1
while (%x &lt;= $lines(answers.txt)) { 
if ($2- isin $read(answers.txt,%x)) { notice $1 $talker(Too late, Someone else got that answer!) }
[color:red]else[/color]if ( $2- !isin $read(answers.txt,%x)) { search2 $1 $strip($2-,c) } 
inc %x 
}
}
 
try that, i've had if / elseif problems before, i'd try it myself but im at work without mIRC atm ;o(
edit: sorry didnt read the whole post, shoot me ;oP
Posted By: Kriminal Re: Loop. - 23/02/04 11:27 AM
on *:TEXT:*:#Kaos:{ if (%kaos.bot == yes) { search $nick $strip($1-,c) }
}
alias search { var %x = 1
while (%x <= $lines(answers.txt)) { if ($2- isin $read(answers.txt,%x)) { notice $1 $talker(Too late, Someone else got that answer!) }
elseif ($2- !isin $read(answers.txt,%x)) { search2 $1 $strip($2-,c) }
inc %x
}
}
alias search2 { var %x = 1
while (%x <= $lines(Eminem.txt)) { if ($2- isin $read(Eminem.txt,%x)) { notice $1 $talker(Point Added!) | write answers.txt $2- }
inc %x
}
}
Is what I tried
--This is quite frustrating cause I'm like, nearly 100%, my code should've worked from my 2nd-3rd fix. =/
--No work =/
Posted By: Iori Re: Loop. - 23/02/04 06:52 PM
You can try this
Code:
on *:TEXT:*:#Kaos:if (%kaos.bot == yes) { search $strip($1-,c) }
alias search {
  var %x = 1
  while (%x &lt;= $lines(answers.txt)) {
    if ($1- isin $read(answers.txt,%x)) { notice $nick Too late, Someone else got that answer! | return }
    inc %x 
  }
  search2 $strip($1-,c)
}
alias search2 {
  var %x = 1
  while (%x &lt;= $lines(Eminem.txt)) {
    if ($1- isin $read(Eminem.txt,%x)) { notice $nick Point Added! | write answers.txt $1- }
    inc %x
  }
}

Or this much shorter version
Code:
on *:TEXT:*:#Kaos:{
  if (%kaos.bot == yes) {
    if $read(answers.txt,wn,$+(*,$1-,*)) { notice $nick Too late, Someone else got that answer! }
    elseif $read(Eminem.txt,wn,$+(*,$1-,*)) { notice $nick Point Added! | write answers.txt $1- }
  }
}

Posted By: Kriminal Re: Loop. - 23/02/04 09:36 PM
Thanks a Bunch Iori, But, Can you tell me what it had to be right there for it to work "the Search2 part" had to be here:
inc %x
}
search2 $strip($1-,c)
}
I like understanding codes that I make that don't work and are fixed by someone. smile
Posted By: Iori Re: Loop. - 23/02/04 09:43 PM
Well with that first code, I just copied what you had and only 'fixed' the part that wasn't working, which was the loop). That particular command could simply have been "search2 $1-"
© mIRC Discussion Forums