作者laechan (挥泪斩马云)
看板mud_sanc
标题Re: [wizs] error msg
时间Sun Mar 19 22:07:21 2023
执行时段错误: *Bad argument 2 to member_array()
Expected: string or array Got: 0.
程式: /d/ppl/justinj/devil/mob/mantis.c:35
物件: /d/ppl/justinj/devil/mob/mantis#253957
生物名: mantis
/d/ppl/justinj/devil/mob/mantis#253957 "heart_beat" /std/gmonster.c:123
/d/ppl/justinj/devil/mob/mantis#253957 "run_away" /d/ppl/justinj/devil/mob/mantis.c:80
/d/ppl/justinj/devil/mob/mantis#253957 "force_me" /std/mob/living.c:16
/d/ppl/justinj/devil/mob/mantis#253957 "cmd_hook" /std/gmonster.c:32
/cmds/std/_go "cmd_go" /cmds/std/_go.c:154
/d/ppl/justinj/devil/mob/mantis#253957 "move_player" /std/gmonster.c:42
/adm/daemons/mob_d "move_player" /adm/daemons/mob_d.c:378
/d/ppl/justinj/devil/mob/mantis#253957 "move" /std/ob/mob.c:60
/std/ob/ob_d "move" /std/ob/ob_d.c:52
/d/ppl/justinj/devil/mob/mantis#253957 "move_to" /std/ob/mob.c:63
/d/ppl/justinj/devil/mob/mantis#253957 "init" /d/ppl/justinj/devil/mob/mantis.c:35
void init()
{
object ppl=this_player();
::init();
if(ppl->query("npc"))//怪物类
{
if(member_array("center",ppl->query("id"))> -1)//塔
kill_ob(ppl);
}
}
我的经验是,member_array("center",ppl->query("id")) 这个如果会
出错,八成是 ppl->query("id") 读到的东西为
1. 空
2. 非 array
通常我会改成 member_array("center",(mixed)ppl->query("id")) 来
避免错误,或是
if(ppl->query("npc") && ppl->query("id"))
另外,ppl 并不一定是玩家,能触发怪物 init 函数的只要是生物
都有可能。
Laechan
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 59.126.145.135 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/mud_sanc/M.1679234844.A.665.html
※ 编辑: laechan (59.126.145.135 台湾), 03/19/2023 22:08:09
1F:推 justinj : 这个是我修改过後的..之前没判断npc会出这个问题 03/20 11:13
2F:→ justinj : 原程式 if(member_array("center",ppl->query("id") 03/20 11:15
3F:→ justinj : > -1 || //塔 或 03/20 11:15
4F:→ laechan : soga, ok 03/20 13:36