you need to change your FriendsPlaying function to something like this
Acts.prototype.FriendsPlaying = function (n)
{
FB.api('/' + Init_App_ID + '/scores', 'GET', {}, function(response) {
var arr = response["data"];
if (!arr)
{
console.error("Hi-scores request failed: " + response);
return;
}
arr.sort(function(a, b) {
// descending order
return b["score"] - a["score"];
});
var i = 0, len = Math.min(arr.length, n);
fbfriendlength = arr.length;
for ( ; i < len; i++)
{
current_friend_score = arr["score"];
current_friend_name = arr["user"]["name"];
current_friend_id = arr["user"]["id"];
fbGameFriendsScore = arr["score"];
fbGameFriendsName = arr["user"]["name"];
fbGameFriendsID = arr["user"]["id"];
fbRank = i + 1;
fbRuntime.trigger(cr.plugins_.FBComplete.prototype.cnds.OnHiscore, fbInst);
}
//fbRuntime.trigger(cr.plugins_.FBComplete.prototype.cnds.OnHiscore, fbInst);
if (!response || response.error) {
fbGameFriendsScore = "failed";
fbGameFriendsName = "failed";
fbGameFriendsID = "failed";
fbRank = "failed";
} else {
fbGameFriendsScore = "failed";
fbGameFriendsName = "failed";
fbGameFriendsID = "failed";
fbRank = "failed";
}
});
};