What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Request] Random Number Generator

[Request] Random Number Generator
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [Request] Random Number Generator
quote:
Originally posted by Slacker
I would really apreciate if someone would be kind enough to make a simple script that generates a random number. When i say random number, a number between 1 and 100 would be ideal please. As im not 100% sure what the number bounds im going to need are, yet. But i'm sure i'll be able to figure out how to edit that tiny bit of the script.
Always search first, and you will find...



Either search the forums:
quote:
CookieRevised's reply to '[I help them] VB2JS'
code:
// Returns a random number
function Rnd() { return Math.random() }

// Returns a random integer number in a range
//   lowerbound    (required) Specifies the lower limit of the range (limit inclusief)
//   upperbound    (required) Specifies the upper limit of the range (limit inclusief)

function RndBetween(lowerbound, upperbound) {
        lowerbound = Math.min(lowerbound, upperbound);
        upperbound = Math.max(lowerbound, upperbound);
        return Math.floor((upperbound - lowerbound + 1) * Math.random() + lowerbound);
}


Or search the help file of Jscript:
http://www.msgpluslive.net/scripts/view/152-Windo...ipt-Documentation/






----------

quote:
Originally posted by -!Felu!-
code:
Math.floor(Math.random()*100)

That will not return a number in the range 1 to 100...  It will return a random number from 0 to 99.

To return a number in the range 1 to 100, you'll need:
Math.floor((100 - 1 + 1) * Math.random() + 1);
or
Math.floor(Math.random() * 100 + 1);




This post was edited on 06-24-2008 at 05:33 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-01-2006 07:44 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Request] Random Number Generator - by Slacker on 12-01-2006 at 04:47 PM
RE: [Request] Random Number Generator - by CookieRevised on 12-01-2006 at 07:44 PM
RE: RE: [Request] Random Number Generator - by Jesus on 12-02-2006 at 01:17 AM
RE: [Request] Random Number Generator - by foaly on 12-02-2006 at 01:25 AM
RE: [Request] Random Number Generator - by CookieRevised on 12-02-2006 at 01:28 AM
RE: RE: [Request] Random Number Generator - by Jesus on 12-03-2006 at 02:21 AM
RE: [Request] Random Number Generator - by CookieRevised on 12-03-2006 at 05:44 AM
RE: RE: [Request] Random Number Generator - by Jesus on 12-03-2006 at 10:37 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On