|
|
| (未显示2个用户的6个中间版本) |
| 第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 个服务端脚本中的 206 处真实调用。</div>
| |
|
| |
|
| == Lua 调用 == | | == Lua 调用 == |
| <pre style="white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.7;padding:12px;background:#f5f7f8;border:1px solid #dbe3e6;">LuaFnDelAvailableItem(sceneId, selfId, itemTypeSn, delCount)</pre> | | <pre>LuaFnDelAvailableItem(sceneId, selfId, itemTypeSn, delCount)</pre> |
|
| |
|
| 服务端脚本中共出现 206 处调用,实参个数出现过:4 个(206 处)。 | | 服务端脚本中共出现 206 处调用,实参个数出现过:4 个(206 处)。 |
| | |
| | 实现位于 <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>(206 处)</span>
| | | 当前调用所在的场景 ID。<br /><span class="lua-muted">脚本中的实参:<code>sceneId</code>(206 处)</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>(205 处)、<code style="white-space:normal;overflow-wrap:anywhere;">maleId</code></span>
| | | 当前场景内的对象 ID。玩家接口需传入有效玩家对象;不是角色 GUID。<br /><span class="lua-muted">脚本中的实参:<code>selfId</code>(205 处)、<code>maleId</code></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;" | 物品配置编号,不是背包格子编号。<br /><span style="color:#657078;">脚本中的实参:<code style="white-space:normal;overflow-wrap:anywhere;">Mat.ID</code>(52 处)、<code style="white-space:normal;overflow-wrap:anywhere;">demandItemId</code>(9 处)、<code style="white-space:normal;overflow-wrap:anywhere;">itemId</code>(4 处)</span>
| | | 物品配置编号,不是背包格子编号。<br /><span class="lua-muted">脚本中的实参:<code>Mat.ID</code>(52 处)、<code>demandItemId</code>(9 处)、<code>itemId</code>(4 处)</span> |
| |- | | |- |
| | style="padding:8px;vertical-align:top;overflow-wrap:anywhere;" | 4
| | | 4 |
| | style="padding:8px;vertical-align:top;overflow-wrap:anywhere;" | <code style="white-space:normal;overflow-wrap:anywhere;">delCount</code><br /><span style="color:#657078;"><code style="white-space:normal;overflow-wrap:anywhere;">number</code></span>
| | | <code>delCount</code><br /><span class="lua-muted"><code>number</code></span> |
| | style="padding:8px;vertical-align:top;overflow-wrap:anywhere;" | 要扣除的总数量,应为正整数。当前实现对 0 或负数直接返回 1,不执行扣除。<br /><span style="color:#657078;">脚本中的实参:<code style="white-space:normal;overflow-wrap:anywhere;">1</code>(65 处)、<code style="white-space:normal;overflow-wrap:anywhere;">nCount</code>(52 处)、<code style="white-space:normal;overflow-wrap:anywhere;">num</code>(9 处)</span>
| | | 要扣除的总数量,应为正整数。当前实现对 0 或负数直接返回 1,不执行扣除。<br /><span class="lua-muted">脚本中的实参:<code>1</code>(66 处)、<code>nCount</code>(52 处)、<code>num</code>(9 处)</span> |
| |} | | |} |
|
| |
|
| 第39行: |
第39行: |
|
| |
|
| == 调用示例 == | | == 调用示例 == |
| <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 needCount = 5 | | local needCount = 5 |
| if LuaFnGetAvailableItemCount(sceneId, selfId, itemTypeSn) >= needCount then | | if LuaFnGetAvailableItemCount(sceneId, selfId, itemTypeSn) >= needCount then |
| 第49行: |
第49行: |
| end | | end |
| 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/city/ecity_0101seekore.lua
| |
| LuaFnDelAvailableItem(sceneId, selfId, demandItemId, 1)
| |
|
| |
| -- event/city/ecity_0204collectseed.lua
| |
| LuaFnDelAvailableItem(sceneId, selfId, demandItemId, demandItemCount)
| |
|
| |
| -- event/city/ecity_0504collectgems.lua
| |
| LuaFnDelAvailableItem(sceneId, selfId, demandItemId, nCountNeeded)
| |
|
| |
| -- event/city/ecity_spy.lua
| |
| LuaFnDelAvailableItem(sceneId, selfId, x600045_g_SpyBook_id, 1)
| |
|
| |
| -- event/city/ecity_spy.lua
| |
| LuaFnDelAvailableItem(sceneId, selfId, x600045_g_SpyBook_id, itemNum)
| |
|
| |
| -- event/city/guild_collect.lua
| |
| LuaFnDelAvailableItem(sceneId, selfId, itemId, count)
| |
|
| |
| -- event/dali/edali_0242.lua
| |
| LuaFnDelAvailableItem(sceneId, selfId, ItemId, 1)
| |
|
| |
| -- event/dali/edali_0243.lua
| |
| LuaFnDelAvailableItem(sceneId, selfId, x210243_g_Stone.id, x210243_g_Stone.num)</pre>
| |
|
| |
|
| == 注意事项 == | | == 注意事项 == |
| 第80行: |
第54行: |
| * 跳过交易锁与密码锁物品,不限制绑定状态;可跨多个背包堆叠扣除,不操作已装备物品和银行。 | | * 跳过交易锁与密码锁物品,不限制绑定状态;可跨多个背包堆叠扣除,不操作已装备物品和银行。 |
| * 不会在扣除前检查总数量,也不提供回滚。先用 [[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> 第 3071 行,服务端注册表第 442 行。调用格式与返回数量依据当前实现整理;脚本调用点取自 4244 个随包脚本(共 535888 行、命中 85384 处调用),未经运行验证。游戏内效果、边界行为及未注明的业务枚举仍需实测。</div>
| |
|
| |
|
| </div> | | </div> |
首页 · 服务端接口 · 角色属性与物品 · 调用约定
删除未加交易锁、未加密码锁的指定物品。
Lua 调用
LuaFnDelAvailableItem(sceneId, selfId, itemTypeSn, delCount)
服务端脚本中共出现 206 处调用,实参个数出现过:4 个(206 处)。
实现位于 LuaFnTbl_Attr.h。
参数
| 序号
|
参数 / 类型
|
说明
|
| 1
|
sceneId
number
|
当前调用所在的场景 ID。 脚本中的实参:sceneId(206 处)
|
| 2
|
selfId
number
|
当前场景内的对象 ID。玩家接口需传入有效玩家对象;不是角色 GUID。 脚本中的实参:selfId(205 处)、maleId
|
| 3
|
itemTypeSn
number
|
物品配置编号,不是背包格子编号。 脚本中的实参:Mat.ID(52 处)、demandItemId(9 处)、itemId(4 处)
|
| 4
|
delCount
number
|
要扣除的总数量,应为正整数。当前实现对 0 或负数直接返回 1,不执行扣除。 脚本中的实参:1(66 处)、nCount(52 处)、num(9 处)
|
返回值
返回一个 number:正数量扣除流程报告成功为 1,失败为 0,对象无效或异常等失败路径为 -1。delCount 小于或等于 0 时直接返回 1,不扣除物品。返回 0 时仍可能已部分扣除。
调用示例
-- itemTypeSn 是有效物品配置编号
local needCount = 5
if LuaFnGetAvailableItemCount(sceneId, selfId, itemTypeSn) >= needCount then
local result = LuaFnDelAvailableItem(sceneId, selfId, itemTypeSn, needCount)
if result == 1 then
-- 扣除流程报告成功后的业务处理
else
-- 停止处理;可能已经部分扣除,不自动重试
end
end
注意事项
- 调用对象必须是当前场景中的有效玩家。
- 跳过交易锁与密码锁物品,不限制绑定状态;可跨多个背包堆叠扣除,不操作已装备物品和银行。
- 不会在扣除前检查总数量,也不提供回滚。先用 LuaFnGetAvailableItemCount 检查数量;失败后不要自动重试或直接发奖励。
- 计数与扣除是两个调用,不构成事务;
- 调用前要求玩家处于可执行逻辑的状态(实现体断言
pHuman->IsCanLogic());不满足时会记录断言,应先确认玩家当前状态。