mIRC Homepage
Posted By: DeathfireD writing 2 lines to a file. - 10/09/04 09:01 PM
Ok I been thinking about this for more then a week. I just started coding again so I’m lost as to do this. Right now I’m trying to have it so when someone talks in a chat the script will look in the file Brain.txt for the word or Sentence to see if it exists. If it doesn’t it will write the word down in the Brain.txt file.

After it is written down it will wait for a set time lets say 1mins for a response to what that person said. So say someone join my chat they say “hi” then script will write hi in the Brain.txt and wait 1min for someone to say something back like “yo what’s up” then after someone response to the first comment the script will write that down to the Brain.txt file next to the first comment.

Like this: Brain.txt
Hi yo what’s up

This is just the first part.
2nd if someone says something that already exists in the Brain.txt file it will say the word that’s next to it. So say someone join the chat and goes “hi” the script looks in the Brain.txt file for whatever word or sentence is next to it and messages the channel that word or sentence.

IF you haven’t noticed I’m trying to make a basic AI bot. If anyone can help please do so. I would be very thankfull.
Posted By: tidy_trax Re: writing 2 lines to a file. - 10/09/04 09:14 PM
Code:
on *:text:*:*:{
     if (!$read(brain.txt,nw,$1-*)) { 
           write brain.txt $1- $chr(9) 
           set %ltopic $1-
     }
     else { 
          if (%ltopic != $null) && ($gettok($read(brain.txt,nw,%ltopic $+ *),2,9) == $null) { 
               write $+(-l,$readn) brain.txt $read(brain.txt,n,$readn) $1- 
               unset %ltopic
          }
          elseif ($gettok($read(brain.txt,nw,$1-*),2,9)) { msg $chan $gettok($read(brain.txt,nw,$1-*),2,9) }
     }
}
Posted By: DeathfireD Re: writing 2 lines to a file. - 10/09/04 09:24 PM
Tidy thanks but for some reason it dosent write down the 2nd word or sentence in the same line till 2 mins pass lol. it all works just the timer seems weird. Ill fool with it but thanks alot this will help me out so much.
© mIRC Discussion Forums