coolhty 发表于 2025-6-27 18:10:59

大佬帮看看关于getmonbyuserid返回值的问题

本帖最后由 coolhty 于 2025-6-27 18:42 编辑

local monobj = getmonbyuserid(mapid, monId)
if monobj then
      humanhp(monobj, "-", 999, nil, nil, actor, 1)
end

monobj做了判断,如果是空不处理,但是引擎会报错:
Func Fail, obj is nil: HumanHP Chrid: 00000000000000000000000000000000 Npc: QFunction tc:stack traceback:
      : in function 'humanhp'

每天都会有,偶尔出现这个错误日志

w1798360633 发表于 6 天前

if monobj then   改成   if monobj ~= nil then

zhaowei 发表于 6 天前

w1798360633 发表于 2025-7-1 19:12
if monobj then   改成   if monobj ~= nil then

这样写也没用

a69783616 发表于 6 天前

humanhp是针对人物对象的,用setbaseinfo

w1798360633 发表于 6 天前

zhaowei 发表于 2025-7-1 19:40
这样写也没用
getmonbyuserid(mapid, monUserId, monobj)
if monobj ~= nil then
      humanhp(monobj, "-", 999, nil, nil, actor, 1)
end


这样呢

w1798360633 发表于 6 天前

a69783616 发表于 2025-7-1 19:59
humanhp是针对人物对象的,用setbaseinfo

怪物可以的

coolhty 发表于 3 天前

w1798360633 发表于 2025-7-1 19:12
if monobj then   改成   if monobj ~= nil then

应该不是这个问题。正常是没问题的,偶尔会有这种情况。
页: [1]
查看完整版本: 大佬帮看看关于getmonbyuserid返回值的问题