Code:
Procedure P07_LoginPlayer;
Var
X,Y,Attempts: Integer;
Begin
Repeat Begin
If (GetTextAtExWrap(250, 215, 387, 231, 0, 5, 1, P07_outline_yellow, 20, 'P07UpChars') = 'Enter your username') Then
Begin
WriteLn('Enter your username & password');
If Not (FindColor(x, y, P07_outline_white, 312, 255, 512, 266)) Then
Begin
If (P07_PlayerName = '') Then
Begin
WriteLn('Player Name Not Entered, Or Set P07_PlayerName and P07_PlayerPass Before SetupP07Include');
TerminateScript;
End;
//P07_MouseBox(345, 259, 365, 263, mouse_left);
P07_TypeFast(P07_PName);
End;
P07_UseKey(9);
If Not (FindColor(x, y, P07_outline_white, 345, 271, 525, 278)) Then
Begin
If (P07_PlayerPass = '') Then
Begin
WriteLn('Player Password Not Entered, Or Use P07_DeclarePlayer Before SetupP07Include');
TerminateScript;
End;
P07_TypeFast(P07_PPass);
End;
Wait(RandomRange(100, 200));
P07_MouseBox(235, 304, 369, 337, mouse_left);
Wait(RandomRange(300, 500));
End;
If (GetTextAtExWrap(300, 240, 381, 255, 0, 5, 1, P07_outline_yellow, 20, 'P07UpChars') = 'Welcome to') Then
Begin
WriteLn('Welcome to Project RS06');
P07_MouseBox(395, 275, 530, 307, mouse_left);
Wait(RandomRange(100, 200));
End;
If (GetTextAtExWrap(260, 215, 373, 227, 0, 5, 1, P07_outline_yellow, 20, 'P07UpChars') = 'Invalid username') Then
Begin
WriteLn('Invalid username or password');
Attempts:=Attempts+1;
P07_MouseBox(395, 305, 530, 336, mouse_left);
Wait(RandomRange(100, 200));
Continue;
End;
If (GetTextAtExWrap(306, 215, 446, 230, 0, 5, 1, P07_outline_yellow, 20, 'P07UpChars') = 'Connecting to') Then
Begin
WriteLn('Connecting to server...');
Wait(RandomRange(300, 500));
End;
If (GetTextAtExWrap(293, 215, 403, 231, 0, 5, 1, P07_outline_yellow, 20, 'P07UpChars') = 'Error connecting') Then
Begin
WriteLn('Error connecting to server');
Attempts:=Attempts+1;
P07_MouseBox(395, 305, 530, 336, mouse_left);
Wait(RandomRange(3300, 5500));
Continue;
End;
If (GetTextAtExWrap(250, 205, 356, 217, 0, 5, 1, P07_outline_yellow, 20, 'P07UpChars') = 'Your account') Then
Begin
WriteLn('Your account is already logged in.');
Attempts:=Attempts+1;
P07_MouseBox(395, 305, 530, 336, mouse_left);
Wait(RandomRange(7300, 15500));
Continue;
End;
If (GetTextAtExWrap(452, 330, 484, 343, 0, 5, 1, P07_outline_white, 20, 'P07UpChars') = 'PLAY') Then
Begin
WriteLn('Click To Play');
Wait(RandomRange(300, 1300));
P07_MouseBox(275, 269, 495, 377, mouse_left);
Wait(RandomRange(800, 1500));
Continue;
End;
If (GetTextAtExWrap(238, 215, 282, 227, 0, 5, 1, P07_outline_yellow, 20, 'P07UpChars') = 'Please') Then
Begin
WriteLn('Please Enter Your Username');
Wait(RandomRange(100, 500));
P07_MouseBox(395, 305, 530, 336, mouse_left);
Wait(RandomRange(100, 500));
Continue;
End;
wait(RandomRange(200,300));
End; Until (P07_LoggedIn) Or (Attempts > 5)
If (P07_LoggedIn) Then
Attempts:=0;
If (Attempts > 5) Then
Begin
WriteLn('Too Many Failed Login Attempts');
TerminateScript;
End;
Wait(RandomRange(1300, 2100));
End;