--- sidebarDepth: 1 --- # 游戏模式 ## GetPlayerGameType 服务端客户端 ### 服务端接口 method in mod.server.component.gameCompServer.GameComponentServer - 描述 获取指定玩家的游戏模式 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | playerId | str | 玩家id | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | int | [GameType枚举](../../枚举值/GameType.md) | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateGame(levelId) gameType = comp.GetPlayerGameType(playerId) ``` ### 客户端接口 method in mod.client.component.gameCompClient.GameComponentClient - 描述 获取指定玩家的游戏模式 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | playerId | str | 玩家id | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | int | [GameType枚举](../../枚举值/GameType.md) | - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateGame(levelId) gameType = comp.GetPlayerGameType(playerId) ``` ## SetPlayerGameType 服务端 method in mod.server.component.playerCompServer.PlayerCompServer - 描述 设置玩家个人游戏模式 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | gameType | int | [GameType枚举](../../枚举值/GameType.md) | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否设置成功 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId) comp.SetPlayerGameType(serverApi.GetMinecraftEnum().GameType.Survival) ```