function Relog(CharIndex: integer = -1): boolean; // relog to the character with the specified number
var i: integer; // (by default it comes on the same as it was)
begin
result:= false;
if (CharIndex > 6) then exit; // quit if character index is incorrect
while (User.InCombat) do delay(99); // wait until we quit the combat
// if we have a thread to disconnect, then we change the global variable,
// so that it stops working for the time of relog
// gBlockDisconnectThread:= true;
if Engine.Restart then // if you managed to restart, then
while (Engine.Status = lsOnline) do delay(999); // wait until we get to the character selection panel
Delay(5000); // wait an additional 5 seconds for loading
if (CharIndex = -1) then begin // if character index was not specified, then
if Engine.GameStart() then // go to the same character as was
while (Engine.Status <> lsOnline) do delay(999); // and look forward to entering the game
end else begin // if the character index was specified, then
if Engine.GameStart(CharIndex) then // go to the character with the specified number
while (Engine.Status <> lsOnline) do delay(999); // and similarly waiting for the entrance to the game
end;
Delay(5000); // waiting for extra time for loading
// gBlockDisconnectThread:= false; // turn on disconnect check thread back if there is one
result:= true;
end;
begin
// code ...
Relog(); // will relog to the same character
// or
Relog(3); // will relog to the 4th character (indexes 0-6)
end.