IncrementGlobalStats
Atomically increment (or decrement) global statistics. Global statistics are defined through the brainCloud portal.
StatisticsData like
{ "stat1" : 10, "stat2" : -5.5 }
would increment stat1 by 10 and decrement stat2 by 5.5. For the full statistics grammar see the statistics grammar section.
There are many more complex operations supported such as
{ "stat1" : "INC_TO_LIMIT#9#30" }
which increments stat1 by 9 up to a limit of 30.
Service | Operation |
---|---|
globalGameStatistics | UPDATE_INCREMENT |
Method Parameters
Parameter | Description |
---|---|
statistics | A collection containing the statistics to increment. |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
var statistics = {
"PLAYER_COUNT": 1
};
var globalStatisticsProxy = bridge.getGlobalStatisticsServiceProxy();
var postResult = globalStatisticsProxy.incrementGlobalStats(statistics);
if (postResult.status == 200) {
// Success!
}
{
"service": "globalGameStatistics",
"operation": "UPDATE_INCREMENT",
"data": {
"statistics": {
"PLAYER_COUNT": 1
}
}
}
JSON Response
{
"status": 200,
"data": {
"statistics": {
"PLAYER_COUNT": 16
}
}
}