Shoutbox

what is wrong? - 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: what is wrong? (/showthread.php?tid=77172)

what is wrong? by 89rafa on 09-01-2007 at 11:03 PM

function OnEvent_MyPsmChange(NewPsm)
{
SendMessage("/me changed the personal message");
}


RE: what is wrong? by foaly on 09-01-2007 at 11:05 PM

well it doesn't know where to send the message to...
you should use something like

code:
ChatWindow.SendMessage("/me changed the personal message");

but you have to define that ChatWindow first...
RE: what is wrong? by 89rafa on 09-01-2007 at 11:08 PM

and how we do that.. i'm noob in javascript
i never had programed =X


RE: what is wrong? by Stigmata on 09-01-2007 at 11:10 PM

you haven't defined a chat window to send the message from.

This will work:

code:
function OnEvent_MyPsmChange(NewPsm)
{
var Windows = Messenger.CurrentChats;
var e = new Enumerator(Windows);
for(; !e.atEnd(); e.moveNext())
{
    var ChatWindow = e.item();
    ChatWindow.SendMessage("/me has changed their personal message");
}

}


That will send the /me message to every open conversation you have.

Hope that is what you want :)

PS: you can also make it display your new psm by including it in the /me message like this

code:
ChatWindow.SendMessage("/me has changed their personal message to " + NewPsm);

RE: what is wrong? by 89rafa on 09-01-2007 at 11:14 PM

can you explain me the

var Windows = Messenger.CurrentChats;
var e = new Enumerator(Windows);
for(; !e.atEnd(); e.moveNext())
{
var ChatWindow = e.item();


i dont get it...


RE: what is wrong? by Stigmata on 09-01-2007 at 11:21 PM

code:
    var Windows = Messenger.CurrentChats;

The Messenger.CurrentChats is a list of chat windows already open.

code:
    var e = new Enumerator(Windows);

Here we enumerate the list so we can sort the chat windows individually.

code:
    for(; !e.atEnd(); e.moveNext())
    {

This is a start of a "for loop". Using the enumeration we did in the line before we go through each chat window object.

Here is some more information on loops in javascript:
http://www.w3schools.com/js/js_loop_for.asp

code:
    var ChatWindow = e.item();

Here we define the current enumerated chat window as ChatWindow so it is easier to handle :)
RE: what is wrong? by 89rafa on 09-01-2007 at 11:28 PM

i think i get it now,
but i would never obtain that.

I want to learn .js :'(


RE: what is wrong? by Stigmata on 09-01-2007 at 11:35 PM

Here is a good place to start :)

http://www.w3schools.com/js/default.asp


RE: what is wrong? by 89rafa on 09-01-2007 at 11:36 PM

i already had that link. .  but my english is kind of poor... but i'll try


RE: what is wrong? by Stigmata on 09-01-2007 at 11:37 PM

Well which language do you speak?


RE: what is wrong? by 89rafa on 09-01-2007 at 11:42 PM

portuguese... and a little bit of spanish...

i done the same thing to nick change.. and works!!

god bless copy-paste =/


RE: what is wrong? by Stigmata on 09-01-2007 at 11:55 PM

Perhaps a google search will help you :)

http://www.google.co.uk/search?q=javascript+tutorial+portuguese

Good luck :)


RE: what is wrong? by 89rafa on 09-02-2007 at 04:40 PM

thanks...

now the problem is:
ex

function OnEvent_ChatWndSendMessage(ChatWnd,Message)
    {
    if (Message.toLowerCase() == "/rafa") // prevenir erros. (ex. !RaFa)
        {
        var text="i'm rafa"
        ChatWnd.SendMessage(text);
        }
    }
   
//outro

function OnGetScriptCommands()
{
    var ScriptCommands = "<ScriptCommands>";
    ScriptCommands += "<Command>";
    ScriptCommands += "<Name>rafa</Name>";
    ScriptCommands += "<Description>tell who i am</Description>";
    ScriptCommands += "</Command>";
    ScriptCommands += "</ScriptCommands>";
    return ScriptCommands;
}


ok... it works...
but gives me a anoying beep song and a erros message that says something like that:
if you want to type /rafa try typing //rafa

edit: mistakes

big progress xD


RE: what is wrong? by matty on 09-02-2007 at 04:47 PM

After the line ChatWnd.SendMessage(text);

add the following

code:
return '';

RE: RE: what is wrong? by 89rafa on 09-02-2007 at 04:50 PM

quote:
Originally posted by matty
After the line ChatWnd.SendMessage(text);

add the following

code:
return '';


can you explain what that does? i'm a begginer...
RE: what is wrong? by effection on 09-02-2007 at 05:10 PM

it means the function returns no message(an empty string) so it wont be displayed or try to be used as a command


RE: what is wrong? by ShawnZ on 09-02-2007 at 05:13 PM

quote:
Originally posted by 89rafa
can you explain what that does? i'm a begginer...

it returns the text "" (an empty string) to whatever called it, as a result. plus! needs you to return something, otherwise it assumes that the command doesn't exist
RE: what is wrong? by 89rafa on 09-02-2007 at 05:17 PM

ok. thanks.
i'm trying to do one thing.. if i can't i will come here asking for help...
but first i will try do it by my self....  =D


RE: what is wrong? by matty on 09-02-2007 at 05:23 PM

quote:
Originally posted by ShawnZ
plus! needs you to return something, otherwise it assumes that the command doesn't exist
Correction, Plus! requires you to return something to the function or else it will try and parse the command. And because the command doesn't exist you receive the error.