mIRC Home    About    Download    Register    News    Help

Print Thread
Greater than, less then, & equal to problems #200269 01/06/08 01:50 AM
Joined: May 2008
Posts: 127
J
Joe_Dean Offline OP
Vogon poet
OP Offline
Vogon poet
J
Joined: May 2008
Posts: 127
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.

Last edited by Joe_Dean; 01/06/08 01:51 AM.
Re: Greater than, less then, & equal to problems [Re: Joe_Dean] #200270 01/06/08 02:01 AM
Joined: Nov 2007
Posts: 19
J
Jyang Offline
Pikka bird
Offline
Pikka bird
J
Joined: Nov 2007
Posts: 19
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.

Re: Greater than, less then, & equal to problems [Re: Joe_Dean] #200271 01/06/08 02:08 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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
  }
}


Last edited by RusselB; 01/06/08 02:59 AM.
Re: Greater than, less then, & equal to problems [Re: Jyang] #200272 01/06/08 02:10 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

Re: Greater than, less then, & equal to problems [Re: RusselB] #200273 01/06/08 02:44 AM
Joined: May 2008
Posts: 127
J
Joe_Dean Offline OP
Vogon poet
OP Offline
Vogon poet
J
Joined: May 2008
Posts: 127
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

Re: Greater than, less then, & equal to problems [Re: Joe_Dean] #200274 01/06/08 03:00 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Sorry, forgot to include the switch information to have the /write command over-write the previous entry.

Re: Greater than, less then, & equal to problems [Re: RusselB] #200275 01/06/08 04:01 AM
Joined: May 2008
Posts: 127
J
Joe_Dean Offline OP
Vogon poet
OP Offline
Vogon poet
J
Joined: May 2008
Posts: 127
Works like a charm now. Thanks! wink