Re: [wizs] error msg
看板mud_sanc (Sanctuary - 聖殿)作者laechan (揮淚斬馬雲)時間2年前 (2023/03/19 22:07)推噓1(1推 0噓 3→)留言4則, 2人參與討論串2/3 (看更多)
執行時段錯誤: *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://www.ptt.cc/bbs/mud_sanc/M.1679234844.A.665.html
※ 編輯: laechan (59.126.145.135 臺灣), 03/19/2023 22:08:09
推
03/20 11:13, 
                                2年前
                            , 1F
03/20 11:13, 1F
→
03/20 11:15, 
                                2年前
                            , 2F
03/20 11:15, 2F
→
03/20 11:15, 
                                2年前
                            , 3F
03/20 11:15, 3F
→
03/20 13:36, 
                                2年前
                            , 4F
03/20 13:36, 4F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 3 篇):
                            1
                        
                            1
                        
mud_sanc 近期熱門文章
PTT遊戲區 即時熱門文章
                            10
                        
                            15
                        
                            -1
                        
                            14
                        
                            49
                        
                            59
                        
                            17
                        
                            26