mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2004
Posts: 7
S
ssc Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: May 2004
Posts: 7
How do i make a script like this:

if someone types !randno <no. of random numbers>
it will appear something like this: 1st rand number + 2nd rand number + 3rd rand number. + ...... = the sum of these rand numbers

hmm... here's an example:
<$nick> !randno 5
<$me> 52 + 78 + 30 + 7 + 99 = 266

How do I make a script like this?
any help is appreciated

Joined: Jan 2003
Posts: 73
K
Babel fish
Offline
Babel fish
K
Joined: Jan 2003
Posts: 73
very easy :

set %no1 $rand(1,999) | set %no2 $rand(1,999)

say %no1 + %no2 = $calc(%no1 + %no2)

maybe?


Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Code:
on *:text:!randno *:#:{
  if $2 !isnum 1-79 || %randno [ $+ [ $site ] ] { return }
  set -u[color:red]5[/color] %randno $+ $site 1
  set -ln %a $left($($str($!r([color:blue]0,99[/color]) + $+ $chr(32),$2),2),-2)
  msg # %a = $calc(%a)
}
The %randno $+ $site variable is not related to the random number generator, it's just a simple flood protection scheme: a user who said "!randno <number>" must wait 5 seconds before saying it again (the script will just ignore them if they say it before the 5 seconds have elapsed). If you want to change that interval, you must change the red number.

Since you didn't specify the range of random numbers, I used 0-99. If you want another range, change the blue 0,99 to something else.

Last edited by qwerty; 28/05/04 09:32 AM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

I was surprised to see that mIRC doesn't mind excessive +'s in the $calc function.

//echo -a $calc(1 +++++++ 2) --> 3
//echo -a $calc(1 + + + + + + + 2) --> 3
//echo -a $calc(1 + 2 +) --> 3

The $left identifier can be seen as redundant then, but well, I guess that's only for those wanting to be picky.

Greets

Btw, that set -l flag is interesting! I didn't know about it since it's undocumented. So it treats the variable as local.

Last edited by FiberOPtics; 28/05/04 09:53 AM.

Gone.
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I'm aware of this feature of $calc(), however $left() is not redundant because I'm using "msg # %a = $calc(%a)" ; the variable has to be displayed properly.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Ah yes indeed, ignore what I said then.

When I was testing that, I directly msged the channel with the $calc where $left had no need. Woops!

Greets


Gone.

Link Copied to Clipboard