Shoutbox

Random Numbers - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Random Numbers (/showthread.php?tid=65175)

Random Numbers by Spunky on 08-20-2006 at 10:51 PM

I know that there must be a random function that I can use for my scripts, I just can't find it. I tried:

code:
myNum = Random(15);


It's for a colourful text program I made for a friend...

RE: Random Numbers by Silentdragon on 08-20-2006 at 11:01 PM

code:
myNum = Math.floor(Math.random()*15);
Should give you a random number between 0 and 15

If you want 1  to 15

code:
myNum = Math.floor(Math.random()*14+1);
Should work.
RE: Random Numbers by KnRd_WC on 08-20-2006 at 11:05 PM

Hi !

Try this ;)

code:
myNum = Math.floor(Math.random()*16);
// myNum will be between 0 and 15, if you don't want to have 0, use this one :
// myNum = Math.floor(Math.random()*15)+1;

;)

--------------
Lol Silentdragon, we don't say the same thing.... !! :D
RE: Random Numbers by Spunky on 08-20-2006 at 11:17 PM

Thanks guys! Didn't work at first, but I'd missed off a closing bracket :$ 

Heres the finished script incase anybody is interested...

EDIT - Start the message with a space if you do not want it to be sent using the script to add colour.  Also, messages that start with "/" have colours disabled so you can still use commands. I caught that little glitch when I tried to get into my preferences :D

Before the colour was the same number as the i variable in the For loop


RE: Random Numbers by KnRd_WC on 08-20-2006 at 11:25 PM

Very funny script ;)

**Disco on messenger !!** lol