why won't this work? |
Author: |
Message: |
Jimbo
Veteran Member
Posts: 1650 Reputation: 18
32 / /
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 |
|
|
markee
Veteran Member
Posts: 1622 Reputation: 50
36 / /
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
|
|
10-19-2006 04:25 PM |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
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 |
|
|
Shondoit
Full Member
Hmm, Just Me...
Posts: 227 Reputation: 15
36 / /
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.
|
|
10-19-2006 04:26 PM |
|
|
Jimbo
Veteran Member
Posts: 1650 Reputation: 18
32 / /
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 |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
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 .
|
|
10-19-2006 04:28 PM |
|
|
Jimbo
Veteran Member
Posts: 1650 Reputation: 18
32 / /
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 .
ok, thanks
|
|
10-19-2006 04:31 PM |
|
|
Ezra
Veteran Member
Forgiveness is between them and God
Posts: 1960 Reputation: 31
37 / /
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.
|
|
10-19-2006 04:43 PM |
|
|
Jimbo
Veteran Member
Posts: 1650 Reputation: 18
32 / /
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 |
|
|
|