Player
Interaction with players in SpellSync takes place using the Player Manager ss.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.
๐๏ธ Player manager
The manager rules over the player state and his synchronization with the server. After SDK initialization, there starts the process of playerโs synchronization with the server. Upon completion, the ready event will be called.
๐๏ธ Player state
Set and save player progress. Player progress is represented by fields that are explicitly set in the control panel.
๐๏ธ Energy
You can configure automatic variables that will be accrued according to the server time, which can be set with upper and lower limits.
๐๏ธ Players Data
Get Player Data
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โ
Key | Type | Description |
---|---|---|
id | number | Player's identifier within the service |
credentials | string | Player's identifier on the platform |
secretCode | string | Unique code used for player authorization |
active | boolean | Active player - player access is not blocked/banned |
removed | boolean | Account removed from the service (not available in SDK) |
test | boolean | Player is on test site |
score | number | Player's score. Default is 0 |
name | string | Player's name. Default is empty |
avatar | string | Player'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.
SpellSync Community Telegram
: @spellsync.
For your suggestions e-mail
: [email protected]
We Wish you Success!