---
metadata:
  - name: generator
    content: Diplodoc Platform v5.66.0
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/construct-3/authorization-and-data.md
  - https://yandex.com/dev/games/doc/hi/sdk/construct-3/authorization-and-data.md
  - https://yandex.com/dev/games/doc/ko/sdk/construct-3/authorization-and-data.md
  - https://yandex.com/dev/games/doc/ru/sdk/construct-3/authorization-and-data.md
  - https://yandex.com/dev/games/doc/tr/sdk/construct-3/authorization-and-data.md
  - https://yandex.com/dev/games/doc/vi/sdk/construct-3/authorization-and-data.md
  - https://yandex.com/dev/games/doc/zh/sdk/construct-3/authorization-and-data.md
  - href: https://yandex.com/dev/games/doc/zh/sdk/construct-3/authorization-and-data.md
    type: text/markdown
    title: Markdown version
  - href: https://yandex.com/dev/games/doc/zh/llms.txt?revision=r21993288
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/games/doc/zh/llms.txt?revision=r21993288

# 授权和玩家数据

<!-- source: zh/_includes/script-common.md -->
<!-- source: zh/_includes/script/index-js.md -->

<!-- endsource: zh/_includes/script/index-js.md -->

<!-- source: zh/_includes/script/requirements-js.md -->

<!-- endsource: zh/_includes/script/requirements-js.md -->

<!-- source: zh/_includes/script/image-modal-js.md -->

<!-- endsource: zh/_includes/script/image-modal-js.md -->
<!-- endsource: zh/_includes/script-common.md -->

<!-- source: zh/_includes/sdk/common-with-plugins.md -->
您可以：

- 使用 SDK 方法将游戏数据（已通过的关卡、经验、应用内购买等）保存在 Yandex 服务器上，或将其传输到您自己的服务器。 云存档允许用户在不同设备上继续游戏。
- 使用 Yandex 用户个人资料中的数据（例如姓名）来个性化游戏。
<!-- endsource: zh/_includes/sdk/common-with-plugins.md -->

## 玩家信息 {#player-info}

要开始使用玩家数据，请将 **Fetch player info** 操作与触发条件 **Player info is successfully fetched** 和 **Failure to fetch player info** 结合使用。

要获取玩家数据，请使用：

- 条件 **Player is authorized**：检查玩家是否在 Yandex 上获得授权。
- 条件 **Player personal info access granted**：检查是否已获取玩家的个人数据。
- 表达式 **Player signature**：`string`，包含来自 Yandex 个人资料的用户数据及签名。 由两行组成，以 `Base64` 格式编码。
- 表达式 **Player avatar**：`string`，玩家头像链接。
- 表达式 **Player name**：`string`，玩家名称。
- 表达式 **Player paying status**：`string`，用户在平台上的支付活动状态。
- 表达式 **Player unique id**：`string`，玩家的唯一标识符。

![Construct 3 截图：使用 YandexGamesSDK 插件配置用户数据的界面。 一个三列表格（第三列的每个单元格中都有"+ 添加操作"和"+ 添加..."按钮），共 4 行。 第 1 行 —— "系统"、"仅执行一次"、"Yan… | 请求玩家信息。 个人数据：False". 第 2 行 —— "YandexGames…"、"玩家信息已加载"，最后一个单元格为空。 第 3 行 —— "YandexGames…"、"玩家已授予个人数据访问权限"，"系统"设置图标… | 将 username 设置为 YandexGamesSDK.玩家名称"。 第 4 行 —— "YandexGames…"、"加载玩家信息时出错"，"系统"设置图标… | 将 username 设置为"匿名用户""。](../../_images/construct-3/authorization-and-data/fetch-player-info.webp)

## 游戏内数据 {#ingame-data}

要处理用户的游戏内数据，请使用以下操作：

- **Get player data** —— 请求用户的游戏内数据并将其写入 JSON 对象。
- **Set player data** —— 从 JSON 对象将用户的游戏内数据发送到 Yandex Games。
- **Get player stats** —— 请求用户的数值数据并将其写入 JSON 对象。
- **Set player stats** —— 从 JSON 对象将用户的数值数据发送到 Yandex Games。
- **Increment player stats** —— 将用户的数值数据增加指定值。

![Construct 3 截图：使用 YandexGamesSDK 插件配置用户数据的界面。 绿色文字"全局数字 游戏进度 = 0"。 下方是一个三列两行的表格。 第 1 行 —— "加载游戏函数"、"YandexGamesSDK"，在接下来的两行中，"系统"设置图标、"从键 "" 获取玩家数据并保存到 (PlayerDataJSON.，"、"等待之前的操作完成"、"将 游戏进度 设置为 int(PlayerDataJSON.获取("levelprogress"))"。 第 2 行 —— "保存游戏函数"、"PlayerDataJSON, YandexGamesSDK"、"将键 "levelprogress" 的值设置为 游戏进度，使用 PlayerDataJSON 保存玩家数据。 Flush: True."](../../_images/construct-3/authorization-and-data/player-data.webp)

{% note warning %}

所有这些操作都是异步的，执行需要一定时间。 为避免错误，请使用 **Wait for previous actions** 操作。

{% endnote %}

---


<!-- source: zh/_includes/sdk/button-git.md -->
<a href="https://github.com/yandex-games-plugins/construct3">
  <span class="button">存储库</span>
</a>
<!-- endsource: zh/_includes/sdk/button-git.md -->
