View as Markdown

Stats

Player skills panel in RuneScape showing a grid of skill icons with level numbers for Attack, Strength, Defence, and other stats
Player stats in Runescape by Jagex.

The Hiro Stats system is a versatile feature designed to enhance player experience by managing and displaying player statistics. It allows players to have both public and private stats, catering to the diverse needs of game dynamics and player preferences.

Public stats are visible to all, fostering a competitive and interactive gaming environment, while private stats are confined to individual players, allowing them to monitor their personal progress.

The system is highly flexible, enabling updates through various operators such as delta, set, min, or max, providing a comprehensive approach to stat management. Whether it’s setting a new value, adjusting by a certain amount, or determining minimum or maximum values, the Hiro Stats system ensures seamless and dynamic stat modifications to enrich gameplay.

The public stats are stored in the player’s Nakama account metadata and the private stats are stored in Nakama storage.

To control which stats can change at all, define a whitelist. Only the stats it names can be updated, which keeps clients from creating or changing stats you didn’t plan for.

Customization parameters #

The following JSON represents the customization parameters you can use to configure the default user experience for the Stats system.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
  "stats_public":{
    "level": {
        "value": 1
    },
    "GamesLost": {
        "value": 0
    },
    "GamesWon": {
        "value": 0
    }
  },
  "stats_private":{
    "strength": {
        "value": 0
    },
    "AreasCompleted": {
        "value": 0
    },
    "FirstTryWins": {
        "value": 0
    }
  }
}

Stats #

PropertyTypeDescription
stats_public{}string, StatsConfigStatA dictionary where the key is the stat ID and the value is the StatsConfigStat.
stats_private{}string, StatsConfigStatA dictionary where the key is the stat ID and the value is the StatsConfigStat.
whitelist[]stringStat IDs that can be updated. Applies to both public and private stats. If empty, all stats can be updated.

StatsConfigStats #

PropertyTypeDescription
valueint64Default initial value
AdditionalProperties{}string, interfaceA dictionary of additional properties.

Stat whitelist #

The whitelist is a single list of stat names that covers both public and private stats. If the whitelist is empty or missing, any stat can be updated.

When a whitelist is defined, it’s enforced that all stats in an update request should be on the whitelist. The whole request is rejected and none of its stats change if any of the stats in the update request is not in the whitelist.

The whitelist works alongside stats_public and stats_private. When both are configured, a stat must be on the whitelist and defined in the matching map. The whitelist only restricts updates, so existing stats and configured defaults are still returned when stats are listed.

Additional Information #