这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
scripting:client:player [2023/12/02 15:31] – bibiboxs | scripting:client:player [2024/08/11 20:16] (当前版本) – bibiboxs | ||
---|---|---|---|
行 14: | 行 14: | ||
> 当某个玩家**取消绑定**了一个实体对象(开始控制角色)时调用。 | > 当某个玩家**取消绑定**了一个实体对象(开始控制角色)时调用。 | ||
+ | |||
+ | |||
+ | ### OnPlayerVoiceStateChange( player, state ) | ||
+ | |||
+ | > 当玩家语音聊天状态发生改变时调用(正在语音聊天)。 | ||
+ | |||
+ | ```javascript | ||
+ | function OnPlayerVoiceStateChange( player: Player, state: bool ) | ||
+ | ``` | ||
行 21: | 行 30: | ||
> 获取本地玩家实例对象(本地玩家自身)。 | > 获取本地玩家实例对象(本地玩家自身)。 | ||
+ | > | ||
+ | > **==注意:在专用服务器模式(`BatchMode`)下,通过服务器自身脚本访问此属性,将会得到一个空值`Null`,因为专用服务器本身并不包含本地玩家。==** | ||
+ | |||
+ | [note2] | ||
+ | 由于**专用服务器模式**本地空玩家的特殊属性,`Character`类对象提供了一个快捷检测方法:`character.IsLocal`判断是否为本地玩家角色,此方法会自动检测`Null`而不会触发异常。 | ||
+ | [/note] | ||
```javascript | ```javascript | ||
- | DLog(Player.Local.Name); | + | if(Player.Local) |
``` | ``` | ||
行 57: | 行 72: | ||
player.IsLocal: | player.IsLocal: | ||
``` | ``` | ||
+ | |||
+ | |||
+ | |||
+ | ### player.IsComplete | ||
+ | |||
+ | > 获取玩家是否完全加载完毕。 | ||
+ | |||
+ | ```javascript | ||
+ | player.IsComplete: | ||
+ | ``` | ||
+ | |||
+ | |||
+ | |||
+ | ### player.IsObserver | ||
+ | |||
+ | > 获取玩家是否当前为相机观察模式(`Client.Camera.IsObserver`)。 | ||
+ | |||
+ | ```javascript | ||
+ | player.IsObserver: | ||
+ | ``` | ||
+ | |||
行 64: | 行 100: | ||
```javascript | ```javascript | ||
- | player.Entity: | + | player.Entity: |
``` | ``` | ||
行 74: | 行 110: | ||
```javascript | ```javascript | ||
- | player.Character: | + | player.Character: |
``` | ``` | ||
行 99: | 行 135: | ||
- | ### player.RaycastPos | + | ### player.VoiceState |
- | > 获取玩家焦点实时位置(鼠标世界坐标),受视角碰撞遮挡影响,包含高度Y轴信息。 | + | > 获取玩家语音聊天状态(是否正在语音聊天)。 |
+ | > | ||
```javascript | ```javascript | ||
- | player.RaycastPos: Vector | + | player.VoiceState: bool |
``` | ``` | ||
+ | |||
+ | |||
+ | |||
+ | ## Static Function | ||
+ | |||
+ | ### Player.Find() | ||
+ | |||
+ | > 寻找一个玩家实例(通过ID),不存在则返回`null`。 | ||
+ | |||
+ | ```javascript | ||
+ | function Player.Find( id: int ): Player | ||
+ | ``` | ||
+ | |||
+ | |||
+ | |||
+ | ### Player.Search() | ||
+ | |||
+ | > 寻找一个玩家实例(通过模糊查找,通常根据玩家名称,不区分大小写),不存在则返回`null`。 | ||
+ | |||
+ | ```javascript | ||
+ | function Player.Search( any: string ): Player | ||
+ | ``` | ||
+ | |||
+ | ```javascript | ||
+ | //Players: " | ||
+ | Player.Search(" | ||
+ | Player.Search(" | ||
+ | Player.Search(" | ||
+ | ``` | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ### Player.FindByUUID() | ||
+ | |||
+ | > 寻找一个玩家实例(通过UUID),不存在则返回`null`。 | ||
+ | |||
+ | ```javascript | ||
+ | function Player.FindByUUID( uuid: string ): Player | ||
+ | ``` | ||
+ | |||
+ | |||
+ | |||
+ | ### Player.GetCount() | ||
+ | |||
+ | > 获取当前所有存在玩家数量。 | ||
+ | |||
+ | ```javascript | ||
+ | function Player.GetCount(): | ||
+ | ``` | ||
+ | |||
+ | |||
+ | |||
+ | ### Player.Get() | ||
+ | |||
+ | > 获取当前存在的指定索引玩家,通常搭配`GetCount()`遍历使用。 | ||
+ | |||
+ | ```javascript | ||
+ | function Player.Get( index: int ): Player | ||
+ | ``` | ||
+ | |||
+ | |||
+ | |||
+ | ## Function | ||
+ | |||
+ | ### player.GetObserver() | ||
+ | |||
+ | > 获取玩家视角观察对象(`Client.Camera.Target`),如不存在则返回`null`。 | ||
+ | |||
+ | ```javascript | ||
+ | function player.GetObserver(): | ||
+ | ``` | ||
+ | |||
+ | |||
</ | </ |