跳转至

用户与角色函数

GetUser(aIndex)

返回指定玩家索引的 GameObject,未连接时返回 nil。使用内部缓存以提升性能。

local player = GetUser(aIndex)
if player then
    LogAdd(LOG_BLUE, "Player: " .. player.Name .. " Level: " .. player.Level)
end

UserLogOut(aIndex)

对玩家发起优雅注销(5 秒倒计时)。

  • 返回值: boolean
UserLogOut(aIndex)

UserDisconnect(aIndex, type)

立即断开玩家连接。

  • 返回值: boolean
UserDisconnect(aIndex, 0)

UserLogOutByName(name)

通过角色名进行优雅注销。

  • 返回值: boolean
UserLogOutByName("PlayerOne")

UserDisconnectByName(name, type)

通过角色名立即断开连接。

  • 返回值: boolean
UserDisconnectByName("PlayerOne", 0)

UserKick(aIndex, reason)

断开玩家连接并可选附带通知消息。

  • 返回值: boolean
UserKick(aIndex, "You have been kicked for AFK.")

UserKickByName(name, reason)

通过角色名踢出玩家并可选附带原因。

  • 返回值: boolean
UserKickByName("BadPlayer", "Violating server rules.")

gObjAllLogOut()

对所有已连接玩家发起注销。

gObjAllLogOut()

gObjAllDisconnect(type)

立即断开所有玩家连接。

gObjAllDisconnect(0)

UserCalcAttribute(aIndex)

重新计算玩家的所有属性(属性点、伤害、防御等)。

  • 返回值: boolean
UserCalcAttribute(aIndex)

UserInfoSend(aIndex)

重新计算属性并刷新玩家的视野(外观更新)。

  • 返回值: boolean
player.Strength = player.Strength + 10
UserInfoSend(aIndex)

LevelUpSend(aIndex)

重新计算属性并向客户端发送升级通知。

  • 返回值: boolean
player.Level = player.Level + 1
player.LevelUpPoint = player.LevelUpPoint + 5
LevelUpSend(aIndex)

MasterLevelUpSend(aIndex)

重新计算属性并发送大师等级升级通知。

  • 返回值: boolean
player.MasterLevel = player.MasterLevel + 1
player.MasterPoint = player.MasterPoint + 1
MasterLevelUpSend(aIndex)

PKLevelSend(aIndex, pkLevel)

设置 PK 等级并向客户端发送外观更新。传入 -1 仅刷新。

  • 返回值: boolean
PKLevelSend(aIndex, 3) -- 设置 PK 等级为 3(英雄)

gObjDel(aIndex)

从服务器删除一个对象(用于怪物/NPC,不要用于玩家)。

  • 返回值: number
gObjDel(monsterIndex)

gObjAuthorityCodeSet(aIndex, code)

设置玩家的权限代码。

gObjAuthorityCodeSet(aIndex, 32) -- 设置 GM 权限

gObjAccountLevelExpireProc(lpObj)

处理 VIP/高级账号的等级过期。

gObjAccountLevelExpireProc(player)

gObjRebuildMasterSkillTree(lpObj)

为玩家重建大师技能树(修改大师技能后使用)。

gObjRebuildMasterSkillTree(player)

CashShopAddPoint(aIndex, WC, WP, GP)

为玩家添加商城货币点数。

CashShopAddPoint(aIndex, 100, 0, 50) -- +100 WCoin, +50 GoblinPoints