zamaro

loginplayer

May 31st, 2014
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.20 KB | None | 0 0
  1. function LoginPlayer: Boolean;
  2. var
  3. RetryLogin: Boolean;
  4. typtmp, t, w, i: integer;
  5. Actions: TVariantArray;
  6. Attempts: LongInt;
  7. p: TPoint;
  8. //ATPA: T2dPointArray;
  9. TPA: TPointArray;
  10. Boxes : TIntegerArray;
  11. //B: TBox;
  12. badworlds: TIntegerArray;
  13. OurCurrentworld: Integer;
  14. label
  15. ProcStart;
  16. begin
  17. ActivateClient;
  18.  
  19. if (LoggedIn) then Exit;
  20. if (LobbyScreen) then
  21. begin
  22. MouseBox(WDx1, WDy1, WDx2, WDy2, mouse_Left); //Click To Play
  23. i := 0;
  24. repeat
  25. i := i+1;
  26. Wait(100 + Random(100));
  27. until (LoggedIn) or (i > 30);
  28. end;
  29.  
  30. Wait(100 + Random(200));
  31. TypeByte(vk_Escape);
  32. Wait(200 + Random(200));
  33.  
  34. {Check for lobby screen already open/ already logged in}
  35.  
  36. Result := (LoggedIn);
  37. if (Result) then Exit;
  38.  
  39. if (LobbyScreen) then
  40. begin
  41. MouseBox(WDx1, WDy1, WDx2, WDy2, mouse_Left); //Click To Play
  42. i := 0;
  43. repeat
  44. i := i+1;
  45. Wait(100 + Random(100));
  46. until (LoggedIn) or (i > 30);
  47. end;
  48.  
  49. {Check for active player.}
  50.  
  51. if (not (Players[CurrentPlayer].Active)) then
  52. begin
  53. WriteLn('Player is not Active...');
  54. if (AllPlayersInActive) then
  55. begin
  56. WriteLn('All players not active!');
  57. Exit;
  58. end;
  59. NextPlayer(False);
  60. Exit;
  61. end;
  62.  
  63. {Wait for the client to finish loading.}
  64.  
  65. T := GetSystemTime;
  66. repeat
  67. if (RSReady) then
  68. Break;
  69. if ((GetSystemTime - T) > 180000) then
  70. begin
  71. WriteLn('It has been 3 minutes and Runescape is not yet ready... Terminating.');
  72. TerminateScript;
  73. end;
  74. Wait(RandomRange(1000, 2000));
  75. until (False);
  76. if (CountColor(16777215, 408, 279, 518, 299) = 281) then //Existing User text
  77. begin
  78. WriteLn('Welcome to Runescape.');
  79. badworlds := [308, 316, 325, 337, 365];
  80. MouseBox(395, 275, 529, 307, mouse_Left); //Existing User
  81. Wait(RandomRange(1000, 2000));
  82. OurCurrentworld := currentworldls;
  83. if InIntArray(Badworlds, OurCurrentworld) then //If its a bad one then exist
  84. MouseBox(238, 309, 362, 332 ,mouse_left); //Continue
  85. end;
  86.  
  87. if Length(Players[CurrentPlayer].WorldInfo) > 0 then
  88. SelectWorld(Players[CurrentPlayer].WorldInfo[0]);
  89. ProcStart:
  90. {Type in username and pass}
  91.  
  92. if (loggedIn) then
  93. exit;
  94.  
  95. for W:= 0 to 1 do
  96. begin
  97. if W = 0 then
  98. Boxes:= [UBX1, UBY1, UBX2, UBY2]
  99. else
  100. Boxes:= [PBX1, PBY1, PBX2, PBY2];
  101.  
  102. t := (getSystemTime + (60000 * 2));
  103. FindColors(TPA, LOGIN_TEXTCOLOUR, Boxes[0], Boxes[1], Boxes[2], Boxes[3]);
  104. repeat
  105. if (Length(TPA) > 0) then
  106. begin
  107. SortTPAFrom(TPA, Point(Boxes[2], Boxes[1] + (Boxes[3] - Boxes[2]) div 2));
  108. p := point(TPA[0].X + 20, TPA[0].Y);
  109. if (not pointInBox(p, intToBox(Boxes[0], Boxes[1], Boxes[2], Boxes[3]))) then
  110. p := point(UBX2 - (10 + random(10)), p.y);
  111. Mouse(p.x, p.y, 2, 2, mouse_left);
  112. end else
  113. MouseBox(Boxes[0], Boxes[1], Boxes[2], Boxes[3], mouse_left);
  114.  
  115. typtmp := 0;
  116. while (CountColor(LOGIN_TEXTCOLOUR, Boxes[0], Boxes[1], Boxes[2], Boxes[3]) > 0) do
  117. begin
  118. Inc(typtmp);
  119. TypeByte(VK_BACK);
  120. Wait(50+Random(50));
  121. if (typtmp >= RandomRange(30, 35)) then
  122. Break;
  123. end;
  124. until(not FindColors(TPA, LOGIN_TEXTCOLOUR, Boxes[0], Boxes[1], Boxes[2], Boxes[3]) or (getSystemTime > t));
  125.  
  126. Wait(100 + Random(200));
  127. if W = 0 then
  128. begin
  129. WriteLn(Capitalize(Players[CurrentPlayer].Name));
  130. TypeSend(Players[CurrentPlayer].Name);
  131. end else
  132. begin
  133. TypeSendEx(Players[CurrentPlayer].Pass, False);
  134. MouseBox(234, 304, 369, 338, mouse_Left); //Login
  135. end;
  136. end;
  137.  
  138. {Check responses}
  139.  
  140. T := GetSystemTime;
  141. repeat
  142. // so the lobby appears (gets rid of black screen)
  143. if (countColorTolerance(clBlack, 0, 0, 500, 500, 20) > 245000) then
  144. begin
  145. wait(2000 + random(1500));
  146. mouseBox(0, 0, 750, 490, mouse_Move);
  147. end;
  148.  
  149. SetLength(Actions, 0);
  150.  
  151. if ((GetSystemTime - T) > 60000) then
  152. Actions := ['One minute has passed... Debug: ' + ToStr(CountColor(LOGIN_STATUSCOLOUR, 224, 190, 532, 250)), 0, 5, 'PlayerFalse', 'Login Failed']
  153. else
  154. // writeln(CountColor(LOGIN_STATUSCOLOUR, 224, 190, 532, 250));
  155. case (CountColor(LOGIN_STATUSCOLOUR, 224, 190, 532, 250)) of //text colour points
  156. // WriteLn Error Wait for Retrys Action Player[CurrentPlayer].Loc
  157. 738: Actions := ['Invalid Username / Password', 0, 2, 'PlayerFalse', 'Wrong User/Pass']; //Updated
  158. 1539: Actions := ['Your account has been disabled', 0, 0, 'PlayerFalse', 'Acc Disabled']; //Updated
  159. 1073: Actions := ['Your account is already logged in', 5000, 5, 'PlayerTrue', 'Already logged in']; //Updated
  160. 1573: Actions := ['Not a Members Account', 0, 1, 'PlayerTrue', '']; //Updated
  161. 492: Actions := ['Error Connecting.', 20000, 9, 'Terminate', 'Error Connecting']; //Updated
  162. 1721: Actions := ['Too many incorrect logins.', 5 * 60000, 2, 'PlayerFalse', 'Too many logins']; //Updated
  163. 906: Actions := ['This world is full.', 5000, 10, 'PlayerFalse', 'World is full']; //Updated
  164. 1136: Actions := ['Runescape has been updated.', 0, 0, 'RSUpdate', 'RS Updated'];
  165. 777: Actions := ['Login limit exceeded.', 20000, 10, '', 'Waiting for login.'];
  166. 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
  167. end;
  168. {Respond}
  169.  
  170. if (Length(Actions) > 0) then
  171. begin
  172. WriteLn(Actions[0]);
  173. if (Actions[0] <> 'Not a Members Account') then
  174. begin
  175. Wait(1000 + Random(500));
  176. end;
  177. Wait(Actions[1] + Random(100));
  178. if (Actions[2] <> 0) then
  179. if (Attempts < Actions[2]) or (Actions[2] = -1) then
  180. begin
  181. if (Actions[0] = 'Not a Members Account') then
  182. begin
  183. Players[CurrentPlayer].Member := False;
  184. if (Length(Players[CurrentPlayer].WorldInfo) > 0) then
  185. Players[CurrentPlayer].WorldInfo[0] := False;
  186. MouseBox(267, 321, 496, 350, mouse_left); //Play free game instead button TODO:Check if this is needed
  187. Wait(3000 + Random(2000));
  188. Result := True;
  189. Exit;
  190. end;
  191. RetryLogin := True;
  192. Wait(2000 + Random(1000));
  193. Break;
  194. end;
  195. if (Actions[4] <> '') then
  196. Players[CurrentPlayer].Loc := Actions[4];
  197. case Actions[3] of
  198. 'PlayerFalse': NextPlayer(False);
  199.  
  200. 'PlayerTrue':
  201. begin
  202. //LeaveLobby();
  203. NextPlayer(True);
  204. end;
  205.  
  206. 'Terminate': TerminateScript;
  207.  
  208. 'RSUpdate':
  209. begin
  210. if SRL_HasProc(srl_OnRSUpdate) then
  211. begin
  212. case actions[0] of
  213. 'Runescape has been updated.':
  214. begin
  215. Writeln('Runescape has been updated! Waiting 5 minutes to restart SMART!');
  216. Wait(300000);
  217. end;
  218. end;
  219. SRL_Procs[srl_OnRSUpdate]();
  220. Exit;
  221. end;
  222. Writeln('Runescape has been updated! Please restart Simba.');
  223. TerminateScript;
  224. end;
  225. end;
  226. Exit;
  227. end;
  228. Wait(100);
  229. Result := (LobbyScreen) or (LoggedIn);
  230. until (Result);
  231.  
  232. TakeIPScreen();
  233.  
  234. if (LobbyScreen) then
  235. begin
  236. MouseBox(WDx1, WDy1, WDx2, WDy2, mouse_Left); //Click To Play
  237. i := 0;
  238. repeat
  239. i := i+1;
  240. Wait(100 + Random(100));
  241. until (LoggedIn) or (i > 30);
  242. end;
  243.  
  244. Wait(100 + Random(100));
  245.  
  246. {Back to main screen if needed}
  247.  
  248. if (RetryLogin) then
  249. begin
  250. RetryLogin := False;
  251. Inc(Attempts);
  252. goto ProcStart;
  253. end;
  254.  
  255. end;
Advertisement
Add Comment
Please, Sign In to add comment