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: 1622
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
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Solved] What is wrong with my script? - by markee on 07-13-2006 at 08:36 AM
RE: [Help] What is wrong with my script? - by -dt- on 07-13-2006 at 08:52 AM
RE: RE: [Help] What is wrong with my script? - by markee on 07-13-2006 at 09:22 AM
RE: [Help] What is wrong with my script? - by markee on 07-14-2006 at 05:24 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