What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Big noob can't edit Chuck Norris script.

Big noob can't edit Chuck Norris script.
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Big noob can't edit Chuck Norris script.
Thats just what I did. Something like this is so much better and managable.

js code:
var oQuotes = {};

function OnEvent_Initialize(bMessengerStart) {
    var xml = createXml();
    if ( typeof xml !== 'object' ) return false;
    xml.load('quotes.xml');
    var quote = xml.selectNodes("/chucknoris/quote");
    for(i=0; i<quote.length; i++){
        oQuotes[i]=quote.text;
    }
}

function OnEvent_ChatWndSendMessage(ChatWnd, Message){
    switch (Message.toLowerCase()) {
        case "/chuck":
            return "[c=green]"+oQuotes[Math.floor((oQuotes.length)*Math.random())]+"[/c] ";
            break;
    }
}

function OnGetScriptCommands(){
    return '<ScriptCommands><Command><Name>chuck</Name><Description>Sends a Chuck Norris sentence</Description></Command></ScriptCommands>';
}

function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd){
    if(MenuItemId=="ym"){
        OriginWnd.SendMessage(OnEvent_ChatWndSendMessage(OriginWnd, "/chuck"));
    }else if(MenuItemId=="about"){
        WndAbout = MsgPlus.CreateWnd("WndAbout.xml","WndAbout");
    }
}

function OnGetScriptMenu(nLocation){
    var ScriptMenu = "<ScriptMenu>";
    if(nLocation === MENULOC_CHATWND){
        ScriptMenu    +=    "<MenuEntry Id='ym'>chuck</MenuEntry>";
        ScriptMenu    +=    "<Separator/>";
    }
    ScriptMenu    +=    "<MenuEntry Id='about'>About</MenuEntry>";
    ScriptMenu    += "</ScriptMenu>";
    return ScriptMenu;
}

function createXml() {
    try {
        var xml = new ActiveXObject('Microsoft.XMLDOM');
        xml.async = true;
    } catch(e) {
        try {
            var xml = new ActiveXObject('MSXML2.DOMDocument');
            xml.async = true;
        } catch(e) {
            return false;
        }
    }
    return xml;
}

xml code:

07-08-2009 05:40 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Big noob can't edit Chuck Norris script. - by Hackey_Sack on 07-08-2009 at 04:30 PM
RE: Big noob can't edit Chuck Norris script. - by matty on 07-08-2009 at 05:13 PM
RE: Big noob can't edit Chuck Norris script. - by segosa on 07-08-2009 at 05:24 PM
RE: Big noob can't edit Chuck Norris script. - by matty on 07-08-2009 at 05:40 PM
RE: Big noob can't edit Chuck Norris script. - by Hackey_Sack on 07-08-2009 at 07:44 PM


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