|
发表于 2016-5-9 13:36:11
|
显示全部楼层
这个【重连提示】是 mushclient 的老问题了。 断线情况下有任何输入都会导致出现提示对话框。挂机网络不稳定会经常出现这个对话框,点确定, mushcllient 就会崩溃退出。
我研究了下 mushclient 源代码
bool CMUSHclientDoc::CheckConnected (void)
{
// let them know if they are foolishly trying to send to a closed connection
// no reconnecting while we are trying to disconnect
if (m_iConnectPhase == eConnectDisconnecting)
return true;
// if no socket, ask if they want one
if (m_iConnectPhase != eConnectConnectedToMud || !m_pSocket)
{
// forget it for this address
if (m_server == "0.0.0.0")
return true;
CString str;
if (m_iConnectPhase != eConnectNotConnected)
{
str = TFormat ("The connection to %s is currently being established.",
(LPCTSTR) m_mush_name);
UMessageBox (str, MB_ICONINFORMATION);
}
else
{
str = TFormat ("The connection to %s is not open. Attempt to reconnect?",
(LPCTSTR) m_mush_name);
if (UMessageBox (str, MB_YESNO | MB_ICONQUESTION) == IDYES)
{
ConnectSocket ();
Frame.FixUpTitleBar ();
UpdateAllViews (NULL); // make sure title bar is updated
}
}
return true;
}
return false;
} // end of CMUSHclientDoc::CheckConnected
红色字就是避免出现这个提示框关键。
你只要把的服务器 ip 地址设置为 0.0.0.0 就直接return 不执行后面代码
你需要在你的机器人写上这个2个函数
function clean_WorldAddress()
local address=world.WorldAddress() --原始地址
world.SetVariable("world_address",address) --保存入变量
world.SetAlphaOption("site","0.0.0.0") --清除掉
end
function set_WorldAddress()
local address=world.GetVariable("world_address") or world.WorldAddress()
world.SetAlphaOption("site",address)
end
set_WorldAddress() --启动脚本时候将变量值自动赋值
重连插件中 连接事件 也要写上
function OnPluginConnect()
auto_connect=true
--恢复所有暂停的计时器
world.Execute("/Timer_Resume()")
world.Execute("/clean_WorldAddress()")
button()
ColourNote("white", "red", "连上书剑世界!!")
world.EnableTimer("reconnect_timer",false)
world.DeleteTimer("reconnect_timer")
Enable_AFK()
end
function sj_Connect()
connect_count=connect_count+1
if connect_count>9999 then
ColourNote("white", "red", "离开书剑世界!!")
world.EnableTimer("reconnect_timer",false)
world.EnableTimer("heart_timer",false)
return
end
local reset_sec=5*connect_count
local reset_min=0
world.ColourNote("white", "red", "断线,启动自动连接"..reset_sec.."秒开启连接")
world.Execute("/set_WorldAddress()")
local hour=math.floor(reset_sec/3600)
reset_sec=reset_sec-hour*3600
local mins=math.floor(reset_sec/60)
reset_sec=reset_sec-mins*60
world.SetTimerOption("reconnect_timer","hour",hour)
world.SetTimerOption("reconnect_timer","minute",mins)
world.SetTimerOption("reconnect_timer","second",reset_sec)
for k, v in pairs (GetWorldIdList ()) do
if v==world.GetWorldID() then
--print("激活:world"..k)
world.DoCommand("world"..k)
world.DoCommand("Connect")
break
end
end
--world.Connect()
end |
|