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"
},