Shoutbox

hmm a problem... - 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: hmm a problem... (/showthread.php?tid=64429)

hmm a problem... by uggi on 08-03-2006 at 05:11 PM

when i use the OnEvent_ChatWndReceiveMessage function to send a command to my script, fx. "!popup" it runs the code as normal, but if i send the script to a friend and he runs it and write the same command in a chat window to me, then my script run on both computers.. how can i stop that.. ??

some of my code:

quote:
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
{
    if(MessageKind == 1)
    {
if(Message.substr(0,7) == '!popup ') {
    var naam = Origin.substr(0,16);
    if(Message.substr(7) == '') {
        var Text = "You need to post a message after !popup..";
        ChatWnd.SendMessage(Text);
    } else {
        var Text = Message.substr(7);
        ext = MsgPlus.RemoveFormatCodes(Text);
        MsgPlus.DisplayToast("",Text);
    }
}
    }
}

RE: hmm a problem... by rob_botch on 08-04-2006 at 09:29 AM

The ChatWndReceiveMessage event is triggered when any message appears in the chat window. This includes messages that you yourself send. If you are trying to get the popup to appear on your contact's side, then you need to filter out messages from you. You can do this by either checking the Origin against your nickname, or by enumerating the contacts in the chat. Unfortunately, neither method is 100% accurate, because Plus! only receives the nickname of the sender, not the email address or UID.

If you want the popup to only show on your side, change the event to ChatWndSendMessage.

I hope this helps

Robert


RE: RE: hmm a problem... by uggi on 08-04-2006 at 10:14 AM

quote:
Originally posted by rob_botch
The ChatWndReceiveMessage event is triggered when any message appears in the chat window. This includes messages that you yourself send. If you are trying to get the popup to appear on your contact's side, then you need to filter out messages from you. You can do this by either checking the Origin against your nickname, or by enumerating the contacts in the chat. Unfortunately, neither method is 100% accurate, because Plus! only receives the nickname of the sender, not the email address or UID.

If you want the popup to only show on your side, change the event to ChatWndSendMessage.

I hope this helps

Robert


Thanks, but if i want to use my friends script, on the pc that he is using, i need to send the command in ChatWndReceiveMessage right ?

Or can i make it so then i send a command to him, the only script that response to the command is on that pc and not on my own pc...

( sry for the language.. )
RE: hmm a problem... by mlevit on 08-04-2006 at 10:21 AM

Uggi if im getting this right, you want to access a script on his computer.

What you can do, is create another command to activate the script in ChatWndReceiveMessage.

You use !popup for your computer, and say !!popup for his computer.


RE: hmm a problem... by RaceProUK on 08-04-2006 at 10:29 AM

Why are people suggesting solutions that won't help?

quote:
Originally posted by rob_botch
You can do this by either checking the Origin against your nickname
is what the guy needs.
RE: hmm a problem... by uggi on 08-04-2006 at 10:45 AM

rob_botch, mlevit, RaceProUK: ( and others.. )

If you look in my script, i only have one command, the "!popup", i use it to let my contacts write a message in a popup to me...

Now, i sent it to my friend, so it runs on both computers, if he write "!popup hello" to me, i see a popup on my screen, AND he see it on the screen he use.

The only problem is that i donīt want the script to show the popup on the computer the command is used on, but only the other computer.

Is there a function/event/anything to do that or not ?

and btw RaceProUK:

negativity is maybe also a problem huh...


RE: hmm a problem... by RaceProUK on 08-04-2006 at 10:51 AM

You have read the thread yes?

quote:
Originally posted by RaceProUK
quote:
Originally posted by rob_botch
You can do this by either checking the Origin against your nickname
is what the guy needs.

RE: RE: hmm a problem... by uggi on 08-04-2006 at 12:22 PM

quote:
Originally posted by RaceProUK
You have read the thread yes?
quote:
Originally posted by RaceProUK
quote:
Originally posted by rob_botch
You can do this by either checking the Origin against your nickname
is what the guy needs.


Yes, i have read your tread, BUT this is not the way to do it, because i change my nickname 2 times a day..and... i'm not the only one that use the script...
RE: hmm a problem... by RaceProUK on 08-04-2006 at 12:25 PM

Gah, you really don't understand this do you? How can I make it obvious?
I know: Messenger.MyName.

And before you have a go at me for acting like this, it's only because you're causing me frustration since you seem unable to grasp the very simple concept I'm trying to get across.

In fact, sod it, I'll make it plain and simple.

if (Origin != Messenger.MyName) {
    // Do shit
}


RE: RE: hmm a problem... by uggi on 08-04-2006 at 12:42 PM

quote:
Originally posted by RaceProUK
Gah, you really don't understand this do you? How can I make it obvious?
I know: Messenger.MyName.

And before you have a go at me for acting like this, it's only because you're causing me frustration since you seem unable to grasp the very simple concept I'm trying to get across.

In fact, sod it, I'll make it plain and simple.

if (Origin != Messenger.MyName) {
    // Do shit
}


just forget this... you donīt understand what i want it to do... (N)

your behaviour and mood is rather than good...

Forget this question...
RE: hmm a problem... by mlevit on 08-04-2006 at 12:58 PM

Uggi i think i might have got it.

code:
var sendingMessage = "";

function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    sendingMessage = Message;
    return Message;
}

function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
{
    if (Message == sendingMessage)
    {
        //Do nothing
    }
    else
    {
        //Your code here
    }
}
Im not sure but i think this is what you're trying to achive?

What this will do, is check if the message received in the chat window didn't come from you. Obviously if it did, then !popup would't work else if its from someone else it would.

I do think that RaceProUK is right too, you check the Origin of the message against your name, if its from you dont do anything else do stuff.

Not sure, this is what we are getting from your posts.
RE: hmm a problem... by RaceProUK on 08-04-2006 at 01:49 PM

quote:
Originally posted by uggi
you donīt understand what i want it to do
You want the script to trigger on your contact's machine only. If that's wrong, then please explain why.
quote:
Originally posted by mlevit
Uggi i think i might have got it.
code:
var sendingMessage = "";

function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    sendingMessage = Message;
    return Message;
}

function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
{
    if (Message == sendingMessage)
    {
        //Do nothing
    }
    else
    {
        //Your code here
    }
}
Im not sure but i think this is what you're trying to achive?
It is, but it's an ugly way to do it. The better (and documented) way is:
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
{
    if (Origin != Messenger.MyName) // Rejects your own messages
    {
        // Do stuff here
    }
}
This code block will only respond to the command if it was sent by someone other than yourself. This test is suggested in the Plus! documentation (and quoted several times above), and given you always compare the Origin to your current display name, it should be practically faultless.
I've also taken the liberty of simplifying the if{} construct to remove the unnecessary else {} clause.

There's only one thing that will bring this solution down: if your contact has the same display name as you. Which, let's face it, is very rare.
quote:
Originally posted by uggi
your behaviour and mood is rather than good
I just get frustrated when I'm making things clear, yet people don't get it. Well, I've now posted a full code sample, so hopefully it's irrevocably clear now [Image: msn_wink.gif]
quote:
Originally posted by uggi
Forget this question
No :P
RE: hmm a problem... by uggi on 08-04-2006 at 02:36 PM

RaceProUK >>

You are a very strange but wise person.. ;) why did you DONīT say all this at the FIRST post... *GG*

i'm confused over how uncomplicated this piece of code is... thanks A LOT...


RE: hmm a problem... by rob_botch on 08-04-2006 at 05:47 PM

Actually, if you look on the very first reply (mine) and RaceProUK's first post, they both make clear the solution, just not in the explicit code.