//执行脚本 //id 脚本id //play 玩家对象 public void ExecuteAction(uint id, PlayerObject play) { reset(); if (play != null) { play.ClearScriptMenuLink(); } uint nextid = id; while (true) { if (!mDicScripte.ContainsKey(nextid)) break; GameStruct.ActionInfo info = mDicScripte[nextid]; bool ret = false; //做一个异常处理,防止脚本写错服务端崩溃 try { ret = SWITCH(info, play); } catch (System.Exception ex) { Log.Instance().WriteLog(ex.Message); Log.Instance().WriteLog(ex.StackTrace); Log.Instance().WriteLog("执行脚本失败,脚本id:" + info.id.ToString() + "玩家昵称:" + play.GetName()); ret = false; } if (ret) nextid = info.id_next; else nextid = info.id_nextfail; //npc对话已经完成,发送结尾标记- if (info.id_next == 0 && mbEndTag && play != null) { NetMsg.MsgNpcReply reple = new NetMsg.MsgNpcReply(); reple.Create(null, play.GetGamePackKeyEx()); play.SendData(reple.Flush()); break; } //退出 if (nextid == 0) break; } }