I would like to update leaderboards when game ended from Cloud code, and the leaderboard is updated by LogEventRequest.
But LogEventRequest cannot be issue in Cloud code by sendRequest or sendRequestAs.
So how to achieve this?
Thanks a lot
Jo
Best Answer
C
Customer Support
said
about 5 years ago
Hey Jo,
You can call a LogEventRequest from cloud-code, you just want to be careful you don't end up calling recursive loops though. You can call your LogEventRequest using the following code...
var response = Spark.sendRequest({
"@class": ".LogEventRequest",
"eventKey": "sendLogEvent"
});
Theres a very handy API for cloud-code requests here.
But, i think your problem doesn't need to insert a leaderboard entry through cloud-code. The way the leaderboards get their entries is by sending a LogEventRequest with the attribute you want to insert for the player, like the score. So, this event is sent from the client at the end of the game with the player score and you dont need any cloud-code.
There's a tutorial here on how to set those events up.
Let me know if that helps, or if ive misunderstood something.
You can call a LogEventRequest from cloud-code, you just want to be careful you don't end up calling recursive loops though. You can call your LogEventRequest using the following code...
var response = Spark.sendRequest({
"@class": ".LogEventRequest",
"eventKey": "sendLogEvent"
});
Theres a very handy API for cloud-code requests here.
But, i think your problem doesn't need to insert a leaderboard entry through cloud-code. The way the leaderboards get their entries is by sending a LogEventRequest with the attribute you want to insert for the player, like the score. So, this event is sent from the client at the end of the game with the player score and you dont need any cloud-code.
There's a tutorial here on how to set those events up.
Let me know if that helps, or if ive misunderstood something.
Sean
J
Jeffry van de Vuurst
said
almost 5 years ago
But it makes sense to update the leaderboard through cloud code, doesn't it, to prevent cheating? Especially when you're using the JavaScript SDK, one could easily send a LogEventRequest with a very high score and end up as number 1 on the leaderboard.
Jo Huang
Hi
I would like to update leaderboards when game ended from Cloud code, and the leaderboard is updated by LogEventRequest.
But LogEventRequest cannot be issue in Cloud code by sendRequest or sendRequestAs.
So how to achieve this?
Thanks a lot
Jo
You can call your LogEventRequest using the following code...
Theres a very handy API for cloud-code requests here.
But, i think your problem doesn't need to insert a leaderboard entry through cloud-code.
The way the leaderboards get their entries is by sending a LogEventRequest with the attribute you want to insert for the player, like the score.
So, this event is sent from the client at the end of the game with the player score and you dont need any cloud-code.
There's a tutorial here on how to set those events up.
Let me know if that helps, or if ive misunderstood something.
Sean
2 people have this question
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
You can call your LogEventRequest using the following code...
Theres a very handy API for cloud-code requests here.
But, i think your problem doesn't need to insert a leaderboard entry through cloud-code.
The way the leaderboards get their entries is by sending a LogEventRequest with the attribute you want to insert for the player, like the score.
So, this event is sent from the client at the end of the game with the player score and you dont need any cloud-code.
There's a tutorial here on how to set those events up.
Let me know if that helps, or if ive misunderstood something.
Sean
Jeffry van de Vuurst
But it makes sense to update the leaderboard through cloud code, doesn't it, to prevent cheating? Especially when you're using the JavaScript SDK, one could easily send a LogEventRequest with a very high score and end up as number 1 on the leaderboard.
2 people like this
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2486 topics