Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function LoginPlayer: Boolean;
- var
- RetryLogin: Boolean;
- typtmp, t, w, i: integer;
- Actions: TVariantArray;
- Attempts: LongInt;
- p: TPoint;
- //ATPA: T2dPointArray;
- TPA: TPointArray;
- Boxes : TIntegerArray;
- //B: TBox;
- badworlds: TIntegerArray;
- OurCurrentworld: Integer;
- label
- ProcStart;
- begin
- ActivateClient;
- if (LoggedIn) then Exit;
- if (LobbyScreen) then
- begin
- MouseBox(WDx1, WDy1, WDx2, WDy2, mouse_Left); //Click To Play
- i := 0;
- repeat
- i := i+1;
- Wait(100 + Random(100));
- until (LoggedIn) or (i > 30);
- end;
- Wait(100 + Random(200));
- TypeByte(vk_Escape);
- Wait(200 + Random(200));
- {Check for lobby screen already open/ already logged in}
- Result := (LoggedIn);
- if (Result) then Exit;
- if (LobbyScreen) then
- begin
- MouseBox(WDx1, WDy1, WDx2, WDy2, mouse_Left); //Click To Play
- i := 0;
- repeat
- i := i+1;
- Wait(100 + Random(100));
- until (LoggedIn) or (i > 30);
- end;
- {Check for active player.}
- if (not (Players[CurrentPlayer].Active)) then
- begin
- WriteLn('Player is not Active...');
- if (AllPlayersInActive) then
- begin
- WriteLn('All players not active!');
- Exit;
- end;
- NextPlayer(False);
- Exit;
- end;
- {Wait for the client to finish loading.}
- T := GetSystemTime;
- repeat
- if (RSReady) then
- Break;
- if ((GetSystemTime - T) > 180000) then
- begin
- WriteLn('It has been 3 minutes and Runescape is not yet ready... Terminating.');
- TerminateScript;
- end;
- Wait(RandomRange(1000, 2000));
- until (False);
- if (CountColor(16777215, 408, 279, 518, 299) = 281) then //Existing User text
- begin
- WriteLn('Welcome to Runescape.');
- badworlds := [308, 316, 325, 337, 365];
- MouseBox(395, 275, 529, 307, mouse_Left); //Existing User
- Wait(RandomRange(1000, 2000));
- OurCurrentworld := currentworldls;
- if InIntArray(Badworlds, OurCurrentworld) then //If its a bad one then exist
- MouseBox(238, 309, 362, 332 ,mouse_left); //Continue
- end;
- if Length(Players[CurrentPlayer].WorldInfo) > 0 then
- SelectWorld(Players[CurrentPlayer].WorldInfo[0]);
- ProcStart:
- {Type in username and pass}
- if (loggedIn) then
- exit;
- for W:= 0 to 1 do
- begin
- if W = 0 then
- Boxes:= [UBX1, UBY1, UBX2, UBY2]
- else
- Boxes:= [PBX1, PBY1, PBX2, PBY2];
- t := (getSystemTime + (60000 * 2));
- FindColors(TPA, LOGIN_TEXTCOLOUR, Boxes[0], Boxes[1], Boxes[2], Boxes[3]);
- repeat
- if (Length(TPA) > 0) then
- begin
- SortTPAFrom(TPA, Point(Boxes[2], Boxes[1] + (Boxes[3] - Boxes[2]) div 2));
- p := point(TPA[0].X + 20, TPA[0].Y);
- if (not pointInBox(p, intToBox(Boxes[0], Boxes[1], Boxes[2], Boxes[3]))) then
- p := point(UBX2 - (10 + random(10)), p.y);
- Mouse(p.x, p.y, 2, 2, mouse_left);
- end else
- MouseBox(Boxes[0], Boxes[1], Boxes[2], Boxes[3], mouse_left);
- typtmp := 0;
- while (CountColor(LOGIN_TEXTCOLOUR, Boxes[0], Boxes[1], Boxes[2], Boxes[3]) > 0) do
- begin
- Inc(typtmp);
- TypeByte(VK_BACK);
- Wait(50+Random(50));
- if (typtmp >= RandomRange(30, 35)) then
- Break;
- end;
- until(not FindColors(TPA, LOGIN_TEXTCOLOUR, Boxes[0], Boxes[1], Boxes[2], Boxes[3]) or (getSystemTime > t));
- Wait(100 + Random(200));
- if W = 0 then
- begin
- WriteLn(Capitalize(Players[CurrentPlayer].Name));
- TypeSend(Players[CurrentPlayer].Name);
- end else
- begin
- TypeSendEx(Players[CurrentPlayer].Pass, False);
- MouseBox(234, 304, 369, 338, mouse_Left); //Login
- end;
- end;
- {Check responses}
- T := GetSystemTime;
- repeat
- // so the lobby appears (gets rid of black screen)
- if (countColorTolerance(clBlack, 0, 0, 500, 500, 20) > 245000) then
- begin
- wait(2000 + random(1500));
- mouseBox(0, 0, 750, 490, mouse_Move);
- end;
- SetLength(Actions, 0);
- if ((GetSystemTime - T) > 60000) then
- Actions := ['One minute has passed... Debug: ' + ToStr(CountColor(LOGIN_STATUSCOLOUR, 224, 190, 532, 250)), 0, 5, 'PlayerFalse', 'Login Failed']
- else
- // writeln(CountColor(LOGIN_STATUSCOLOUR, 224, 190, 532, 250));
- case (CountColor(LOGIN_STATUSCOLOUR, 224, 190, 532, 250)) of //text colour points
- // WriteLn Error Wait for Retrys Action Player[CurrentPlayer].Loc
- 738: Actions := ['Invalid Username / Password', 0, 2, 'PlayerFalse', 'Wrong User/Pass']; //Updated
- 1539: Actions := ['Your account has been disabled', 0, 0, 'PlayerFalse', 'Acc Disabled']; //Updated
- 1073: Actions := ['Your account is already logged in', 5000, 5, 'PlayerTrue', 'Already logged in']; //Updated
- 1573: Actions := ['Not a Members Account', 0, 1, 'PlayerTrue', '']; //Updated
- 492: Actions := ['Error Connecting.', 20000, 9, 'Terminate', 'Error Connecting']; //Updated
- 1721: Actions := ['Too many incorrect logins.', 5 * 60000, 2, 'PlayerFalse', 'Too many logins']; //Updated
- 906: Actions := ['This world is full.', 5000, 10, 'PlayerFalse', 'World is full']; //Updated
- 1136: Actions := ['Runescape has been updated.', 0, 0, 'RSUpdate', 'RS Updated'];
- 777: Actions := ['Login limit exceeded.', 20000, 10, '', 'Waiting for login.'];
- 1700: Actions := ['You will need a members account to login to this world. Please subscribe, or use a different world.', 0, 0, 'PlayerFalse', 'Acc Disabled']; //Updated
- end;
- {Respond}
- if (Length(Actions) > 0) then
- begin
- WriteLn(Actions[0]);
- if (Actions[0] <> 'Not a Members Account') then
- begin
- Wait(1000 + Random(500));
- end;
- Wait(Actions[1] + Random(100));
- if (Actions[2] <> 0) then
- if (Attempts < Actions[2]) or (Actions[2] = -1) then
- begin
- if (Actions[0] = 'Not a Members Account') then
- begin
- Players[CurrentPlayer].Member := False;
- if (Length(Players[CurrentPlayer].WorldInfo) > 0) then
- Players[CurrentPlayer].WorldInfo[0] := False;
- MouseBox(267, 321, 496, 350, mouse_left); //Play free game instead button TODO:Check if this is needed
- Wait(3000 + Random(2000));
- Result := True;
- Exit;
- end;
- RetryLogin := True;
- Wait(2000 + Random(1000));
- Break;
- end;
- if (Actions[4] <> '') then
- Players[CurrentPlayer].Loc := Actions[4];
- case Actions[3] of
- 'PlayerFalse': NextPlayer(False);
- 'PlayerTrue':
- begin
- //LeaveLobby();
- NextPlayer(True);
- end;
- 'Terminate': TerminateScript;
- 'RSUpdate':
- begin
- if SRL_HasProc(srl_OnRSUpdate) then
- begin
- case actions[0] of
- 'Runescape has been updated.':
- begin
- Writeln('Runescape has been updated! Waiting 5 minutes to restart SMART!');
- Wait(300000);
- end;
- end;
- SRL_Procs[srl_OnRSUpdate]();
- Exit;
- end;
- Writeln('Runescape has been updated! Please restart Simba.');
- TerminateScript;
- end;
- end;
- Exit;
- end;
- Wait(100);
- Result := (LobbyScreen) or (LoggedIn);
- until (Result);
- TakeIPScreen();
- if (LobbyScreen) then
- begin
- MouseBox(WDx1, WDy1, WDx2, WDy2, mouse_Left); //Click To Play
- i := 0;
- repeat
- i := i+1;
- Wait(100 + Random(100));
- until (LoggedIn) or (i > 30);
- end;
- Wait(100 + Random(100));
- {Back to main screen if needed}
- if (RetryLogin) then
- begin
- RetryLogin := False;
- Inc(Attempts);
- goto ProcStart;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment