Files
netease-modsdk-wiki/docs/mcdocs/2-Apollo/4-SDK/1-大厅与游戏服事件.md
2025-03-18 14:46:12 +08:00

247 lines
6.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
sidebarDepth: 1
---
# <span id="1-大厅与游戏服事件"></span>1-大厅与游戏服事件
事件的定义。
<span id="服务器"></span>
## 服务器
<span id="MasterConnectStatusEvent"></span>
### MasterConnectStatusEvent
- 描述
master成功连接到当前服务器事件
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| isConnect | int | 1代表连接建立0代表连接中断 |
| serverId | int | 当前lobby/game服务器id |
- 返回值
<span id="MasterForceShutDownEvent"></span>
### MasterForceShutDownEvent
- 描述
不建议开发者使用,强制关闭当前服务器时会触发本事件
- 返回值
<span id="MasterGraceShutDownEvent"></span>
### MasterGraceShutDownEvent
- 描述
不建议开发者使用,优雅关闭当前服务器时会触发本事件
- 返回值
<span id="ServerWillShutDownEvent"></span>
### ServerWillShutDownEvent
- 描述
不建议开发者使用游戏即将强制关闭触发本事件。事件回调函数需要好清理和存档工作同时终止或强制join所有异步线程
- 返回值
<span id="ServiceConnectEvent"></span>
### ServiceConnectEvent
- 描述
service与lobby/game的成功建立连接事件
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | service的服务器id |
| serviceType | str | service的服务器类型 |
- 返回值
<span id="ServiceDisconnectEvent"></span>
### ServiceDisconnectEvent
- 描述
service与lobby/game断开连接事件
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | service的服务器id |
- 返回值
<span id="ServiceRegisterModuleEvent"></span>
### ServiceRegisterModuleEvent
- 描述
不建议开发者使用service向lobby/game注册module
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | service服务器id |
| moduleName | str | 模块名是公共配置中module_names中某个module |
- 返回值
<span id="配置"></span>
## 配置
<span id="ReloadCommonConfigEvent"></span>
### ReloadCommonConfigEvent
- 描述
不建议开发者使用,公共配置发生变化时触发本事件,注意只有与本服相关配置发生变化时才会触发本事件,比如日志等级
- 返回值
<span id="玩家"></span>
## 玩家
<span id="MasterResponseTransferFailServerEvent"></span>
### MasterResponseTransferFailServerEvent
- 描述
转服失败事件,当玩家试图转服时,没有符合条件的目标服务器时抛出此事件
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| uid | int/long | 玩家uid玩家的唯一标识 |
| reason | int | 失败的错误码serverApi.GetMinecraftEnum().TransferServerFailReason |
- 返回值
<span id="MasterResponseTransferSucServerEvent"></span>
### MasterResponseTransferSucServerEvent
- 描述
转服成功事件,当玩家试图转服时,成功定位到可转服的目标服务器时抛出此事件
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| uid | int/long | 玩家uid玩家的唯一标识 |
- 返回值
<span id="ServerGetPlayerLockEvent"></span>
### ServerGetPlayerLockEvent
- 描述
玩家登录到lobby/game过程中获取玩家在线锁事件。事件触发时玩家还处于开始登录阶段
还没有下载行为包且没有在地图中出生。在线锁实质是redis中记录的玩家在线信息redis key格式
是“user:online: + netease uid”它是个hash表包含两个hash key:serverid,proxyid
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| uid | int/long | 玩家的netease uid玩家的唯一标识 |
| serverId | int | 当前服务器id |
| proxyId | int | 当前客户端连接的proxy服务器id |
- 返回值
<span id="ServerPlayerBornPosEvent"></span>
### ServerPlayerBornPosEvent
- 描述
创建玩家对象过程中,设置玩家出生位置时触发本事件
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| userId | int | 玩家的netease uid |
| dimensionId | int | 玩家出生dimension支持修改 |
| posx | int | 玩家出生位置,支持修改 |
| posy | int | 玩家出生位置,支持修改 |
| posz | int | 玩家出生位置,支持修改 |
| deltax | int | 玩家motion位置初始值为存档中的数据。若修改了posx/posy/posz则建议设置为0。 |
| deltay | int | 玩家motion位置初始值为存档中的数据。若修改了posx/posy/posz则建议设置为0。 |
| deltaz | int | 玩家motion位置初始值为存档中的数据。若修改了posx/posy/posz则建议设置为0。 |
| rotx | int | 玩家的rot初始值为存档中的数据支持修改 |
| roty | int | 玩家的rot初始值为存档中的数据支持修改 |
| ret | bool | 是否需要修改玩家初始位置设置为True后其他数据的修改才会生效 |
| retRespawn | bool | 是否需要设置玩家的重生位置仅在ret设置True时生效。设置True时会使用dimensionIdposxposyposz设置玩家的重生位置。如果修改了dimensionId请务必将这个字段设为True否则可能引起崩溃。 |
- 返回值
<span id="ServerReleasePlayerLockEvent"></span>
### ServerReleasePlayerLockEvent
- 描述
玩家下线过程中释放在redis中的玩家在线锁事件。事件触发时客户端同服务端断开了连接
家数据已经保存到地图玩家已经不存在于mc的世界中。在线锁实质是redis中记录的玩家在线信息
redis key格式是“user:online: + netease uid”它是个hash表包含两个hash key:serverid,proxyid
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| uid | int/long | 玩家的netease uid玩家的唯一标识 |
- 返回值
<span id="ServerReleasePlayerLockOnShutDownEvent"></span>
### ServerReleasePlayerLockOnShutDownEvent
- 描述
不建议开发者使用游戏强制关闭过程中玩家强制下线时触发本事件。事件回调函数需要释放在redis中的
玩家的在线锁
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| idx | int | 事件唯一id回调时返回 |
| uid | int/long | 玩家的netease uid玩家的唯一标识 |
- 返回值
<span id="StoreBuySuccServerEvent"></span>
### StoreBuySuccServerEvent
- 描述
玩家游戏内购买商品时服务端抛出的事件
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| playerId | str | 玩家id |
- 返回值