Shoutbox

Help me with a Basic.. and easy.. script - 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 me with a Basic.. and easy.. script (/showthread.php?tid=72845)

Help me with a Basic.. and easy.. script by Joined_ on 03-20-2007 at 03:39 PM

Hi to all!
Congratulations for the beatiful forum and the cool software you created.
I've a little problem creating a script.
This is the first time i create a script..
I want to create a script that Blocks/Unblocks the contact i'm talking with..
i tried to modify some other scripts that i found here to do what i want.. but i didn't have any result...
Help me please!
Bye, Lorenzo
P.S.: Sorry for my English but i'm italian!


RE: Help me with a Basic.. and easy.. script by Jesus on 03-20-2007 at 03:51 PM

you can already block/unblock the contact with the /block and /unblock command, or by using the block/unblock button on the conversation window.

If you want to be able to do it another way, please post the code you have so far so we can help you out.


RE: Help me with a Basic.. and easy.. script by Joined_ on 03-20-2007 at 04:00 PM

Yes but.. i need to block/unblock for many times quickly!


RE: Help me with a Basic.. and easy.. script by Vilkku on 03-20-2007 at 04:15 PM

Can't you make a quick text with /block and /unblock many times? And if you want to annoy your contacts with sound and toasts, use HopperLive.


RE: Help me with a Basic.. and easy.. script by Joined_ on 03-20-2007 at 04:56 PM

Yes.. but.. what type of text? and how can i load and start that text?


RE: Help me with a Basic.. and easy.. script by matty on 03-20-2007 at 05:05 PM

something like this

code:
function OnEvent_ChatWndSendMessage(oChatWnd, nMessage){
    var aContacts = new Array();
    if (nMessage === '/cBlock'){
        for (var e = new Enumerator(oChatWnd.Contacts); !e.atEnd(); e.moveNext()){
            aContacts[aContacts.length] = e.item().Email;
        }
        for (var j=0; j < 5; j++){
            for (var i in aContacts){
                aContacts[i].Blocked = !aContacts[i].Blocked;
            }
        }
    }
}

This will block and unblock them 5 times.

Don't do this its very annoying!
RE: Help me with a Basic.. and easy.. script by Joined_ on 03-20-2007 at 05:14 PM

It tell me that the command is not know!


RE: Help me with a Basic.. and easy.. script by Jesus on 03-20-2007 at 05:19 PM

code:
function OnEvent_ChatWndSendMessage(oChatWnd, nMessage){
        var aContacts = new Array();
        if (nMessage === '/cBlock'){
            for (var e = new Enumerator(oChatWnd.Contacts); !e.atEnd(); e.moveNext()){
                aContacts[aContacts.length] = e.item().Email;
            }
            for (var j=0; j < 5; j++){
                for (var i in aContacts){
                    aContacts[i].Blocked = !aContacts[i].Blocked;
                }
            }
        }
        return "";
    }
should doesn't work.
Don't get angry if everyone blocks you when you use this code, because
quote:
Originally posted by Matty
its very annoying!

RE: Help me with a Basic.. and easy.. script by Joined_ on 03-20-2007 at 05:25 PM

When i load it, i can't write any message and it also doesn't work!


RE: Help me with a Basic.. and easy.. script by matty on 03-20-2007 at 05:40 PM

code:
function OnEvent_ChatWndSendMessage(oChatWnd, nMessage){
    var aContacts = new Array();
    if (nMessage === '/cBlock'){
        for (var e = new Enumerator(oChatWnd.Contacts); !e.atEnd(); e.moveNext()){
            aContacts[aContacts.length] = e.item();
        }
        for (var j=0; j < 2; j++){
            for (var i in aContacts){
                aContacts[i].Blocked = !aContacts[i].Blocked;
            }
        }
        return '';
    }
}

function OnGetScriptCommands(){
    return '<ScriptCommands><Command><Name>cBlock</Name></Command></ScriptCommands>';
}

Maybe they are already blocked!
RE: Help me with a Basic.. and easy.. script by Jesus on 03-20-2007 at 05:41 PM

lol sorry I misplaced the return "";
after fixing the code and actually testing it I found out that this method doesn't work like expected.
To actually annoy your contact with lots of toasts and sounds I suggest you take a look at MsgPlus Timers in the scripting documentation and fiddle around a bit with them.


quote:
Originally posted by Matty
code:
function OnEvent_ChatWndSendMessage(oChatWnd, nMessage){
    var aContacts = new Array();
    if (nMessage === '/cBlock'){
        for (var e = new Enumerator(oChatWnd.Contacts); !e.atEnd(); e.moveNext()){
            aContacts[aContacts.length] = e.item().Email;   //Don't use .Email, you need the contact object.
        }
        for (var j=0; j < 5; j++){
            for (var i in aContacts){
                aContacts[i].Blocked = !aContacts[i].Blocked; //Doesn't work if called too quick after each other.
            }
        }
        return '';
    }
}

function OnGetScriptCommands(){
    return '<Command><Name>cBlock</Name></Command></ScriptCommands>'; //<ScriptCommands> is missing
}

Maybe they are already blocked!
Won't work, see the comments...
RE: Help me with a Basic.. and easy.. script by Joined_ on 03-20-2007 at 05:47 PM

Messenger don't seems to know this command!!!


RE: Help me with a Basic.. and easy.. script by matty on 03-20-2007 at 05:54 PM

Code should work now however as the second comment says if .Blocked is called too early it may not work. Learn to use Timers.