#New Leaderboards through CloudScript

5 messages · Page 1 of 1 (latest)

west minnow
#

I''m using the new leaderboards (not the legacy ones) and I'm trying to write a cloudscript function that validates a score and then submits it using UpdateLeaderboardEntries. However it seems that UpdateLeaderboardEntries is not a recognized function in cloudscript?

handlers.SubmitScore = function (args) {
    if (args == null || args.leaderboardName == null || args.score == null || args.timeSpent == null || args.ballsFaced == null) {
        return { error: "Invalid arguments. Please provide leaderboardName, score, timeSpent, and ballsFaced." };
    }

    try {
        var updateRequest = {
            LeaderboardName: args.leaderboardName,
            Entries: [
                {
                    EntityId: currentPlayerId,
                    Scores: [args.score.toString(), args.timeSpent.toString(), args.ballsFaced.toString()],
                    Metadata: JSON.stringify({
                        lastUpdated: new Date().toISOString()
                    })
                }
            ]
        };

        var result = server.UpdateLeaderboardEntries(updateRequest);

        return { success: true, message: "Leaderboard updated successfully" };
    } catch (e) {
        return { error: "Failed to update leaderboard: " + e };
    }
};

And this is what I see in when I'm monitoring the execution

"EventName": "player_executed_cloudscript",
    "Source": "CloudScript",
    "FunctionName": "SubmitScore",
    "CloudScriptExecutionResult": {
        "FunctionName": "SubmitScore",
        "Revision": 15,
        "FunctionResult": {
            "error": "Failed to update leaderboard: TypeError: server.UpdateLeaderboardEntries is not a function"
        },
haughty swan
#

Thanks for reporting, we will take a look and get back to you.

haughty swan
#

We have found the gap and are updating it. I will let you know once it is available.

west minnow
#

Thanks Rakesh - for now I'll just use the regular client API and will switch to server-side validation once it is available

haughty swan
#

@west minnow , can you give it a try again? We dont have lot of internal usage of the leaderboards on cloudscript but we did find one gap and fix it.