What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Two questions: !remotecommand and Messenger.MyContacts

Pages: (2): « First [ 1 ] 2 » Last »
Two questions: !remotecommand and Messenger.MyContacts
Author: Message:
kaourika
Junior Member
**


Posts: 16
Reputation: 1
34 / Female / –
Joined: Jul 2006
O.P. Two questions: !remotecommand and Messenger.MyContacts
I don't know JS at all, so as a learning experience I just started throwing things together, and naturally I've run into some questions.

First question
The following code works fine when I type !whatevercommand, but I also want my contacts to be able to type !whatevercommand, have the script respond to them, and increment the nbrPoke++.

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
... there was a lot more in here; I'm just including the relevent stuff...
code:
        if(Message.substr(0,5).toLowerCase()=="!poke"){
        nbrPoke++;
        var z = Math.floor((Math.random()*(xArray.length-1)));
        return "*" + Messenger.MyName + " pokes with a pointy stick* \n" +xArray[z];
    }

Any tips on doing what I need to do? :D

Second question
I can't understand Messenger.MyContacts. For example, here,
code:
aArray[6] = "*" + Messenger.MyName +" attacks " + Messenger.MyContacts + "*";
MyName works fine, but Contacts just produces a blank space.
I read in the documentation that this could happen due to the contact being logged out, but that wasn't the case here.

Thanks for any help :D
12-11-2007 08:05 PM
Profile E-Mail PM Web Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
Joined: Jan 2006
RE: Two questions: !remotecommand and Messenger.MyContacts
for your first question, you should use the function OnEvent_ChatWndReceivedMessage(ChatWnd,Origin,Msg,Kind){

as for the second question, Messenger.MyContacts isn't a string so it doesn't work like that.  You need to do
code:
Messenger.MyContacts.GetContact("put their email here").Name
to return their display name (which i think is what you want).
[Image: markee.png]
12-12-2007 09:01 AM
Profile PM Find Quote Report
kaourika
Junior Member
**


Posts: 16
Reputation: 1
34 / Female / –
Joined: Jul 2006
O.P. RE: Two questions: !remotecommand and Messenger.MyContacts
Thanks for the help, Markee. =)

I tried putting in function OnEvent_ChatWndReceivedMessage(ChatWnd,Origin,Msg,Kind){ instead, and after doing so, that part of the script completely stops working(!command will simply show up as !command, for both sides of the conversation).
I figured it must be a conflict with some other part of my script, so I systematically removed all of those other parts, and tested without each one, but it didn't fix the problem.

Here is the relevent code section:
code:
    //// Actions
function OnEvent_ChatWndReceivedMessage(ChatWnd,Origin,Msg,Kind){
        if(Message.substr(0,8).toLowerCase()=="!petrafi"){
        nbrPet++;
        var h = Math.floor((Math.random()*(dArray.length-1)));
        return "*" + Messenger.MyName + " pets Rafeal* \n" +dArray[h];
    }
    }
    //// End Actions

There were more !commands, but I temporarily removed them so they wouldn't complicate my diagnosis. Anyway, I can't seem to find the problem with it =/

The display name was indeed what I was after. :D However, with that code, won't it only work with one person, the person whose email I define? If it's possible and not too horribly complex, I was trying to make the script adapt to whoever I was talking to at the time.
12-13-2007 12:31 AM
Profile E-Mail PM Web Find Quote Report
ddunk
Veteran Member
*****

Avatar

Posts: 1228
Reputation: 51
35 / Male / Flag
Joined: Mar 2004
RE: Two questions: !remotecommand and Messenger.MyContacts
There's a couple problems.

First off, the event is "onEvent_ChatWndReceiveMessage" rather than "onEvent_ChatWndReceivedMessage".

Also, you have
code:
function OnEvent_ChatWndReceivedMessage(ChatWnd,Origin,Msg,Kind){
if(Message.substr(0,8).toLowerCase()=="!petrafi"){
So "Message" is undefined. So either change "Message" to "Msg" or "Msg" to "Message" and that part of the code should be just fine. :)
12-13-2007 12:40 AM
Profile E-Mail PM Web Find Quote Report
kaourika
Junior Member
**


Posts: 16
Reputation: 1
34 / Female / –
Joined: Jul 2006
O.P. RE: Two questions: !remotecommand and Messenger.MyContacts
Ah! Thank you!! Now the script is actually attempting a return instead of just displaying the raw !command. I'm glad I don't have to go searching other chunks of the code for the problem.
However, it seems there's still something wrong here... D:
As you suggested, I changed it to
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,Kind){

        if(Message.substr(0,8).toLowerCase()=="!petrafi"){
        nbrPet++;
        var h = Math.floor((Math.random()*(dArray.length-1)));
        return "*" + Messenger.MyName + " pets Rafeal* \n" +dArray[h];
    }
But now it attempts to shave the response to 8 characters, I guess because of "(Message.substr(0,8)"... This is the return I'm getting in the conversation window (My name right now being Kao):
quote:
Kao says:
*Kao pet

It didn't have that problem when I was using "function OnEvent_ChatWndSendMessage." The Message.substr(0,8) is just supposed to apply to the raw !command, not the return, so that's weird...

Also, for my contact, when they say !petrafi, it executes the script in my view of the conversation, but in theirs, it still just says !petrafi. I hope there's a way around that! =/

Thanks for the continuing help! :3

This post was edited on 12-13-2007 at 01:21 AM by kaourika.
12-13-2007 01:19 AM
Profile E-Mail PM Web Find Quote Report
pollolibredegrasa
Full Member
***

Avatar
formerly fatfreechicken

Posts: 483
Reputation: 34
35 / Male / Flag
Joined: May 2005
RE: Two questions: !remotecommand and Messenger.MyContacts
I think the problem is that the message you return in the ChatWndReceiveMessage event cannot be longer than the original message, or it just gets truncated. There's no way round this to my knowledge I'm afraid, as it's a technical limitation of Plus.
;p

[Image: chickennana.gif] Vaccy is my thin twin! [Image: chickennana.gif]
12-13-2007 01:29 AM
Profile PM Find Quote Report
kaourika
Junior Member
**


Posts: 16
Reputation: 1
34 / Female / –
Joined: Jul 2006
O.P. RE: Two questions: !remotecommand and Messenger.MyContacts
...Crap. :|

So... If I just want both people in a conversation to be able to type !command, and have text return based on that... there's really no way at all to do that? Or am I just trying to go about it in the wrong way?

Argh D: *pulls hair*
12-13-2007 01:44 AM
Profile E-Mail PM Web Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: Two questions: !remotecommand and Messenger.MyContacts
quote:
Originally posted by kaourika
...Crap. :|

So... If I just want both people in a conversation to be able to type !command, and have text return based on that... there's really no way at all to do that? Or am I just trying to go about it in the wrong way?

Argh D: *pulls hair*

when you return from "chatwndreceivemessage", you're editing their text as it appears to you, not sending another message back to them.
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
12-13-2007 01:46 AM
Profile PM Web Find Quote Report
kaourika
Junior Member
**


Posts: 16
Reputation: 1
34 / Female / –
Joined: Jul 2006
O.P. RE: Two questions: !remotecommand and Messenger.MyContacts
Ah! Okay, I understand, thank you.

Then there should be a way to edit the text as it's being sent, so just the end edited result appears to both contacts? Like how Quick Texts work.
12-13-2007 01:55 AM
Profile E-Mail PM Web Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: Two questions: !remotecommand and Messenger.MyContacts
quote:
Originally posted by kaourika
Ah! Okay, I understand, thank you.

Then there should be a way to edit the text as it's being sent, so just the end edited result appears to both contacts? Like how Quick Texts work.

yes, whatever you return from "chatwndsendmessage" will change the message being sent, and whatever you return from "chatwndreceivemessage" will change the message being received.

what you want to do is send a new message altogether from within "chatwndreceivemessage", not return anything.
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
12-13-2007 02:31 AM
Profile PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« 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