What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » why won't this work?

why won't this work?
Author: Message:
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
31 / Male / Flag
Joined: Jul 2006
O.P. why won't this work?
why won't this work?
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
if (Message.substr(0, 6) == "bye"){
return'/signout'
}
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
if (Message.substr(0, 6) == "away"){
return'/away'
}
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
if (Message.substr(0, 6) == "back"){
return'online'

10-19-2006 04:22 PM
Profile E-Mail PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
Joined: Jan 2006
RE: why won't this work?
Its because you cant have more than one functioned named the one thing unless they are local functions
[Image: markee.png]
10-19-2006 04:25 PM
Profile PM Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
29 / Male / Flag
Joined: Apr 2006
Status: Away
RE: why won't this work?
You can use OnEvent_ChatWndSendMessage only once... so
code:

function OnEvent_ChatWndSendMessage(ChatWnd, Message){
if (Message.substr(0, 3)== "bye"){
return'/signout'
}
if (Message.substr(0, 4) == "away"){
return'/away'
}
if (Message.substr(0, 4) == "back"){
return'online'
}
}
should work.


Also message.substr was used in the wrong way

This post was edited on 10-19-2006 at 04:27 PM by Felu.
10-19-2006 04:25 PM
Profile E-Mail PM Web Find Quote Report
Shondoit
Full Member
***

Avatar
Hmm, Just Me...

Posts: 227
Reputation: 15
35 / Male / Flag
Joined: Jul 2006
RE: why won't this work?
It would work but you can only have one function with a specified name, so you have to put all options together, like this:
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
   if (Message.substr(0, 6) == "bye"){
      return'/signout'
   }else if (Message.substr(0, 6) == "away"){
      return'/away'
   } else if (Message.substr(0, 6) == "back"){
      return '/online'
   }
}

Edit: Beaten by Felu

This post was edited on 10-19-2006 at 04:26 PM by Shondoit.
My scripts:                            [Image: shondoit.gif]
+ Timezone
+ Camelo
+ Multisearch
10-19-2006 04:26 PM
Profile PM Find Quote Report
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
31 / Male / Flag
Joined: Jul 2006
O.P. RE: why won't this work?
lol, thanks everyone. they were very fast replys
10-19-2006 04:27 PM
Profile E-Mail PM Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
29 / Male / Flag
Joined: Apr 2006
Status: Away
RE: why won't this work?
quote:
Originally posted by JimboDude
lol, thanks everyone. they were very fast replys
Please see my edit. You were using Message.substr the wrong way [Image: msn_tongue.gif].
10-19-2006 04:28 PM
Profile E-Mail PM Web Find Quote Report
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
31 / Male / Flag
Joined: Jul 2006
O.P. RE: why won't this work?
quote:
Originally posted by -!Felu!-
quote:
Originally posted by JimboDude
lol, thanks everyone. they were very fast replys
Please see my edit. You were using Message.substr the wrong way [Image: msn_tongue.gif].
ok, thanks
10-19-2006 04:31 PM
Profile E-Mail PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: why won't this work?
Also why return a command if you can do it directly with the script?

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
  if (Message.match(/^bye$/i) != null)
  {
    Messenger.Signout();
    return "";
  }
  else if (Message.match(/^away$/i) != null)
  {
    Messenger.MyStatus = 7; //Set status to Away;
    return "";
  }
  else if (Message.match(/^back$/i) != null)
  {
    if (ChatWnd.EditChangeAllowed)
    {
      return "Online";
    }
    else
    {
      Debug.Trace("Could not return a value");
      return "";
    }
  }
  else
  {
    if (ChatWnd.EditChangeAllowed)
    {
      return Message;
    }
    else
    {
      Debug.Trace("Could not return a value");
      return "";
    }
  }
}

Uses the direct functions and uses regex to compare the Message.

EDIT:

AND it returns the complete Message if anything else was said ;)

This post was edited on 10-19-2006 at 04:49 PM by Ezra.
[Image: 1-0.png]
             
10-19-2006 04:43 PM
Profile PM Web Find Quote Report
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
31 / Male / Flag
Joined: Jul 2006
O.P. RE: why won't this work?
quote:
Originally posted by Ezra
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
if (Message.substr(0, 3)== "bye"){
return'/signout'
}
if (Message.substr(0, 4) == "away"){
return'/away'
}
if (Message.substr(0, 4) == "back"){
return'online'
}
}
ok, but wouldn't this code still work by !felu!
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
if (Message.substr(0, 3)== "bye"){
return'/signout'
}
if (Message.substr(0, 4) == "away"){
return'/away'
}
if (Message.substr(0, 4) == "back"){
return'online'
}
}

10-19-2006 04:44 PM
Profile E-Mail 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