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