What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Solved] What is wrong with my script?

[Solved] What is wrong with my script?
Author: Message:
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
O.P. Huh?  [Solved] What is wrong with my script?
Can someone please tell me what's wrong with this script.  It is meant to make your text a gradient for the people you select.  It also uses the commands /colour1 /colour2 for the colours of the gradient and /contact to be able to send the gradient to that contact and /contactdelete to remove the contaact from being able to receive the gradient text.  It is also not meant to work when you are writing a command but work when you have "//" at the begining of your message.  Thanks in advance.

code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
  var ChatWndContacts = ChatWnd.Contacts;
  if(ChatWndContacts.Count == 1)
  {
    var e = new Enumerator(ChatWndContacts);
    var Contact = e.item();
    var WSH = new ActiveXObject('WScript.Shell');
    try
    {
      WSH.RegRead(MsgPlus.ScriptRegPath + Contact.Email);
      Debug.Trace(MsgPlus.ScriptRegPath + "numberofpies exists.");
      var WSH = new ActiveXObject('WScript.Shell');
      colour1no = WSH.RegRead(MsgPlus.ScriptRegPath + "colour1");
      var WSH = new ActiveXObject('WScript.Shell');
      colour2no = WSH.RegRead(MsgPlus.ScriptRegPath + "colour2");
      if (Message.charAt(0) == '/')
      {
        if(Message.charAt(1) == '/')
        {
          ChatWnd.SendMessage("[c" + colour1no + "]" + Message + "[/c=" + colour2no + "]");
        }
        return Message;
      }
      ChatWnd.SendMessage("[c" + colour1no + "]" + Message + "[/c=" + colour2no + "]");
    }
    catch (e)
    {
    Debug.Trace(MsgPlus.ScriptRegPath + "numberofpies doesnt exists.");
    ChatWnd.SendMessage(Message)
    }
  }
  Debug.Trace(MsgPlus.ScriptRegPath + "number of contacts more than one");
}
function OnEvent_ChatWndSendMessage(ChatWnd, sMessage) {

    if(sMessage.charAt(0) == "/"){
        return parseCommands(sMessage,ChatWnd);
    }
}
function parseCommands(sMessage,ChatWnd){
  var ChatWndContacts = ChatWnd.Contacts;
  if(ChatWndContacts.Count == 1)
  {
    var e = new Enumerator(ChatWndContacts);
    var Contact = e.item();
    if (sMessage.charAt(0) == '/'){
        if(sMessage.charAt(1) == '/'){
            return sMessage;
        } else {
            var firstSpace = sMessage.search(' ');
            if(firstSpace == -1){
                var command = sMessage.toLowerCase().substr(1);
                var params = '';
            } else {
                var command = sMessage.toLowerCase().substr(1, firstSpace-1);
                var params = sMessage.substr(firstSpace+1);
            }
            if(params != "") { Debug.Trace("The command \"" + command + "\" with the parameters \"" + params + "\" has been parsed."); }
            else { Debug.Trace("The command \"" + command + "\" has been parsed."); }
            switch(command) {
                case 'colour1':
                    var colour1no = params
                    {
                      new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + "colour1",colour1no);
                    }
                    sMessage = '';
                    break;
                case 'colour2':
                    var colour2no = params
                    {
                      new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + "colour2",colour2no);
                    }
                    sMessage = '';
                    break;
                case 'contact':
                    var Message = params
                    {
                      new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Contact.Email,Message);
                    }
                    sMessage = '';
                    break;
                case 'contactdelete':
                    {
                      new ActiveXObject('WScript.Shell').RegDelete(MsgPlus.ScriptRegPath + Contact.Email);
                    }
                    sMessage = '';
                    break;
                default:
            }
        }
    }
    return sMessage;
}
}
function OnGetScriptCommands()
{
    var commands = '<ScriptCommands>';
        commands+='<Command>';
            commands+='<Name>colour1</Name>';
            commands+='<Description>'+"First colour for gradient"+'</Description>';
            commands+='<Parameters>Message</Parameters>';
        commands+='</Command>';
        commands+='<Command>';
            commands+='<Name>colour2</Name>';
            commands+='<Description>'+"Second colour for gradient"+'</Description>';
            commands+='<Parameters>Message</Parameters>';
        commands+='</Command>';
        commands+='<Command>';
            commands+='<Name>contact</Name>';
            commands+='<Description>'+"Add contact to receive gradient message list"+'</Description>';
            commands+='<Parameters>Message</Parameters>';
        commands+='</Command>';
        commands+='<Command>';
            commands+='<Name>contactdelete</Name>';
            commands+='<Description>'+"Remove contact from receive gradient list"+'</Description>';
            commands+='<Parameters>Message</Parameters>';
        commands+='</Command>';
    commands+='</ScriptCommands>';
    return commands;
}


Edit: you must also set the colours and a contact before being able to use the script properly

This post was edited on 07-14-2006 at 05:25 AM by markee.
[Image: markee.png]
07-13-2006 08:36 AM
Profile PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: [Help] What is wrong with my script?
quote:
Originally posted by shoutbox

<-dt-> :-/ you know you dont have to redeclare "WScript.Shell" each time
<-dt-> just assign it to a variable and use it :sad:
<-dt-> also wtf at the OnGetScriptCommands xml ... :/ why are you adding two strings together....just use one
<-dt-> also ChatWnd.SendMessage("[c" + colour1no + "]" + Message + "[/c=" + colour2no + "]"); , the first one you're missing an =


also

code:
17          if (Message.charAt(0) == '/')
18          {
19            if(Message.charAt(1) == '/')


err? so they enter // for it to work?

This post was edited on 07-13-2006 at 08:53 AM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
07-13-2006 08:52 AM
Profile PM Web Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
O.P. RE: RE: [Help] What is wrong with my script?
quote:
Originally posted by -dt-
quote:
Originally posted by shoutbox

<-dt-> :-/ you know you dont have to redeclare "WScript.Shell" each time
<-dt-> just assign it to a variable and use it :sad:
<-dt-> also wtf at the OnGetScriptCommands xml ... :/ why are you adding two strings together....just use one
<-dt-> also ChatWnd.SendMessage("[c" + colour1no + "]" + Message + "[/c=" + colour2no + "]"); , the first one you're missing an =


also

code:
17          if (Message.charAt(0) == '/')
18          {
19            if(Message.charAt(1) == '/')


err? so they enter // for it to work?


Ok, well I fixed everything you said apart from changing the script commands to an .xml file, I just kept them in the script like I had before.  I also added "else" in a couple of places that I realised I was missing from you pointing it out.  I'm still having troubles with the sending the message part, I made sure that it saved to the regestry and I added the Debug.Trace 's before and none of them seem to be triggering either.

Here's what the code looks like now

code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
  var ChatWndContacts = ChatWnd.Contacts;
  if(ChatWndContacts.Count == 1)
  {
    var e = new Enumerator(ChatWndContacts);
    var Contact = e.item();
    var WSH = new ActiveXObject('WScript.Shell');
    try
    {
      WSH.RegRead(MsgPlus.ScriptRegPath + Contact.Email);
      Debug.Trace(MsgPlus.ScriptRegPath + "numberofpies exists.");
      colour1no = WSH.RegRead(MsgPlus.ScriptRegPath + "colour1");
      colour2no = WSH.RegRead(MsgPlus.ScriptRegPath + "colour2");
      if (Message.charAt(0) == '/')
      {
        if(Message.charAt(1) == '/')
        {
          ChatWnd.SendMessage("[c=" + colour1no + "]" + Message + "[/c=" + colour2no + "]");
        }
        else
        {
          return Message;
        }
      }
      else
      {
        ChatWnd.SendMessage("[c=" + colour1no + "]" + Message + "[/c=" + colour2no + "]");
      }
    }
    catch (e)
    {
    Debug.Trace(MsgPlus.ScriptRegPath + "numberofpies doesnt exists.");
    ChatWnd.SendMessage(Message)
    }
  }
  Debug.Trace(MsgPlus.ScriptRegPath + "number of contacts more than one");
}
function OnEvent_ChatWndSendMessage(ChatWnd, sMessage) {

    if(sMessage.charAt(0) == "/"){
        return parseCommands(sMessage,ChatWnd);
    }
}
function parseCommands(sMessage,ChatWnd){
  var ChatWndContacts = ChatWnd.Contacts;
  if(ChatWndContacts.Count == 1)
  {
    var e = new Enumerator(ChatWndContacts);
    var Contact = e.item();
    if (sMessage.charAt(0) == '/'){
        if(sMessage.charAt(1) == '/'){
            return sMessage;
        } else {
            var firstSpace = sMessage.search(' ');
            if(firstSpace == -1){
                var command = sMessage.toLowerCase().substr(1);
                var params = '';
            } else {
                var command = sMessage.toLowerCase().substr(1, firstSpace-1);
                var params = sMessage.substr(firstSpace+1);
            }
            if(params != "") { Debug.Trace("The command \"" + command + "\" with the parameters \"" + params + "\" has been parsed."); }
            else { Debug.Trace("The command \"" + command + "\" has been parsed."); }
            switch(command) {
                case 'colour1':
                    var colour1no = params
                    {
                      new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + "colour1",colour1no);
                    }
                    sMessage = '';
                    break;
                case 'colour2':
                    var colour2no = params
                    {
                      new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + "colour2",colour2no);
                    }
                    sMessage = '';
                    break;
                case 'contact':
                    var Message = params
                    {
                      new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Contact.Email,Message);
                    }
                    sMessage = '';
                    break;
                case 'contactdelete':
                    {
                      new ActiveXObject('WScript.Shell').RegDelete(MsgPlus.ScriptRegPath + Contact.Email);
                    }
                    sMessage = '';
                    break;
                default:
            }
        }
    }
    return sMessage;
}
}
function OnGetScriptCommands()
{
    var commands = '<ScriptCommands>';
        commands+='<Command>';
            commands+='<Name>colour1</Name>';
            commands+='<Description>'+"First colour for gradient"+'</Description>';
            commands+='<Parameters>Message</Parameters>';
        commands+='</Command>';
        commands+='<Command>';
            commands+='<Name>colour2</Name>';
            commands+='<Description>'+"Second colour for gradient"+'</Description>';
            commands+='<Parameters>Message</Parameters>';
        commands+='</Command>';
        commands+='<Command>';
            commands+='<Name>contact</Name>';
            commands+='<Description>'+"Add contact to receive gradient message list"+'</Description>';
            commands+='<Parameters>Message</Parameters>';
        commands+='</Command>';
        commands+='<Command>';
            commands+='<Name>contactdelete</Name>';
            commands+='<Description>'+"Remove contact from receive gradient list"+'</Description>';
            commands+='<Parameters>Message</Parameters>';
        commands+='</Command>';
    commands+='</ScriptCommands>';
    return commands;
}


I hope you can find what the problem is.
[Image: markee.png]
07-13-2006 09:22 AM
Profile PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
O.P. RE: [Help] What is wrong with my script?
Ok well I've worked out what I've done wrong. Thanks for the help anyway.
[Image: markee.png]
07-14-2006 05:24 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


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