
[Help] Code - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Help] Code (/showthread.php?tid=66051)
[Help] Code by Eddie on 09-10-2006 at 03:38 PM
How come this isnt working
quote: Originally posted by Code
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin, Message, MessageKind)
{
if (Message.match(Hello)!=null)
{
ChatWnd.SendMessage(hi);
}
also just tried
quote: Originally posted by Code
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin, Message, MessageKind)
{
if (Message.match(Hello)!=null)
ChatWnd.SendMessage(hi);
}
Ive done it before i just cant remember exactly how 
And Plus Live accepted it but it didnt work when my contact said Hello
RE: [Help] Code by absorbation on 09-10-2006 at 03:41 PM
You left out a curly bracket 
OK, I see your edit now:
code: function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin, Message, MessageKind)
{
if (Message == 'Hello')
{
ChatWnd.SendMessage('hi');
}
}
Edit: Damn MyBB RC2 for not indenting the code
RE: [Help] Code by Eddie on 09-10-2006 at 03:41 PM
Whered i forget a curly bracket?
RE: [Help] Code by Eddie on 09-10-2006 at 03:48 PM
quote: Originally posted by absorbation
You left out a curly bracket 
OK, I see your edit now:
code: function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin, Message, MessageKind)
{
if (Message == 'Hello')
{
ChatWnd.SendMessage('hi');
}
}
Edit: Damn MyBB RC2 for not indenting the code 
Still didnt send it to my contact 
RE: [Help] Code by Felu on 09-10-2006 at 03:58 PM
code: function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
if(Message == 'Hello')
{
ChatWnd.SendMessage('Hi')
}
}
Looks same but this one works .
RE: [Help] Code by Eddie on 09-10-2006 at 04:00 PM
quote: Originally posted by -!Felu!-
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
if(Message == 'Hello' && Origin != Messenger.MyName)
{
ChatWnd.SendMessage('Hi')
}
}
Thanks buddy that works!
RE: [Help] Code by Matti on 09-10-2006 at 04:45 PM
The problems were:
- Message.match only accepts a regular expression as parameter (e.g.: /Hello/i), where your script had an undefined variable Hello
- you tried to send an undefined variable hi to the chat window
- the script would respond on both your and the contacts messages
So, a solution when you really want to use regular expression would be:
code: function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
if(Message.match(/hello/i) && Origin != Messenger.MyName)
{
ChatWnd.SendMessage('Hi')
}
}
But if you don't need regular expressions, you can just keep -!Felu!-'s version.
RE: [Help] Code by vladinator on 09-25-2006 at 06:48 PM
Il use this topic to continue my topic from here:
http://www.mpscripts.net/showthread.php?tid=79
Reason I post here is since you already started the begining of the problem, and il just continue it. 
Now this is the code I managed to make:
code: function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
//Help text
if( Message.match(/!help/i) )
{
ChatWnd.SendMessage('!help = Show this text. !song = Show the song im listening to. !sendsong = Send you the song im listening to.')
}
//Song name
if( Message.match(/!song/i) )
{
ChatWnd.SendMessage('/np')
}
//Send Song
if( Message.match(/!sendsong/i) )
{
ChatWnd.SendMessage('/sendsong')
}
}
But there are a few problems.
1) When you !help it spams it alot.
2) If you say !help in the middle of a sentence, it still works.
3) If you use !help and the !help contains !song and !sendsong it registers it and you get a loop of the commands.
Also I would like to know how to make a new line for the help thingy, so I can separate. And simply make it only work if its in the begining of the message and only the command, nothing else behind or before. Thats simply what I need to fix and this code will work like a dream. ^^ (and remove loop /cry)
RE: [Help] Code by Eljay on 09-25-2006 at 07:09 PM
quote: Originally posted by vladinator
1) When you !help it spams it alot.
2) If you say !help in the middle of a sentence, it still works.
3) If you use !help and the !help contains !song and !sendsong it registers it and you get a loop of the commands.
use a regular expression such as:
/^!command$/i
the ^ means the expression should only match strings starting at the beginning of the message
the $ means the same but for the end
or you could just use plain text match such as:
if(Message == '!song')....
but it wouldnt be case insensitive then...
RE: [Help] Code by Shondoit on 09-25-2006 at 07:20 PM
And also check if he send the command or you did...
(That's why it was looping)
Mattike already pointed this out
code: function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
if(Message.match(/hello/i) && Origin != Messenger.MyName)
{
ChatWnd.SendMessage('Hi')
}
}
RE: RE: [Help] Code by vladinator on 09-25-2006 at 07:32 PM
Shondoit: Thanks, I managed to forget to include that.
Eljay: Genious.
Both: Genious.
RE: [Help] Code by DennisMartijn on 10-06-2006 at 05:07 PM
''ChatWnd,Origin,''
a quote from a post, saying it still doenst work, reason why the second same looking one did work: !a space between the , and Origin. !
RE: [Help] Code by Matti on 10-06-2006 at 05:10 PM
quote: Originally posted by DennisMartijn
''ChatWnd,Origin,''
a quote from a post, saying it still doenst work, reason why the second same looking one did work: !a space between the , and Origin. !
There is no need for spaces between parameters in a function declaration or call, but it makes the code look cleaner. And please don't bring topics back with no replies since a month ago...
RE: [Help] Code by vladinator on 10-07-2006 at 07:30 PM
Sorry for replying but im e-mailed on replies. Anyway reason I posted to begin with was to keep the board most clean. Got used to it when 90% of all online forums says "use the search button before posting". Tough same rule is on the msghelp.net forums. 
Anyway I personally have completed my code and it is working, thank you.
|