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

# PFMultiplayerCreateServerBackfillTicket

> 创建 PlayFab 多人游戏服务器回填票证，使有空缺槽位的游戏服务器可以与匹配队列中的其他玩家进行匹配。

创建服务器回填票证。

## 语法

```cpp theme={null}
HRESULT PFMultiplayerCreateServerBackfillTicket(  
    PFMultiplayerHandle handle,  
    const PFEntityKey* server,  
    const PFMatchmakingServerBackfillTicketConfiguration* configuration,  
    void* asyncContext,  
    PFMatchmakingTicketHandle* ticket  
)  
```

### 参数

**`handle`**   PFMultiplayerHandle

PFMultiplayer API 实例的句柄。

**`server`**   [PFEntityKey\*](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/pfentitykey_clientsdk.md)

服务器实体。

**`configuration`**   [PFMatchmakingServerBackfillTicketConfiguration\*](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmatchmaking/structs/pfmatchmakingserverbackfillticketconfiguration.md)

回填票证配置。

**`asyncContext`**   void\*\
*optional*

可选的应用定义指针大小上下文值，可用于将完成状态变更与此调用相关联。

**`ticket`**   PFMatchmakingTicketHandle\*\
*library-allocated output*

生成的票证对象。

### 返回值

类型：HRESULT

如果调用成功，则为 `S_OK`；否则为错误代码。可以通过 [PFMultiplayerGetErrorMessage()](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayergeterrormessage.md) 获取错误代码的人类可读形式。

## 备注

若要使用此功能，必须在包含 PFMatchmaking.h 之前定义 PFMULTIPLAYER\_INCLUDE\_SERVER\_APIS。\
\
&#x20;库将自动且异步地向匹配服务提交服务器回填票证。每次票证状态更改时，都会提供一个 [PFMatchmakingTicketStatusChangedStateChange](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmatchmaking/structs/pfmatchmakingticketstatuschangedstatechange.md)。可以随时通过 [PFMatchmakingTicketGetStatus()](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmatchmaking/functions/pfmatchmakingticketgetstatus.md) 查询票证状态。票证立即从 `PFMatchmakingTicketStatus::Creating` 状态开始。\
\
&#x20;当票证完成时，将提供一个 [PFMatchmakingTicketStatusChangedStateChange](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmatchmaking/structs/pfmatchmakingticketstatuschangedstatechange.md)。此时，要么找到了回填票证的匹配，要么票证因失败而停止。成功时，可以通过 [PFMatchmakingTicketGetMatch()](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmatchmaking/functions/pfmatchmakingticketgetmatch.md) 查询找到的匹配。[PFMatchmakingMatchDetails](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmatchmaking/structs/pfmatchmakingmatchdetails.md) 中的 `regionPreferences` 仅包含服务器所在的区域。\
\
&#x20;如果票证创建失败是因为配置中指定的用户票证过多，库将透明地取消这些未完成的票证，然后重试票证创建。\
\
&#x20;此函数要求先前已调用 [PFMultiplayerSetEntityToken()](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayersetentitytoken.md) 来设置游戏服务器实体令牌。

## 要求

**头文件：** PFMatchmaking.h

## 另请参阅

[PFMatchmaking 成员](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmatchmaking/pfmatchmaking_members.md)


## Related topics

- [使用服务器回填票证 - Multiplayer SDK](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/matchmaking/backfill-tickets-multiplayer-sdk.md)
- [PlayFab Multiplayer C++ SDK 发行说明](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/lobby-matchmaking-sdks/lobby-and-matchmaking-release-notes.md)
- [PFMultiplayer C/C++ API 概览 - PFMatchmaking.h](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmatchmaking/pfmatchmaking_members.md)
- [Create Server Backfill Ticket](https://docs.xbox.com/api-reference/matchmaking/create-server-backfill-ticket.md)
- [CreateServerBackfillTicket](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/unity-multiplayer-api-reference/PlayFab.Multiplayer/PlayFabMultiplayer.PlayFabMultiplayerServer/CreateServerBackfillTicket.md)
