What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Random numbers, prevent from being used more than once

Random numbers, prevent from being used more than once
Author: Message:
stu
Junior Member
**

Avatar
Stu

Posts: 82
Reputation: 1
39 / Male / Flag
Joined: Sep 2004
O.P. RE: Random numbers, prevent from being used more than once
Thanks Volv for the (foaly's) code, I'll try that out as well once I get Cookie's code working
___________________________________

quote:
You've not copied the code exactly as I put it (or you changed stuff too much or in the wrong way)...
Perhaps so, take a look.

This is the code as I have it.. well, the main functions...
code:
var Text=new Array();

var num=0;

Text[num++] = "Test 1";

Text[num++] = "Test 2";

Text[num++] = "Test 3";

Text[num++] = "Test 4";

Text[num++] = "Test 5";

Text[num++] = "Test 6";

Text[num++] = "Test 7";

Text[num++] = "Test 8";

Text[num++] = "Test 9";

Text[num++] = "Test 10";

Text[num++] = "Test 11";

Text[num++] = "Test 12";


///////////////////////////////////////////////////////////
//                    Script Starts here
//////////////////////////////////////////////////////////

var arrLyrics = new Array();
var arrPrevious = new Array();
var nUniqueness = 10;


function GetAllLyrics() {
arrPrevious = new Array();
return Text
}

function GetRandomLyric() {
// get a random lyric line from the 'possible lyrics' array
var rndLyric = Math.floor(Math.random() * arrLyrics.length);
// step 1: add new line to 'used lyrics' array and remove it from the 'possible lyrics' array
arrPrevious[nUniqueness-1] = arrLyrics.splice(rndLyric, 1);
// step 2: add last lyric line from the 'used lyrics' array back to the 'possible lyrics' array
if (arrPrevious[0] !== undefined) arrLyrics.push(arrPrevious[0]);
// step 3: remove last lyric line from the 'used lyrics' array
arrPrevious.shift();
// you're done: return the new lyric line
return arrPrevious[nUniqueness-2]
Debug.Trace(arrPrevious);
}


function personalMessage()
{
Debug.Trace ("Started Personal Message");
    //reading the timer value from the registry
    try{
        timer = WShell.RegRead(MsgPlus.ScriptRegPath+Messenger.MyUserId+"\\JeremysRandomSongLyricTimer");
    }
    catch(e){}

    try{
        randomlyric = WshShell.RegRead(MsgPlus.ScriptRegPath+Messenger.MyUserId+"\\JeremysRandomSongLyric");
    }
    catch(e){}
    if (randomlyric==1)
    {

       
        arrLyrics = GetAllLyrics();

        var rndLyric = GetRandomLyric();
        //Messenger.MyPersonalMessage = "( 8)" + rndLyric;
        MsgPlus.DisplayToast("New Random Lyric", "( 8)" + rndLyric, null, 'OnToastClick', null);
        MsgPlus.AddTimer('randomtext', timer);
        Debug.Trace ("Printed personal message - " + rndLyric);
        Debug.Trace ("ArrPrevious - " + arrPrevious);
        Debug.Trace ("ArrLyrics - " + arrLyrics);
       
}

This post was edited on 07-05-2007 at 03:28 AM by stu.
07-05-2007 03:22 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Random numbers, prevent from being used more than once - by stu on 07-03-2007 at 10:14 PM
RE: Random numbers, prevent from being used more than once - by pollolibredegrasa on 07-03-2007 at 10:33 PM
RE: Random numbers, prevent from being used more than once - by foaly on 07-03-2007 at 10:34 PM
RE: Random numbers, prevent from being used more than once - by roflmao456 on 07-04-2007 at 03:15 AM
RE: Random numbers, prevent from being used more than once - by Volv on 07-04-2007 at 06:01 AM
RE: Random numbers, prevent from being used more than once - by markee on 07-04-2007 at 02:17 PM
RE: Random numbers, prevent from being used more than once - by Volv on 07-04-2007 at 02:31 PM
RE: Random numbers, prevent from being used more than once - by markee on 07-04-2007 at 02:35 PM
RE: Random numbers, prevent from being used more than once - by foaly on 07-04-2007 at 04:00 PM
RE: Random numbers, prevent from being used more than once - by stu on 07-04-2007 at 04:50 PM
RE: Random numbers, prevent from being used more than once - by roflmao456 on 07-04-2007 at 05:22 PM
RE: Random numbers, prevent from being used more than once - by Volv on 07-04-2007 at 05:47 PM
RE: Random numbers, prevent from being used more than once - by CookieRevised on 07-05-2007 at 12:34 AM
RE: Random numbers, prevent from being used more than once - by stu on 07-05-2007 at 12:51 AM
RE: Random numbers, prevent from being used more than once - by CookieRevised on 07-05-2007 at 12:55 AM
RE: Random numbers, prevent from being used more than once - by stu on 07-05-2007 at 01:03 AM
RE: Random numbers, prevent from being used more than once - by CookieRevised on 07-05-2007 at 01:32 AM
RE: Random numbers, prevent from being used more than once - by stu on 07-05-2007 at 01:55 AM
RE: Random numbers, prevent from being used more than once - by CookieRevised on 07-05-2007 at 02:00 AM
RE: Random numbers, prevent from being used more than once - by stu on 07-05-2007 at 02:18 AM
RE: Random numbers, prevent from being used more than once - by CookieRevised on 07-05-2007 at 02:32 AM
RE: Random numbers, prevent from being used more than once - by Volv on 07-05-2007 at 02:45 AM
RE: Random numbers, prevent from being used more than once - by stu on 07-05-2007 at 02:51 AM
RE: Random numbers, prevent from being used more than once - by CookieRevised on 07-05-2007 at 03:07 AM
RE: Random numbers, prevent from being used more than once - by Volv on 07-05-2007 at 03:11 AM
RE: Random numbers, prevent from being used more than once - by stu on 07-05-2007 at 03:22 AM
RE: Random numbers, prevent from being used more than once - by CookieRevised on 07-05-2007 at 03:36 AM
RE: Random numbers, prevent from being used more than once - by stu on 07-05-2007 at 03:45 AM
RE: Random numbers, prevent from being used more than once - by CookieRevised on 07-05-2007 at 03:47 AM
RE: Random numbers, prevent from being used more than once - by stu on 07-05-2007 at 03:55 AM
RE: RE: Random numbers, prevent from being used more than once - by CookieRevised on 07-05-2007 at 04:23 AM
RE: Random numbers, prevent from being used more than once - by stu on 07-05-2007 at 04:30 AM
RE: Random numbers, prevent from being used more than once - by foaly on 07-05-2007 at 10:57 AM
RE: Random numbers, prevent from being used more than once - by stu on 07-05-2007 at 04:59 PM
RE: Random numbers, prevent from being used more than once - by CookieRevised on 07-05-2007 at 11:39 PM


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