70 lines
1.4 KiB
Markdown
70 lines
1.4 KiB
Markdown
---
|
||
sidebarDepth: 1
|
||
---
|
||
# 游戏模式
|
||
|
||
## GetPlayerGameType
|
||
|
||
<span style="display:inline;color:#ff5555">服务端</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)
|
||
```
|
||
|
||
|
||
|
||
## SetPlayerGameType
|
||
|
||
<span style="display:inline;color:#ff5555">服务端</span>
|
||
|
||
method in mod.server.component.playerCompServer.PlayerCompServer
|
||
|
||
- 描述
|
||
|
||
设置玩家个人游戏模式
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| gameType | int | GetMinecraftEnum().GameType.*:Survival,Creative,Adventure分别为0~2 |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 是否设置成功 |
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.server.extraServerApi as serverApi
|
||
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
|
||
comp.SetPlayerGameType(serverApi.GetMinecraftEnum().GameType.Survival)
|
||
```
|
||
|
||
|
||
|