--
-- If deliberate quit, we don't need to check any more
--
if did_quit then
Note "Deliberate quit, disabling disconnection check"
EnableTimer (sName, false)
return
end -- if
--
-- OK, we need to Connect now ...
--
retry = retry + 1
Note ("Connecting to world, attempt # " .. retry)
Connect ()
end -- function
function OnPluginDisconnect ()
--
-- If deliberate quit, we don't need to enable the connection check
--
if did_quit then
return
end -- if
--
-- We have been disconnected, we need to try connecting again
--
Note "Connection checker enabled"
EnableTimer ("ConnectCheckTimer", true)
end -- function
function OnPluginConnect ()
--
-- Now we are connected, no need to keep trying to Connect
--
retry = 0
EnableTimer ("ConnectCheckTimer", false)
if IsTrigger("logging_in") == 0 then
EnableTrigger ("logging_in", true)
else
AddTrigger("logging_in", "Players Online: d*", "", 33, custom_colour.Custom15, 0, "", "loggingIn")
end
if IsTrigger("logging_in2") == 0 then
EnableTrigger ("logging_in2", true)
else
AddTrigger("logging_in2", ".*That character is already playing.", "y", 33, custom_colour.Custom15, 0, "", "")
end
if IsTrigger("logging_in3") == 0 then
EnableTrigger ("logging_in3", true)
else
AddTrigger("logging_in3", ".*You already have a different character in the game.", "", 33, custom_colour.Custom13, 0, "", "addCharNum")
end
if IsTrigger("logging_in4") == 0 then
EnableTrigger ("logging_in4", true)
else
AddTrigger("logging_in4", ".*That is not an option!", "", 33, custom_colour.Custom13, 0, "", "resetCharNum")
end
--
-- No deliberate quit yet
--
did_quit = false
end -- function
function loggingIn (name, line, wildcards)
EnableTrigger ("logging_in", false)
EnableTrigger ("logging_in2", false)
EnableTrigger ("logging_in3", false)
EnableTrigger ("logging_in4", false)
Send (charName)
Send (charPass)
Send (charNum)
end
function addCharNum (name, line, wildcards)
charNum = charNum + 1
SetVariable ("char", charNum)
end
function resetCharNum (name, line, wildcards)
charNum = 1
SetVariable ("char", charNum)
end
function OnPluginInstall ()
DoAfterNote (1, "Connection checker installed.")
DoAfterNote (1, "")
DoAfterNote (1, "Use 'setchar *' to set the character number to login to.")
for k, v in pairs (GetVariableList()) do
Note (k, " = ", v)
end
temp = GetVariable ("char")
if temp ~= charNum and temp ~= nil then
charNum = temp
else
SetVariable ("char", charNum)
end
SetVariable ("char2", "blah")
SetVariable ("char3", "blah2")
SetVariable ("char4", "blah3")
SetVariable ("char5", "blah4")
Note(temp)
Note(charNum)
end -- function
function OnPluginEnable ()
for k, v in pairs (GetVariableList()) do
Note (k, " = ", v)
end
end
]]>
function OnQuit (sName, sLine, wildcards)
--did_quit = true
Send ("&quit_command;") -- Send to world so it does it
Note "Deliberate quit (&quit_command;), reconnect disabled"
end -- function
function OnConnect (sName, sLine, wildcards)
Note "Connection checker enabled"
EnableTimer ("ConnectCheckTimer", true)
did_quit = false
end -- function
function OnNoConnect (sName, sLine, wildcards)
Note "Connection checker disabled"
EnableTimer ("ConnectCheckTimer", false)
did_quit = true
end -- function
</script>
<!-- Plugin Help -->
<aliases>
<alias
script="OnHelp"
match="Reconnecter:Help"
enabled="y"
>
</alias>
</aliases>
<script>
<![CDATA[
function OnHelp (sName, sLine, wildcards)
Note (GetPluginInfo (GetPluginID, 3))
end -- function
]]>
</script>
</muclient>
|