|
|
| (未显示2个用户的5个中间版本) |
| 第1行: |
第1行: |
| __NOTOC__ | | __NOTOC__ |
| <div class="lua-reference" style="max-width:1200px;margin:0 auto;line-height:1.8;color:#29343a;font-family:Arial,'Microsoft YaHei',sans-serif;letter-spacing:0;overflow-wrap:anywhere;"> | | <div class="lua-reference"> |
| [[首页|首页]] · [[Lua接口/服务端函数索引|服务端接口]] · [[Lua接口/服务端函数索引/角色属性与物品|角色属性与物品]] · [[Lua接口/服务端调用约定|调用约定]] | | [[首页|首页]] · [[Lua接口/服务端函数索引|服务端接口]] · [[Lua接口/服务端函数索引/角色属性与物品|角色属性与物品]] · [[Lua接口/服务端调用约定|调用约定]] |
|
| |
|
| <div style="padding:14px 0;border-top:3px solid #287568;border-bottom:1px solid #dbe3e6;">统计指定物品的数量,包括已装备物品与背包物品。</div> | | <div class="lua-lead lua-rule">统计指定物品的数量,包括已装备物品与背包物品。</div> |
|
| |
|
| <div style="margin:10px 0;padding:10px 12px;border-left:3px solid #9a7940;background:#faf7f0;font-size:13px;color:#5f5136;">本页由服务端绑定源码与随包脚本自动整理:用途、参数位置与返回数量取实现体,<b>未在游戏内执行验证</b>。调用点取自 4244 个服务端脚本中的 195 处真实调用。</div> | | 同一接口的其他调用名称:<code>LuaFnGetItemCount</code>。 |
|
| |
|
| 同一接口的其他调用名称:<code style="white-space:normal;overflow-wrap:anywhere;">LuaFnGetItemCount</code>。
| | == Lua 调用 == |
| | <pre>GetItemCount(sceneId, selfId, itemTypeSn)</pre> |
|
| |
|
| == Lua 调用 ==
| | 服务端脚本中共出现 205 处调用,实参个数出现过:3 个(205 处)。 |
| <pre style="white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.7;padding:12px;background:#f5f7f8;border:1px solid #dbe3e6;">GetItemCount(sceneId, selfId, itemTypeSn)</pre>
| |
|
| |
|
| 服务端脚本中共出现 195 处调用,实参个数出现过:3 个(195 处)。
| | 实现位于 <code>LuaFnTbl_Attr.h</code>。 |
|
| |
|
| == 参数 == | | == 参数 == |
| {| class="wikitable" style="width:100%;table-layout:fixed;border-collapse:collapse;font-size:13px;" | | {| class="wikitable" |
| ! scope="col" style="text-align:left;background:#edf3f2;padding:8px;width:11%;" | 序号 | | ! scope="col" class="lua-w11" | 序号 |
| ! scope="col" style="text-align:left;background:#edf3f2;padding:8px;width:36%;" | 参数 / 类型 | | ! scope="col" class="lua-w36" | 参数 / 类型 |
| ! scope="col" style="text-align:left;background:#edf3f2;padding:8px;" | 说明 | | ! scope="col" | 说明 |
| |- | | |- |
| | style="padding:8px;vertical-align:top;overflow-wrap:anywhere;" | 1
| | | 1 |
| | style="padding:8px;vertical-align:top;overflow-wrap:anywhere;" | <code style="white-space:normal;overflow-wrap:anywhere;">sceneId</code><br /><span style="color:#657078;"><code style="white-space:normal;overflow-wrap:anywhere;">number</code></span>
| | | <code>sceneId</code><br /><span class="lua-muted"><code>number</code></span> |
| | style="padding:8px;vertical-align:top;overflow-wrap:anywhere;" | 当前调用所在的场景 ID。<br /><span style="color:#657078;">脚本中的实参:<code style="white-space:normal;overflow-wrap:anywhere;">sceneId</code>(195 处)</span>
| | | 当前调用所在的场景 ID。<br /><span class="lua-muted">脚本中的实参:<code>sceneId</code>(205 处)</span> |
| |- | | |- |
| | style="padding:8px;vertical-align:top;overflow-wrap:anywhere;" | 2
| | | 2 |
| | style="padding:8px;vertical-align:top;overflow-wrap:anywhere;" | <code style="white-space:normal;overflow-wrap:anywhere;">selfId</code><br /><span style="color:#657078;"><code style="white-space:normal;overflow-wrap:anywhere;">number</code></span>
| | | <code>selfId</code><br /><span class="lua-muted"><code>number</code></span> |
| | style="padding:8px;vertical-align:top;overflow-wrap:anywhere;" | 当前场景内的对象 ID。玩家接口需传入有效玩家对象;不是角色 GUID。<br /><span style="color:#657078;">脚本中的实参:<code style="white-space:normal;overflow-wrap:anywhere;">selfId</code>(183 处)、<code style="white-space:normal;overflow-wrap:anywhere;">curOwner</code>(7 处)、<code style="white-space:normal;overflow-wrap:anywhere;">humanObjId</code>(2 处)</span>
| | | 当前场景内的对象 ID。玩家接口需传入有效玩家对象;不是角色 GUID。<br /><span class="lua-muted">脚本中的实参:<code>selfId</code>(193 处)、<code>curOwner</code>(7 处)、<code>humanObjId</code>(2 处)</span> |
| |- | | |- |
| | style="padding:8px;vertical-align:top;overflow-wrap:anywhere;" | 3
| | | 3 |
| | style="padding:8px;vertical-align:top;overflow-wrap:anywhere;" | <code style="white-space:normal;overflow-wrap:anywhere;">itemTypeSn</code><br /><span style="color:#657078;"><code style="white-space:normal;overflow-wrap:anywhere;">number</code></span>
| | | <code>itemTypeSn</code><br /><span class="lua-muted"><code>number</code></span> |
| | style="padding:8px;vertical-align:top;overflow-wrap:anywhere;" | ItemType的9位数号(实际为8位)<br /><span style="color:#657078;">脚本中的实参:<code style="white-space:normal;overflow-wrap:anywhere;">demandItemId</code>(44 处)、<code style="white-space:normal;overflow-wrap:anywhere;">40002000</code>(27 处)、<code style="white-space:normal;overflow-wrap:anywhere;">itemdataId</code>(18 处)</span>
| | | ItemType的9位数号(实际为8位)<br /><span class="lua-muted">脚本中的实参:<code>demandItemId</code>(46 处)、<code>40002000</code>(28 处)、<code>itemdataId</code>(19 处)</span> |
| |} | | |} |
|
| |
|
| 第37行: |
第37行: |
|
| |
|
| == 调用示例 == | | == 调用示例 == |
| <pre style="white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.7;padding:12px;background:#f5f7f8;border:1px solid #dbe3e6;">-- itemTypeSn 是待检查的物品配置编号 | | <pre>-- itemTypeSn 是待检查的物品配置编号 |
| local count = GetItemCount(sceneId, selfId, itemTypeSn) | | local count = GetItemCount(sceneId, selfId, itemTypeSn) |
| if count >= 5 then | | if count >= 5 then |
| -- 已装备与背包中的该物品合计至少 5 个 | | -- 已装备与背包中的该物品合计至少 5 个 |
| end</pre> | | end</pre> |
|
| |
| == 脚本中的调用 ==
| |
| 以下是服务端脚本里的真实调用点,按实参形态去重后列出 8 条。这些调用取自随包发布的脚本,可用于确认参数顺序与实际传入的值;它们不代表该写法在当前版本仍然有效。
| |
| <pre style="white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.7;padding:12px;background:#f5f7f8;border:1px solid #dbe3e6;">-- event/caoyun/ecaoyun.lua
| |
| GetItemCount(sceneId, selfId, x311010_g_CashItem_id)
| |
|
| |
| -- event/caoyun/ecaoyun.lua
| |
| GetItemCount(sceneId, selfId, item.id)
| |
|
| |
| -- event/chuansong/echuansong_to_petisland.lua
| |
| GetItemCount(sceneId, selfId, 40002000)
| |
|
| |
| -- event/chuansong/team.lua
| |
| GetItemCount(sceneId, followMembers[i], x400900_g_Yinpiao)
| |
|
| |
| -- event/chuansong/team.lua
| |
| GetItemCount(sceneId, drideTargetID, x400900_g_Yinpiao)
| |
|
| |
| -- event/city/ecity_0101seekore.lua
| |
| GetItemCount(sceneId, selfId, itemdataId)
| |
|
| |
| -- event/city/ecity_0104collectfoundrymat.lua
| |
| GetItemCount(sceneId, selfId, demandItemId)
| |
|
| |
| -- event/city/ecity_0104collectfoundrymat.lua
| |
| GetItemCount(sceneId, curOwner, demandItemId)</pre>
| |
|
| |
|
| == 注意事项 == | | == 注意事项 == |
| 第73行: |
第47行: |
| * 统计范围包括已装备物品,以及按物品类型选择的普通、材料或任务背包;不包含银行,不过滤交易锁、密码锁或绑定状态。 | | * 统计范围包括已装备物品,以及按物品类型选择的普通、材料或任务背包;不包含银行,不过滤交易锁、密码锁或绑定状态。 |
| * 该数量不能直接当成可扣除数量。只统计背包中未加交易锁、未加密码锁的物品,使用 [[Lua接口/服务端/LuaFnGetAvailableItemCount|LuaFnGetAvailableItemCount]]。 | | * 该数量不能直接当成可扣除数量。只统计背包中未加交易锁、未加密码锁的物品,使用 [[Lua接口/服务端/LuaFnGetAvailableItemCount|LuaFnGetAvailableItemCount]]。 |
| * 调用前要求玩家处于可执行逻辑的状态(实现体断言 <code style="white-space:normal;overflow-wrap:anywhere;">pHuman->IsCanLogic()</code>);不满足时会记录断言,应先确认玩家当前状态。 | | * 调用前要求玩家处于可执行逻辑的状态(实现体断言 <code>pHuman->IsCanLogic()</code>);不满足时会记录断言,应先确认玩家当前状态。 |
| | |
| <div style="margin-top:20px;padding-top:10px;border-top:1px solid #dbe3e6;color:#657078;font-size:12px;">核对依据:<code style="white-space:normal;overflow-wrap:anywhere;">LuaFnTbl_Attr.h</code> 第 2793 行,服务端注册表第 329、829 行。调用格式与返回数量依据当前实现整理;脚本调用点取自 4244 个随包脚本(共 535888 行、命中 85384 处调用),未经运行验证。游戏内效果、边界行为及未注明的业务枚举仍需实测。</div>
| |
|
| |
|
| </div> | | </div> |
首页 · 服务端接口 · 角色属性与物品 · 调用约定
统计指定物品的数量,包括已装备物品与背包物品。
同一接口的其他调用名称:LuaFnGetItemCount。
Lua 调用
GetItemCount(sceneId, selfId, itemTypeSn)
服务端脚本中共出现 205 处调用,实参个数出现过:3 个(205 处)。
实现位于 LuaFnTbl_Attr.h。
参数
| 序号
|
参数 / 类型
|
说明
|
| 1
|
sceneId
number
|
当前调用所在的场景 ID。 脚本中的实参:sceneId(205 处)
|
| 2
|
selfId
number
|
当前场景内的对象 ID。玩家接口需传入有效玩家对象;不是角色 GUID。 脚本中的实参:selfId(193 处)、curOwner(7 处)、humanObjId(2 处)
|
| 3
|
itemTypeSn
number
|
ItemType的9位数号(实际为8位) 脚本中的实参:demandItemId(46 处)、40002000(28 处)、itemdataId(19 处)
|
返回值
返回指定物品的累计数量(number)。找不到物品时为 0,对象无效等失败路径为 -1。
调用示例
-- itemTypeSn 是待检查的物品配置编号
local count = GetItemCount(sceneId, selfId, itemTypeSn)
if count >= 5 then
-- 已装备与背包中的该物品合计至少 5 个
end
注意事项
- 调用对象必须是当前场景中的有效玩家。
- 统计范围包括已装备物品,以及按物品类型选择的普通、材料或任务背包;不包含银行,不过滤交易锁、密码锁或绑定状态。
- 该数量不能直接当成可扣除数量。只统计背包中未加交易锁、未加密码锁的物品,使用 LuaFnGetAvailableItemCount。
- 调用前要求玩家处于可执行逻辑的状态(实现体断言
pHuman->IsCanLogic());不满足时会记录断言,应先确认玩家当前状态。