Skip to main content

Player

Interaction with players in GamePush takes place using the Player Manager gp.player. The manager manages the player's state and its synchronization with the server. The player manager inherits from Player and extends it, allows you to work with the state, fields and data of the players.

Data Management

The player manager allows you to manage player data - set and save player progress. Player progress is represented as fields, which are explicitly defined in the control panel. Explicit field specification is necessary in order to create leaderboards and avoid storing accidentally added / unnecessary data in the current version.

Fields can be defined in the project management control panel under Players section.

Players have base fields and custom fields:

Field Types:

  • Service - Service field, read-only.
  • Number - Numeric field (float).
  • String - String field with JSON support.
  • Flag - Boolean field.

Base Fields

KeyTypeDescription
idnumberPlayer's identifier within the service
credentialsstringPlayer's identifier on the platform
secretCodestringUnique code used for player authorization
activebooleanActive player - player access is not blocked/banned
removedbooleanAccount removed from the service (not available in SDK)
testbooleanPlayer is on test site
scorenumberPlayer's score. Default is 0
namestringPlayer's name. Default is empty
avatarstringPlayer's avatar. Default is empty

Custom Fields

You can extend the player model by adding any field in the control panel.

In the add form, you can specify:

  • Name. You can provide a name for multiple languages by changing the language in the "Language" select menu.
  • Key for accessing the field in the SDK. Restrictions:
    • Cannot use service fields;
    • Only Latin characters A-Z, a-z and numbers, special characters _, - are allowed;
  • Type. Available types: number, string, boolean.
  • Default value. This value will be recorded in the player profile upon first login.
  • Range Restriction (numeric fields only). Specify the minimum and maximum values for the field.
  • Auto-Increment Variable (numeric fields only). Define the increment interval and the value to be added each period.
  • Enumerated Values (numeric/string fields only). Apply to all players or in test mode only.
  • Public field. The field will be accessible to other players in searches. For example, in creating arenas, you can enable player inventory and characteristics for opponent equipment. Currency or player progress may not be shown.
  • Important field. In case of save conflicts, this field will be shown to the player to decide which profile to continue the game with.

Field Range Restriction

Available for numeric fields only.

You can restrict the minimum and maximum value of a field at the schema level.

When the toggle is on, the field will be limited by the specified limits.

  • Minimum value. Value below this mark cannot be set for the player. If an attempt is made to set a value lower, the specified minimum value will automatically be set.
  • Maximum value. Value above this mark cannot be set for the player. If an attempt is made to set a value higher, the specified maximum value will automatically be set.
  • Setting value above the maximum allowed. In this case, when setting the field manually, the restriction will be ignored, but it will work when automatically awarded.

Auto-Increment Variable

Available for numeric fields only.

You can specify the logic for updating a variable using server time at the schema level.

When the toggle is on, the field will automatically increase at the specified interval with the specified value until it reaches the maximum/minimum value.

  • Accrual Interval (sec.). How often the value should be added to the player's variable.
  • Quantity. How much to increase the player's variable value per iteration.

Enumerated Values

At the schema level, you can strictly define the possible field value options. Other values will be ignored.

This is also useful when specifying field translation in leaderboards.

Stay in Touch

Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.

GamePush Community Telegram: @gs_community.

For your suggestions e-mail: [email protected]

We Wish you Success!