作者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/m.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