mIRC Homepage
When a user says something in an 'on TEXT' event, I want my bot to warn them based on how many times they've been warned for it in the past. So when a user says something, the bot will put their name in a text file, then the next time they say it again, the bot will look in the text file to see if that name exists in the file 3 or more times, and if so, make the bot say something else.

Example:

http://www.paste.mircscripting.info/index.php?id=2857

Can someone help me please? Thanks.
The text file is storing text, not numbers.
I'd suggest using .ini files (If not hash tables) to store values, since it's easier to handle values.
Something like this should work:
Code:
on *:text:*fuckoff*:#: {
    if ( $readini(txt\warns.txt,Warns,$nick) <= 2 ) {
        msg $chan $nick $+ , please do not say that!
        .writeini txt\warns.txt Warns $nick $calc($v1 + 1)
    }
    if ( $readini(txt\warns.txt,Warns,$nick) >= 3 ) {
        msg $chan That's it! | /mode +b blah blah blah | .remini txt\warns.txt Warns $nick
    }
}


Oh, and just a pointer. Once the nick's warning counter reaches 2, both of the if statements will trigger.
Here's my recommendation. Part of the reason your code wasn't working, is that the $read identifier only detected the first time that the nick was written to the text file, not the total number of times that it was written.
Code:
on *:text:*fuckoff*:#: {
  var %warns = $read(txt\warns.txt,s,$nick)
  inc %warns
  .write -s $+ $nick txt\warns.txt $nick %warns
  if %warns <= 2 {
    msg $chan $nick $+ , please do not say that!
  }
  else {
    msg $chan That's it!
    ban -ku300 $chan $nick Enough swearing
    .write -ds $+ $nick txt\warns.txt
  }
}

Both of the if statements wouldn't trigger, as the condition for the first if statement says less than or equal to two, but the second requires the number to be three or more.
Russel, it's not working. I tested 4 times and this is what the file looks like (warns.txt):

Joe_Dean 1
Joe_Dean 2
Joe_Dean 2
Joe_Dean 2
Sorry, forgot to include the switch information to have the /write command over-write the previous entry.
Works like a charm now. Thanks! wink
© mIRC Discussion Forums