> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 玩家分段

> 在 Game Manager 中基于统计信息、标签或货币定义 PlayFab 玩家分段，并在玩家进入分段时触发 CloudScript 操作。

玩家分段在 [Game Manager](/services/playfab/live-service-management/gamemanager/quickstart) 中定义。分段允许你定义有用或有趣的玩家群体，并对该群体执行专属操作。

## 要求

* 拥有在 PlayFab 中定义的具有和不具有独特特征的玩家。

* 已定义的 [CloudScript PlayStream Hook](/services/playfab/data-analytics/acting-data/action-rules-using-cloudscript-actions-with-playstream)。

### 示例场景：为每位达成游戏内目标的玩家运行自定义 CloudScript

玩家的*决定性特征*可能是：

* 登录时间
* 已关联的设备类型
* 标签
* 现实世界位置
* 统计值
* 虚拟货币值
* 真实货币购买等等。

对于此示例，我们的独特特征将是一个统计信息——具体来说，是达到 **50 str** 的玩家。

<Note>
  统计信息是众多可能选项之一，仅在此示例中特别需要。你可以随意用你选择的其他筛选条件替换统计信息要求。
</Note>

我们的操作是运行一个 CloudScript 函数。CloudScript 是迄今为止最灵活的触发选项，它在分段转变时为你提供玩家和分段信息的完全控制权。

从 **Game Manager** 界面中：

* 导航到你的 **Title**。
* 从左侧菜单中选择 **Players**。
* 转到 **Segments** 选项卡。
* 选择 **New Segment**。

下面显示的界面是上述 **Segment** 的示例。

<img src="https://mintcdn.com/microsoft-4404708b/IwSYTY5BEqd_x-HK/images/playfab/data-analytics/acting-data/tutorials/game-manager-players-segments-new-segment.png?fit=max&auto=format&n=IwSYTY5BEqd_x-HK&q=85&s=816790fcff260f025fe164429652ba7f" alt="Game Manager - players - segments - new segment" width="1280" height="720" data-path="images/playfab/data-analytics/acting-data/tutorials/game-manager-players-segments-new-segment.png" />

此示例中最复杂的部分是 CloudScript。在你的 [CloudScript 处理程序](/services/playfab/data-analytics/acting-data/action-rules-using-cloudscript-actions-with-playstream)中利用第二个参数 *Context* 来标识玩家以及分段转变。

之后，对玩家执行你希望的任何操作，例如授予[库存道具](/services/playfab/player-progression/player-data/player-inventory)、[虚拟货币](/services/playfab/economy-monetization/economy-v2/tutorials/currencies)、[玩家数据](/services/playfab/player-progression/player-data/quickstart)或[统计信息](/services/playfab/community/leaderboards/tournaments-leaderboards/using-player-statistics)。

另请参阅：[商店分段最佳实践](/services/playfab/economy-monetization/economy-v2/overview)


## Related topics

- [针对整个玩家分段的批量操作](/zh-CN/services/playfab/data-analytics/acting-data/action-rules-bulk-actions-for-an-entire-player-segment.md)
- [分段配置](/zh-CN/services/playfab/live-service-management/game-configuration/segmentation/segmentation-configuration.md)
- [实时服务管理概述](/zh-CN/services/playfab/live-service-management/overview.md)
- [使用玩家自定义属性进行高级分段](/zh-CN/services/playfab/live-service-management/game-configuration/segmentation/advanced-segmentation.md)
- [推送通知模板](/zh-CN/services/playfab/live-service-management/game-configuration/title-communications/push-notifications/push-notification-templates.md)
