mIRC Home    About    Download    Register    News    Help

Print Thread
#21418 28/04/03 10:30 PM
Joined: Jan 2003
Posts: 14
T
tendre Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2003
Posts: 14
hi..
am wondering.. is it possible to have a random number generator that will spit out a number from 1-10 .. like

3.256 <--

on a command like : !capture
it will say $nick was captured in 9.653

any help would be apprectiated greatly !!!

#21419 28/04/03 10:46 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Code:
alias randDec {
  /set -u0 %num $rand(1,10)
  return $+(%num,.,$iif(%num &lt; 10, $+($rand(0,9),$rand(0,9),$rand(0,9)),000))
}


-KingTomato
#21420 28/04/03 11:16 PM
Joined: Jan 2003
Posts: 14
T
tendre Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2003
Posts: 14
that is working !!
except.. am always getting an even number..

like 7.000 or 9.000
will it always do that ?
or will it come up with also a 7.235 etc ?


thank you also !!

#21421 28/04/03 11:39 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Code:
alias randdec return $calc($rand($calc($1 *10^ $3),$calc($2 *10^ $3)) /10^ $3)


Usage: $randdec(N1,N2,P)
N1 and N2 are the same parameters as in $rand()
P is the precision parameter.
Fex, to create random numbers from 2 to 13 with up to 4 decimals you'd use this:
$randdec(2,13,4)


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#21422 28/04/03 11:57 PM
Joined: Jan 2003
Posts: 14
T
tendre Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2003
Posts: 14
hii..

am not able to get that last script to work at all for some reason..
thank you for your help though..

#21423 29/04/03 12:09 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
10-try test using mine...

4.368
7.885
3.851
5.317
4.179
5.179
4.951
8.862
3.822
5.633


-KingTomato
#21424 29/04/03 12:11 AM
Joined: Jan 2003
Posts: 14
T
tendre Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2003
Posts: 14
am not quite sure how to set it up though..

#21425 29/04/03 12:12 AM
Joined: Jan 2003
Posts: 14
T
tendre Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2003
Posts: 14
that is exactly what i want though .. number wise !!!!


#21426 29/04/03 01:21 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Just put this in remotes:

alias randDec {
/set -u0 %num $rand(1,10)
return $+(%num,.,$iif(%num < 10, $+($rand(0,9),$rand(0,9),$rand(0,9)),000))
}


-KingTomato
#21427 29/04/03 03:20 AM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
That script is incredibly complex for such a simple task. There is no need for any $iifs, no local variables,

$calc(($rand(1,100000000)/$rand(1,1000000) % 9) +1)

That will return a random real number between 1 and 10. If you want it to only have 3 decimal places, use $round:

$round($calc(($rand(1,100000000)/$rand(1,1000000) % 9) + 1),3)

It produces some very nice random results:
7.61
7.052
9.145
9.382
6.79
3.115
1.546
5.04
8.57
7.766

#21428 29/04/03 05:49 AM
Joined: Jan 2003
Posts: 14
T
tendre Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2003
Posts: 14
thank you so much !!!!!!!!!! i was so tired last night i went and stuck it in the alias *lol*

BUT now.. it works !!

#21429 29/04/03 06:35 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Always good to hear. grin


-KingTomato

Link Copied to Clipboard