What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Help] Scripting Problem

[Help] Scripting Problem
Author: Message:
Shadowajohn
Junior Member
**

Avatar
Addiction, it keeps me sane...

Posts: 19
31 / Male / Flag
Joined: Nov 2008
O.P. [Help] Scripting Problem
Not sure if this should be in help & support or scripting..so i put in h&s.

A while ago i made a Xbox360 script (well edited from an old last.fm script with permission) which more or less allows you to post your Xbox Live gamerscore and status to MSN.
I've recently noticed the status function i added no longer works,

It used to output something like:
code:
360 - Shadowajohn: Playing Magic: The Gathering - Playing Campaign (Single Player). Life:16
Now it outputs:
code:
360 - Shadowajohn: Valid - Valid
I've not changed anything since it worked, yet it doesn't work anymore.
I have very limited knowledge in java or xml..and i've tried nearly everything i think it could be.

Here's the full code

code:
//////////////////
// Globals vars //
//////////////////
var GamerTag = '';
var WScript = new ActiveXObject('WScript.Shell');
var message = '';
var user = new Array();
var PC = new Array();


///////////////////////////
// Menu Clicked function //
///////////////////////////


function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd)
{
  switch(MenuItemId)
  {
    case "SendGamerScore":
        SendGamerScore(OriginWnd);
        Debug.Trace('[Sent] Gamerscore sent');
    break;
    case "SendStatus":
        SendStatus(OriginWnd);
        Debug.Trace('[Sent] Status sent');
    break;
    case "XboxOptions":
        if(Messenger.MyEmail != "")
        {
            GetGamerTag(Messenger.MyEmail);
        }
        plusWnd = MsgPlus.CreateWnd('Windows.xml', 'XboxOptions');
        plusWnd.SetControlText('EdtGamerTag', GamerTag);
        Debug.Trace('[Window] XboxOptions opened');
    break;
    case "XboxAbout":
        plusWnd = MsgPlus.CreateWnd('Windows.xml', 'XboxAbout');
    break;
  }
}

//////////////////////////////
// XboxOptions Clicked Function //
//////////////////////////////

function OnXboxOptionsEvent_CtrlClicked(PlusWnd, ControlId)
{    Debug.Trace('[Clicked] '+ControlId);
    switch (ControlId)
    {
        case "BtnSave":
            GamerTag = PlusWnd.GetControlText('EdtGamerTag');
               if(Messenger.MyEmail != "")
            {
                SetGamerTag(Messenger.MyEmail);
            }
            PlusWnd.Close(1);
            Debug.Trace('[Window] XboxOptions closed');
            break;
    }
}

////////////////////////////
// About Clicked Function //
////////////////////////////

function OnXboxAboutEvent_CtrlClicked(Wnd, sControlId){
    if(sControlId == "lnkWebsite"){
        new ActiveXObject("wscript.shell").run("http://shadowgaming.wordpress.com/");
    }
}

////////////////////////////////////////////
// Get the GamerTag from registry //
////////////////////////////////////////////

function GetGamerTag(email)
{    try
    {
        GamerTag = WScript.RegRead(MsgPlus.ScriptRegPath + email + '\\GamerTag');
        Debug.Trace('[Loaded] XboxLive GamerTag: '+GamerTag);
    }
    catch(exception)
    {        WScript.RegWrite(MsgPlus.ScriptRegPath + email + '\\GamerTag', '');
        GetGamerTag(email);
    }
}

//////////////////////////////////////////
// Set the GamerTag in registry //
//////////////////////////////////////////

function SetGamerTag(email)
{    WScript.RegWrite(MsgPlus.ScriptRegPath + email + '\\GamerTag', GamerTag);
    Debug.Trace('[Saved] Xbox Live GamerTag: '+GamerTag);
}

///////////////////////////////////
// The SendGamerScore function //
///////////////////////////////////

function SendGamerScore(OriginWnd)
{    if(Messenger.MyEmail != "")
    {
        GetGamerTag(Messenger.MyEmail);
        GetFeed('http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag='+ GamerTag, 'SendGamerScoreHandler', OriginWnd);
    }
}

function SendStatus(OriginWnd)
{    if(Messenger.MyEmail != "")
    {
        GetGamerTag(Messenger.MyEmail);
        GetFeed('http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag='+ GamerTag, 'SendStatusHandler', OriginWnd);
    }
}
//////////////////////////////////////
// The handler for SendGamerScore //
//////////////////////////////////////
function SendGamerScoreHandler(response, OriginWnd)
{
    // empty message var
    message = '';
   
    // Get playcount
    PC = response.selectNodes('XboxInfo');
     for(var i=0; i<PC.length; i++){
    message += GamerTag + " has a total of " + PC[i].childNodes(11).text + "GS";
    }

    OriginWnd.SendMessage(message);
}

//////////////////////////////////////
// The handler for SendStatus //
//////////////////////////////////////
function SendStatusHandler(response, OriginWnd)
{
    // empty message var
    message = '';
   
    // Get playcount
    user = response.selectNodes('XboxInfo/PresenceInfo');
     for(var i=0; i<PC.length; i++){
    message += "360 - " + GamerTag + ": " + PC[i].childNodes(2).text + " - " + PC[i].childNodes(3).text;

    }

    OriginWnd.SendMessage(message);
}

////////////////////////////////////////////////////
// Ajax functions by Lucsas van Dijk (lucasvd.nl) //
////////////////////////////////////////////////////
function GetFeed(url, callback_function, OriginWnd)
{
    var feed = create_http_object();

    feed.onreadystatechange = function()
    {
        if(feed.readyState==4)
        {
            if(feed.status == 200)
            {
                eval(callback_function + '(feed.responseXML, OriginWnd)');
            }
            else
            {
                Debug.Trace('[Error] ' + feed.status);
            }
        }
    }

    Debug.Trace('[URL] '+url);

    feed.open('GET', url, false);
    feed.send(null);
}

function create_http_object()
{
    var ActiveXTypes = [
        "MSXML2.XMLHTTP.5.0",
        "MSXML2.XMLHTTP.4.0",
        "MSXML2.XMLHTTP.3.0",
        "MSXML2.XMLHTTP",
        "Microsoft.XMLHTTP",
    ];

    for( var i = 0; i < ActiveXTypes.length; i++ )
    {
        try
        {            Debug.Trace('[ActiveX] ' + ActiveXTypes[i]);
            return new ActiveXObject( ActiveXTypes[i] );
        }
        catch( e )
        { }
    }

    try
    {
        return new XMLHttpRequest();
    }
    catch( e )
    { }

    return false;
}

Xbox360Stuff Script - Twitter - Blog
X360Stuff Script Status: On-Hold.
Will make/edit a new script soon.
[Image: ShadowAjohn.gif]
07-13-2009 08:22 PM
Profile E-Mail PM Web Find Quote Report
rikimasse97
New Member
*


Posts: 14
– / Male / Flag
Joined: Jul 2009
RE: [Help] Scripting Problem
You forgot a few ";" the rest should be right.!
This is the code that I modified:

code:
//////////////////
// Globals vars //
//////////////////
var GamerTag = '';
var WScript = new ActiveXObject('WScript.Shell');
var message = '';
var user = new Array();
var PC = new Array();


///////////////////////////
// Menu Clicked function //
///////////////////////////


function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd)
{
  switch(MenuItemId)
  {
    case "SendGamerScore":
        SendGamerScore(OriginWnd);
        Debug.Trace('[Sent] Gamerscore sent');
    break;
    case "SendStatus":
        SendStatus(OriginWnd);
        Debug.Trace('[Sent] Status sent');
    break;
    case "XboxOptions":
        if(Messenger.MyEmail != "");
        {
            GetGamerTag(Messenger.MyEmail);
        }
        plusWnd = MsgPlus.CreateWnd('Windows.xml', 'XboxOptions');
        plusWnd.SetControlText('EdtGamerTag', GamerTag);
        Debug.Trace('[Window] XboxOptions opened');
    break;
    case "XboxAbout":
        plusWnd = MsgPlus.CreateWnd('Windows.xml', 'XboxAbout');
    break;
  }
}

//////////////////////////////
// XboxOptions Clicked Function //
//////////////////////////////

function OnXboxOptionsEvent_CtrlClicked(PlusWnd, ControlId)
{    Debug.Trace('[Clicked] '+ControlId);
    switch (ControlId)
    {
        case "BtnSave":
            GamerTag = PlusWnd.GetControlText('EdtGamerTag');
               if(Messenger.MyEmail != "")
            {
                SetGamerTag(Messenger.MyEmail);
            }
            PlusWnd.Close(1);
            Debug.Trace('[Window] XboxOptions closed');
            break;
    }
}

////////////////////////////
// About Clicked Function //
////////////////////////////

function OnXboxAboutEvent_CtrlClicked(Wnd, sControlId){
    if(sControlId == "lnkWebsite"){
        new ActiveXObject("wscript.shell").run("http://shadowgaming.wordpress.com/");
    }
}

////////////////////////////////////////////
// Get the GamerTag from registry //
////////////////////////////////////////////

function GetGamerTag(email)
{    try
    {
        GamerTag = WScript.RegRead(MsgPlus.ScriptRegPath + email + '\\GamerTag');
        Debug.Trace('[Loaded] XboxLive GamerTag: '+GamerTag);
    }
    catch(exception)
    {        WScript.RegWrite(MsgPlus.ScriptRegPath + email + '\\GamerTag', '');
        GetGamerTag(email);
    }
}

//////////////////////////////////////////
// Set the GamerTag in registry //
//////////////////////////////////////////

function SetGamerTag(email)
{    WScript.RegWrite(MsgPlus.ScriptRegPath + email + '\\GamerTag', GamerTag);
    Debug.Trace('[Saved] Xbox Live GamerTag: '+GamerTag);
}

///////////////////////////////////
// The SendGamerScore function //
///////////////////////////////////

function SendGamerScore(OriginWnd)
{    if(Messenger.MyEmail != "")
    {
        GetGamerTag(Messenger.MyEmail);
        GetFeed('http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag='+ GamerTag, 'SendGamerScoreHandler', OriginWnd);
    }
}

function SendStatus(OriginWnd)
{    if(Messenger.MyEmail != "");
    {
        GetGamerTag(Messenger.MyEmail);
        GetFeed('http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag='+ GamerTag, 'SendStatusHandler', OriginWnd);
    }
}
//////////////////////////////////////
// The handler for SendGamerScore //
//////////////////////////////////////
function SendGamerScoreHandler(response, OriginWnd)
{
    // empty message var
    message = '';
   
    // Get playcount
    PC = response.selectNodes('XboxInfo');
     for(var i=0; i<PC.length; i++){
    message += GamerTag + " has a total of " + PC[i].childNodes(11).text + "GS";
    }

    OriginWnd.SendMessage(message);
}

//////////////////////////////////////
// The handler for SendStatus //
//////////////////////////////////////
function SendStatusHandler(response, OriginWnd)
{
    // empty message var
    message = '';
   
    // Get playcount
    user = response.selectNodes('XboxInfo/PresenceInfo');
     for(var i=0; i<PC.length; i++){
    message += "360 - " + GamerTag + ": " + PC[i].childNodes(2).text + " - " + PC[i].childNodes(3).text;

    }

    OriginWnd.SendMessage(message);
}

////////////////////////////////////////////////////
// Ajax functions by Lucsas van Dijk (lucasvd.nl) //
////////////////////////////////////////////////////
function GetFeed(url, callback_function, OriginWnd)
{
    var feed = create_http_object();

    feed.onreadystatechange = function();
    {
        if(feed.readyState==4)
        {
            if(feed.status == 200)
            {
                eval(callback_function + '(feed.responseXML, OriginWnd)');
            }
            else
            {
                Debug.Trace('[Error] ' + feed.status);
            }
        }
    }

    Debug.Trace('[URL] '+url);

    feed.open('GET', url, false);
    feed.send(null);
}

function create_http_object()
{
    var ActiveXTypes = [
        "MSXML2.XMLHTTP.5.0",
        "MSXML2.XMLHTTP.4.0",
        "MSXML2.XMLHTTP.3.0",
        "MSXML2.XMLHTTP",
        "Microsoft.XMLHTTP",
    ];

    for( var i = 0; i < ActiveXTypes.length; i++ );
    {
        try
        {            Debug.Trace('[ActiveX] ' + ActiveXTypes[i]);
            return new ActiveXObject( ActiveXTypes[i] );
        }
        catch( e )
        { }
    }

    try
    {
        return new XMLHttpRequest();
    }
    catch( e )
    { }

    return false;
}

07-16-2009 06:01 AM
Profile E-Mail PM Find Quote Report
rikimasse97
New Member
*


Posts: 14
– / Male / Flag
Joined: Jul 2009
RE: [Help] Scripting Problem
the debug says that there is an error at line 159:
code:

.....
////////////////////////////////////////////////////
// Ajax functions by Lucsas van Dijk (lucasvd.nl) //
////////////////////////////////////////////////////
function GetFeed(url, callback_function, OriginWnd)
{
    var feed = create_http_object();

    feed.onreadystatechange = function();
    {
        if(feed.readyState==4)
        {
            if(feed.status == 200)
            {
                eval(callback_function + '(feed.responseXML, OriginWnd)');
            }
            else
            {
                Debug.Trace('[Error] ' + feed.status);
            }
        }
    }

    Debug.Trace('[URL] '+url);

    feed.open('GET', url, false);
    feed.send(null);
}

function create_http_object()
{
    var ActiveXTypes = [
        "MSXML2.XMLHTTP.5.0",
        "MSXML2.XMLHTTP.4.0",
        "MSXML2.XMLHTTP.3.0",
        "MSXML2.XMLHTTP",
        "Microsoft.XMLHTTP",
    ];

    for( var i = 0; i < ActiveXTypes.length; i++ );
    {
        try
        {            Debug.Trace('[ActiveX] ' + ActiveXTypes[i]);
            return new ActiveXObject( ActiveXTypes[i] );
        }
        catch( e )
        { }
    }

    try
    {
        return new XMLHttpRequest();
    }
    catch( e )
    { }

    return false;
}


This post was edited on 07-16-2009 at 06:14 AM by rikimasse97.
07-16-2009 06:10 AM
Profile E-Mail PM Find Quote Report
Shadowajohn
Junior Member
**

Avatar
Addiction, it keeps me sane...

Posts: 19
31 / Male / Flag
Joined: Nov 2008
O.P. RE: [Help] Scripting Problem
Just tried both bits of code, and both don't seem to fix the problem.

Though browsing through the script, i just noticed i'm an idiot.

This:
code:
    user = response.selectNodes('XboxInfo/PresenceInfo');
Should be:
code:
    PC = response.selectNodes('XboxInfo/PresenceInfo');

Anyways, thanks for the help =D.
Xbox360Stuff Script - Twitter - Blog
X360Stuff Script Status: On-Hold.
Will make/edit a new script soon.
[Image: ShadowAjohn.gif]
07-16-2009 06:21 AM
Profile E-Mail PM Web Find Quote Report
rikimasse97
New Member
*


Posts: 14
– / Male / Flag
Joined: Jul 2009
RE: [Help] Scripting Problem
you're welcome
07-16-2009 06:25 AM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: [Help] Scripting Problem
quote:
Originally posted by rikimasse97
you're welcome

In response to your first post, the semi-colon is not needed and in fact, it breaks the script as the syntax is for defining a function. Marking the end of a line with a semi-colon there is like putting nothing after an equals sign...
<Eljay> "Problems encountered: shit blew up" :zippy:
07-17-2009 02:08 PM
Profile PM Find Quote Report
« 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