What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » adding a counter to my script.

adding a counter to my script.
Author: Message:
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: adding a counter to my script.
You can better just only add the registry reading to OnEvent_Signin, that will always work because initialize usually won't know the uid yet, and only write out count on OnEvent_Signout, that will cut down on a lot of registry writing, and errors when initializing:

EDIT: Added Initialize too, now it will also read the correct number when resetting the script.

code:

var RaadselId = Array();
var teller = 0;

function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
{
  var Message=Message.toLowerCase();

  if (MessageKind == 1 && Message.substr(1,4) == "druk")
  {
    var ranNum = Math.floor(Math.random() * Raadsel.length);
    RaadselId[ChatWnd.handle] = ranNum;
    ChatWnd.SendMessage(Raadsel[ranNum]);
    teller++;
  }

  if(MessageKind == 1 && Message.substr(0,7) == "ik wens" || Message.substr(0,8) == "antwoord" || Message.substr(1,9) == "antwoord")
  {
    ChatWnd.SendMessage(Antwoord[RaadselId[ChatWnd.handle]]);
  }
}

function OnEvent_Initialize(MessengerStart)
{
  if (!MessengerStart)
  {
    if (Messenger.MyStatus != 0)
    {
      OnEvent_Singin(Messenger.MyEmail);
    }
  }
}

function OnEvent_Signin(Email)
{
  try
  {
    count = ReadRegistry("count");
  }
  catch(e)
  {
    Debug.Trace("Reading Settings Failed, Defaulting to zero");
    count = 0;
  }
}

function OnEvent_Signout(Email)
{
  try
  {
    WriteRegistry("count", count, "REG_DWORD");
  }
  catch(e)
  {
    Debug.Trace("Writing to Registry Failed, Settings could not be saved");
  }
}
   
function WriteRegistry(key, value, type)
{
  if (type == undefined){ type = "REG_SZ"; }
  var Shell = new ActiveXObject("WScript.Shell");
  return Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\" + key, value, type);
}

function ReadRegistry(key)
{
  var Shell = new ActiveXObject("WScript.Shell");
  return Shell.RegRead(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\" + key);
}

This post was edited on 08-17-2006 at 05:11 PM by Ezra.
[Image: 1-0.png]
             
08-17-2006 05:07 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
adding a counter to my script. - by laurenz on 08-17-2006 at 03:22 PM
RE: adding a counter to my script. - by Matti on 08-17-2006 at 03:38 PM
RE: adding a counter to my script. - by laurenz on 08-17-2006 at 03:48 PM
RE: adding a counter to my script. - by Ezra on 08-17-2006 at 05:07 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