Lua接口/服务端/GetLevel:修订间差异
来自雪舞天龙知识库
跳到导航跳到搜索
整理当前服务端 Lua 接口:注册名称、参数、返回值与调用说明 |
维护服务端 Lua 接口:核对参数、返回值、边界条件与调用示例 |
||
| (未显示2个用户的8个中间版本) | |||
| 第1行: | 第1行: | ||
__NOTOC__ | __NOTOC__ | ||
<div class="lua-reference | <div class="lua-reference"> | ||
[[首页|首页]] · [[Lua接口/服务端函数索引|服务端接口]] · [[Lua接口/服务端函数索引/角色属性与物品|角色属性与物品]] · [[Lua接口/服务端调用约定|调用约定]] | [[首页|首页]] · [[Lua接口/服务端函数索引|服务端接口]] · [[Lua接口/服务端函数索引/角色属性与物品|角色属性与物品]] · [[Lua接口/服务端调用约定|调用约定]] | ||
<div | <div class="lua-lead lua-rule">读取角色当前等级。</div> | ||
同一接口的其他调用名称:<code | 同一接口的其他调用名称:<code>LuaFnGetLevel</code>。 | ||
== Lua 调用 == | == Lua 调用 == | ||
<pre | <pre>GetLevel(sceneId, selfId)</pre> | ||
服务端脚本中共出现 1024 处调用,实参个数出现过:2 个(1024 处)。 | |||
实现位于 <code>LuaFnTbl_Attr.h</code>。 | |||
== 参数 == | == 参数 == | ||
{| class="wikitable | {| class="wikitable" | ||
! scope="col" | ! scope="col" class="lua-w11" | 序号 | ||
! scope="col" | ! scope="col" class="lua-w36" | 参数 / 类型 | ||
! scope="col | ! scope="col" | 说明 | ||
|- | |- | ||
| 1 | |||
| <code>sceneId</code><br /><span class="lua-muted"><code>number</code></span> | |||
| | | 当前调用所在的场景 ID。<br /><span class="lua-muted">脚本中的实参:<code>sceneId</code>(1020 处)、<code>s</code>(4 处)</span> | ||
|- | |- | ||
| 2 | |||
| <code>selfId</code><br /><span class="lua-muted"><code>number</code></span> | |||
| | | 当前场景内的对象 ID。玩家接口需传入有效玩家对象;不是角色 GUID。<br /><span class="lua-muted">脚本中的实参:<code>selfId</code>(870 处)、<code>member</code>(28 处)、<code>nPlayerId</code>(25 处)</span> | ||
|} | |} | ||
| 第29行: | 第33行: | ||
== 调用示例 == | == 调用示例 == | ||
<pre | <pre>local level = GetLevel(sceneId, selfId) | ||
if level >= 40 then | if level >= 40 then | ||
-- 满足 40 级要求后的业务逻辑 | -- 满足 40 级要求后的业务逻辑 | ||
| 第36行: | 第40行: | ||
== 注意事项 == | == 注意事项 == | ||
* 调用对象必须是当前场景中的有效角色对象,可包括玩家、怪物或珍兽。 | * 调用对象必须是当前场景中的有效角色对象,可包括玩家、怪物或珍兽。 | ||
</div> | </div> | ||
2026年10月27日 (二) 12:33的最新版本
读取角色当前等级。
同一接口的其他调用名称:LuaFnGetLevel。
Lua 调用
GetLevel(sceneId, selfId)
服务端脚本中共出现 1024 处调用,实参个数出现过:2 个(1024 处)。
实现位于 LuaFnTbl_Attr.h。
参数
| 序号 | 参数 / 类型 | 说明 |
|---|---|---|
| 1 | sceneIdnumber
|
当前调用所在的场景 ID。 脚本中的实参: sceneId(1020 处)、s(4 处)
|
| 2 | selfIdnumber
|
当前场景内的对象 ID。玩家接口需传入有效玩家对象;不是角色 GUID。 脚本中的实参: selfId(870 处)、member(28 处)、nPlayerId(25 处)
|
返回值
返回角色等级(number);对象无效等失败路径返回 -1。
调用示例
local level = GetLevel(sceneId, selfId)
if level >= 40 then
-- 满足 40 级要求后的业务逻辑
end
注意事项
- 调用对象必须是当前场景中的有效角色对象,可包括玩家、怪物或珍兽。