What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » My first script.

My first script.
Author: Message:
devilz-fury
Junior Member
**

Avatar

Posts: 17
Reputation: -6
30 / Male / –
Joined: Nov 2006
O.P. My first script.
This is a dead simple script. All it does is it reads a text file every 10 minutes, picks out a random non-blank line from that file and then sets that as your Personal Message on Messenger. You could use this script with IRC logs, a list of quotes, etc. It didn't take long to make.

Source Code
function updateMessage() {    FileSystem = new ActiveXObject("Scripting.FileSystemObject");    file = FileSystem.OpenTextFile("E:/Documents/testfile.txt", 1);    i = 0;    lines = new Array();    while(!file.AtEndOfStream) {        line = file.ReadLine();        if (line != '') {            lines[i] = line;        }        i++;    }    file.Close();    linenum = Math.floor(Math.random()*lines.length)-1;        Messenger.MyPersonalMessage = lines[linenum];}function OnEvent_Initialize(MessengerExit) { }function OnEvent_Uninitialize(MessengerExit) { }function OnEvent_Signin(email) {    if (email == Messenger.MyEmail) {        updateMessage();        MsgPlus.AddTimer('randomtext', 600000);    }}function OnEvent_Timer(timerId) {    if (timerId == 'randomtext') {        updateMessage();        MsgPlus.AddTimer('randomtext', 600000);    }}

Hopefully most of this script should be fairly self-explanatory. OnEvent_Signin is called when a user signs in. This function checks that it is the current user who has just signed in, and if so calls updateMessage() and schedules the next call for in 10 minutes time.

OnEvent_Timer gets called when a timer is triggered - in this case it'll get called after 10 minutes. The function calls updateMessage() and schedules the next call for in another 10 minutes time. updateMessage() opens a text file, reads the whole file putting it into an array and then selects a random line and sets it as the personal message.

Usage
To use it, go to Plus > Scripts and select "Create New". Enter a name for the script and paste the contents of the script above into it and save it. You'll have to sign out/sign in or restart Messenger to make it work. Make sure you've also changed the path to the text file which is E:/Documents/testfile.txt by default.


It'll overwrite your whole personal message. If you want it to appear as part of your personal message, concatenate the random line with something else. For example, you could change:

Messenger.MyPersonalMessage = lines[linenum];To:

Messenger.MyPersonalMessage = 'My Personal Message | '+lines[linenum]; If you want to change the update interval, change the value of 600000 (600000ms is 10 minutes).
"The World At Peace? I'd Rather See The World In Pieces."
[Image: GrimDEV.png]
[Image: Team-Exile-Member-Userbar.gif]
11-29-2006 06:39 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
My first script. - by devilz-fury on 11-29-2006 at 06:39 PM
RE: My first script. - by andrey on 11-29-2006 at 06:58 PM
RE: My first script. - by CookieRevised on 11-30-2006 at 01:45 AM
RE: My first script. - by Menthix on 11-30-2006 at 01:50 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