mIRC Homepage
Hello, I want to make a simple code where the bot would recognize whether the number a person sending the command is typing would be positive or negative. It would look something like that:

Quote:
Person: !number 3
Bot: The number is positive.

or
Quote:
Person: !number -3
Bot: The number is negative.


I have tried putting a variable after the command like so:
Code:
on *:TEXT:!number %number:#:

But this doesn't seem to work.

Any idea how should it look like? Thank you in advance for helping me smile
on *:text:!number *:#: if ($2 < 0) msg $chan The number is negative | elseif ($2 > 0) msg $chan The number is positive

that should work and also zero isn't positive or negative if you didn't know, so the script doesn't say anything for zero lol
Yes, I know, the example I gave is for me to learn how those work for a bigger project smile

The bot seems to recognize the numbers in the command I gave in the example, but I also have another question.

Is there a way to make the bot recognize a number in a sentence? And if there is more than one number, is it possible for the bot to "care" only about the first one? Example:
Quote:
Person: The number 20 is bigger than 19.
Bot: Number 20 is positive.
This one is a little more advance as it uses regex matching. It will find the first number that is by itself. So it will not find anon31 but it will find 975.

on $*:text:/^.*? (\d+) /:#: echo -a number $regml(1)

The $ in the on $*:text allows you to use regex in the on text event. The /^.*? (\d+) / is the regex string. If you want to know more just ask.
© mIRC Discussion Forums