Advertisement
Guest User

Leaderstarter

a guest
Sep 16th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.86 KB | None | 0 0
  1. // added a line that sends whisper game name for leechers when in game revised by stairbuilder on 1-2-11 //
  2. // added fix for white screen of death credit to korean modders revised by stairbuilder on 2-17-11 //
  3. // added fix for creation button sticking revised by stairbuilder on 2-17-11 //
  4. // added sending game name and pw to txt file for leecher text file joining 9-25-11 //
  5. // added a while loop and manager print if a bad cd key is used or bad account or password stair 9-25-11 //
  6. // added txt file joining and added game count over 99 mod 12-1-12 //
  7. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  8. // Version of the LeaderStarter remains at 2.3!
  9.  
  10. ///////////////////////////////////////////////////
  11. // characters in your game setting:
  12. ///////////////////////////////////////////////////
  13.  
  14. var characterdiff = "90"; //use this to keep those pesky spam bots out of the f'ing game
  15. //note you must manually hit the check box the first time for this to work
  16. var maxNumberOfPlayersss = "8"; //use this to set the maximum number of players allowed in your game
  17.  
  18. ///////////////////////////////////////
  19. // Channel Settings: These control what if any channel you join
  20. ///////////////////////////////////////
  21.  
  22. var joinChatAfterGame = True; // join chat after leaving a game
  23. var joinRandomChannel = false; // if this is true, will join a random channel, otherwise it will use the channel below..
  24. var joinChannelInChat = "Op Abba"; // Channel you want your bot to join, leave blank to not join a private channel
  25.  
  26. ///////////////////////////////////////
  27. // Message Settings: These control what your bot sais to the leechers will also send a log incommand to a channel bot
  28. ///////////////////////////////////////
  29.  
  30. var WhisperFList = true; // Whisper your friends when you enter a game or not
  31.  
  32. var chatMessageOnJoin = ".login"; // Chat Message to say Login command for channel bot will only be sent once
  33. var chatMessageAfterGame1 = "Niiiice game"; // Optional chat message Line #1 to say after each game on Channel
  34. var chatMessageAfterGame2 = ""; // Optional chat message Line #2 to say after each game on Channel
  35. var chatMessageAfterGame3 = ""; // Optional chat message Line #3 to say after each game on Channel
  36. var chatMessageAfterGame4 = ""; // Optional chat message Line #4 to say after each game on Channel
  37. var chatMessageAfterGame5 = ""; // Optional chat message Line #5 to say after each game on Channel
  38.  
  39. /////////////////////////////////////// // These will let you send a message with a game name password and time to your leechers
  40. // Game Message Settings: // // var saygamename must be true for any of these to work
  41. /////////////////////////////////////// // You cant NOT have a - in you game name it will bug it out
  42.  
  43. var saygamename = true; // Must be true for any of the game message settings to work
  44. var nextgamemessage = "next game should be"; // This will come befor your next game name eg "New game is"
  45. var saypassword = true; // This will togle if the bot says your game pw
  46. var saytime = true; // This will togle if the bot says how much time till creation
  47. var timemessage = "in about"; // This will come after your pw and befor the time eg. "in about" xx seconds say time MUST be true for this to be used
  48.  
  49. //////////////////////////////////////
  50. // Minimum Game Length: //
  51. //////////////////////////////////////
  52.  
  53. var gameMinLength = 180000; // time in milliseconds, minimum game length, 180 seconds default (1 game/3 minutes)
  54.  
  55. // ====================================================================================================
  56. // All of the delays for actions from bot start until in-game are below! Read the notes!!!
  57. // ====================================================================================================
  58.  
  59. var unableToConnectRetry = 5; // time in minutes to retry connecting on connection fail (real value is +/- 1 min)
  60. var realmDownRetry = 900; // time in minutes to retry connecting on a realm down (default is 300 minutes)
  61. var disconnectedRetry = 5; // time in minutes to retry on a disconnection (usually ip ban related)
  62. var cdkeyInUseRetry = 5; // time in minutes to retry on a cdkey in use error message (set to 0 to stop)
  63. var connectingToBnetTimeout = 20000; // time in milliseconds to wait for a login to time out and click cancel and retry
  64. var characterScreenTimeout = 10000; // time in milliseconds to wait for character screen to appear
  65. var pleaseWaitTimeout = 10000; // time in milliseconds to wait for a please wait popup
  66. var createGameThreshold = 12000; // time in milliseconds to wait between making games
  67. var createGameThresholdRandom = 1000; // time in milliseconds to randomly add +/- to the game create time
  68. var createGameTimeout = 44000; // time in milliseconds to register a failed to create game
  69. var waitInLineTimeout = 60000; // time in milliseconds to wait in lines for a create game (60 second default)
  70. var characterSelectDelay = 1000; // time in milliseconds to wait before selecting a character on the char screen
  71. var loginDelay = 1000; // time in milliseconds to wait before submitting login information
  72. var clickDelay = 500; // wait X milliseconds before next action after a click event
  73. var textDelay = 500; // wait X milliseconds before next action after inserting text into a textbox
  74. var clickDelayRandom = 500; // random amount of time to add to a click
  75. var textDelayRandom = 500; // random amount of time to add to a text set
  76. var gameDoesNotExistDelayMin = 600000; // how long to wait when a Game Does Not Exist occurs - minimum - default 10 minutes
  77. var gameDoesNotExistDelayMax = 900000; // how long to wait when a Game Does Not Exist occurs - maximum - default 15 minutes
  78. var gameDoesNotExistTimeout = 30000; // how long to wait for the dialog to disappear (default 30 seconds, don't change this)
  79. var waitBeforeEnterChatMin = 1000; // min how long to wait before entering chat
  80. var waitBeforeEnterChatMax = 2000; // max how long to wait before entering chat
  81. var waitInChatBeforeActionsMin = 2000; // min how long to wait before joining channel
  82. var waitInChatBeforeActionsMax = 3000; // max how long to wait before joining channel
  83. var waitBeforeNextLineChatMin = 500; // Minimum ammount of time to add after each text line
  84. var waitBeforeNextLineChatMax = 1500; // Maximum ammount of time to add after each text line
  85. var ftjDelay = 180; // time to idle before trying if leader failed to join. In seconds.
  86.  
  87. // DONT EDIT ANYTHING BELOW THIS
  88.  
  89. // =============================================================================
  90. // Debug : set to true if you are experiencing problems with your JoinBot
  91. // it will log in your OOG the lobby chat actions
  92. // =============================================================================
  93. var Debug = false;
  94.  
  95. // D2NT Manager Command
  96. const D2NT_MGR_LOADING = 1;
  97. const D2NT_MGR_READY = 2;
  98. const D2NT_MGR_LOGIN = 3;
  99. const D2NT_MGR_CREATE_GAME = 4;
  100. const D2NT_MGR_INGAME = 5;
  101. const D2NT_MGR_RESTART = 6;
  102. const D2NT_MGR_CHICKEN = 7;
  103. const D2NT_MGR_PRINT_STATUS = 8;
  104. const D2NT_MGR_PRINT_LOG = 9;
  105. var alreadyLoggedIn = false; // will only send the login command once leave as unless you want to login everytime you join a channel
  106. var lastGameMade = GetTickCount();
  107. var lastGameStatus = 0;
  108. var nextGameMake = 0;
  109. var inGameAt = 0;
  110. var chatActionsDone = false;
  111. var lastGameFailed = false;
  112. var tempDelay = Random(waitBeforeNextLineChatMin, waitBeforeNextLineChatMax);
  113. var gameInfo = "";
  114. var bugignor = true;
  115. var ftjcount = 0;
  116. Include("libs/controlInfo.ntl");
  117. Include("libs/common/NTColorConverter.ntl");
  118. Include("libs/common/NTLogger.ntl");
  119.  
  120. var controlData = new controlInfo();
  121.  
  122. function NTMain()
  123. {
  124. Delay(1000);
  125.  
  126. var _ingame = false;
  127.  
  128. controlData.clickDelay = clickDelay;
  129. controlData.textDelay = textDelay;
  130. controlData.clickDelayRandom = clickDelayRandom;
  131. controlData.textDelayRandom = textDelayRandom;
  132. NTLG_Log("NTBot.ntj", NTLG_TYPE_LOG, NTLG_LEVEL_INFO);
  133. while(1)
  134. {
  135. if(me.ingame)
  136. {
  137. if(!inGameAt)
  138. inGameAt = GetTickCount();
  139.  
  140. if(!_ingame)
  141. {
  142. RunGC(); // run garbage collector between each game
  143.  
  144. if(Load("NTBot/NTBotGame.ntj"))
  145. {
  146. _ingame = true;
  147. NT_File("logs/messagecomands/"+me.charname+"-nextgame.txt", 1, me.gamename + "/" + me.gamepassword); // for leader to print game/pw to txt
  148.  
  149. if(me.playtype > 0) {
  150. NTLG_Log("NTBot.ntj", NTLG_TYPE_LOG, NTLG_LEVEL_INFO, "In Game[IP:" + me.gameserverip.split(".")[3] + "]");
  151. sendEventToOOG(D2NT_MGR_INGAME, "In Game[IP:" + me.gameserverip.split(".")[3] + "]", 0);
  152.  
  153. } else {
  154. NTLG_Log("NTBot.ntj", NTLG_TYPE_LOG, NTLG_LEVEL_INFO, "In Game");
  155. sendEventToOOG(D2NT_MGR_INGAME, "In Game", 0);
  156. }
  157. if(WhisperFList) {
  158. FriendMessage = "/f m in_new_game " + me.gamename;
  159. //if(saypassword) FriendMessage = FriendMessage + "//" + me.gamepassword;
  160. Say(FriendMessage); Delay(Random(500,1000)); // this is for leechers to join only after leader is in game
  161. }
  162. lastGameStatus = 2; // in game successful
  163. }
  164. }
  165.  
  166. Delay(1000);
  167. NTLG_FlushLogQueue();
  168. }
  169. else
  170. {
  171.  
  172. if(_ingame)
  173. {
  174. My_ExitGame_Check(); // out of korean modded d2nt fixes white screen of death
  175.  
  176. _ingame = false;
  177.  
  178. sendEventToOOG(D2NT_MGR_READY, "", 0);
  179. }
  180.  
  181. locationAction(controlData.getLocation());
  182.  
  183. Delay(500);
  184. }
  185. }
  186. }
  187.  
  188. function locationAction(location)
  189. {
  190. switch(location.id)
  191. {
  192. case 3: // Lobby Chat
  193. //ftjcheck
  194. if (ftjcount >= 10 && lastGameStatus == 1) {
  195. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "FTJ detected...........Idling", 0);
  196. ftjcount = 0;
  197. inGameAt = 0;
  198. lastGameStatus = 0;
  199. setNextGameMake();
  200. locationTimeout(ftjDelay*1000, location);
  201. }
  202. if(!chatActionsDone)
  203. {
  204. chatActionsDone = true;
  205. Delay(Random(waitInChatBeforeActionsMin, waitInChatBeforeActionsMax));
  206.  
  207. if(joinRandomChannel || joinChannelInChat != "")
  208. {
  209. Say("/join " + (joinRandomChannel ? getRandomString(Random(3,10)) : joinChannelInChat));
  210. Delay(1000);
  211. if(!alreadyLoggedIn){
  212. alreadyLoggedIn = true;
  213. if (chatMessageOnJoin.length > 0){
  214. Say(chatMessageOnJoin);
  215. }
  216. }
  217. Delay(500);
  218. chatActionsDone = true;
  219. }
  220. }
  221. case 1: // Lobby
  222. //ftjcheck
  223. if (ftjcount >= 10 && lastGameStatus == 1) {
  224. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "FTJ detected...........Idling", 0);
  225. ftjcount = 0;
  226. inGameAt = 0;
  227. lastGameStatus = 0;
  228. setNextGameMake();
  229. locationTimeout(ftjDelay*1000, location);
  230. }
  231. if(location.id == 1 && joinChatAfterGame)
  232. {
  233. Delay(Random(waitBeforeEnterChatMin, waitBeforeEnterChatMax));
  234. controlData.click(controlData.controls.lobby.button.enterChat);
  235. break;
  236. }
  237. //LogPrintSimple(me.account + "MyAccountTest.txt", me.account + " / " + me.charname) // this is to check for 2nd account login
  238.  
  239. if(GetTickCount() > nextGameMake)
  240. {
  241. lastGameFailed = false;
  242.  
  243. switch(lastGameStatus)
  244. {
  245. case 0:
  246. password = (me.gamepassword);
  247. game = (getGameName(me.gamename));
  248. counter = (getGameCounter(me.gamename, false));
  249. time = (parseInt((nextGameMake - GetTickCount() - tempDelay)/1000+3.0));
  250. if (saygamename){{
  251. gameInfo += nextgamemessage + " " + game + counter;
  252. }
  253. if (saypassword){
  254. gameInfo += "//" + password
  255. }
  256. if (saytime){
  257. gameInfo += " " + timemessage + " " + time + " seconds"
  258. }
  259. }
  260. if(joinChatAfterGame){
  261. if(chatMessageAfterGame1.length > 0){
  262. Say(chatMessageAfterGame1);
  263. if(chatMessageAfterGame1.length > 0){
  264. Delay(tempDelay);
  265. }
  266. }
  267. if(chatMessageAfterGame2.length > 0){
  268. Say(chatMessageAfterGame2);
  269. if(chatMessageAfterGame2.length > 0){
  270. Delay(tempDelay);
  271. }
  272. }
  273. if(chatMessageAfterGame3.length > 0){
  274. Say(chatMessageAfterGame3);
  275. if(chatMessageAfterGame3.length > 0){
  276. Delay(tempDelay);
  277. }
  278. }
  279. if(chatMessageAfterGame4.length > 0){
  280. Say(chatMessageAfterGame4);
  281. if(chatMessageAfterGame4.length > 0){
  282. Delay(tempDelay);
  283. }
  284. }
  285. if(chatMessageAfterGame5.length > 0){
  286. Say(chatMessageAfterGame5);
  287. if(chatMessageAfterGame5.length > 0){
  288. Delay(tempDelay);
  289. }
  290. }
  291. if(saygamename) {
  292. if(bugignor){
  293. bugignor = false;
  294. gameInfo = "";
  295. }
  296. else{
  297. Say(gameInfo)
  298. Delay(tempDelay)
  299. gameInfo = "";
  300. }
  301. }
  302. }
  303. _control = controlData.get(controlData.controls.lobby.button.create); // fixes creation stuck button bug out of unmodded d2nt
  304. if(_control && _control.pressed)
  305. {
  306. controlData.click(controlData.controls.lobby.button.join);
  307. Delay(500);
  308. }
  309.  
  310. controlData.click(controlData.controls.lobby.button.create);
  311. _control = controlData.get(controlData.controls.lobby.create.button.useCharacterDifference);
  312. if(_control && !_control.pressed)
  313. {
  314. controlData.click(controlData.controls.lobby.create.button.useCharacterDifference);//checks the use character diff box...does this every time so no go
  315. }
  316. controlData.setText(controlData.controls.lobby.create.editBox.characterDifference,(characterdiff)); //level restriction
  317. controlData.setText(controlData.controls.lobby.create.editBox.maxNumberOfPlayers, (maxNumberOfPlayersss)); //max players
  318. nextGameMake = GetTickCount() + createGameTimeout; // set our timeout
  319. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  320. break;
  321. case 1: // game failed, rollover to reset timer
  322. inGameAt = GetTickCount(); // reset inGameAt, to wait how long we should have waited..
  323. lastGameFailed = true;
  324. case 2:
  325. outputGameLength();
  326. lastGameStatus = 0;
  327. setNextGameMake();
  328. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  329. break;
  330. }
  331. }
  332. else
  333. timeoutDelay(nextGameMake-GetTickCount(), location, true);
  334. break;
  335.  
  336. case 2: // Waiting In Line
  337. if(GetTickCount()-lastGameMade > waitInLineTimeout)
  338. controlData.click(controlData.controls.lobby.inLine.button.cancel);
  339. break;
  340.  
  341. case 4: // Create Game
  342. sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
  343.  
  344. locationTimeout(5000, location);
  345.  
  346. lastGameMade = GetTickCount();
  347. lastGameStatus = 1; // pending creation
  348. break;
  349.  
  350. case 5: // Join Game
  351. break;
  352.  
  353. case 6: // Ladder
  354. break;
  355.  
  356. case 7: // Channel List
  357. break;
  358.  
  359. case 8: // Main Menu
  360. if(controlData.getCurrentRealmIndex() == me.gatewayid)
  361. {
  362. outputGameLength();
  363. controlData.click(controlData.gameTypes[me.playtype]);
  364. }
  365. else
  366. controlData.click(controlData.controls.mainMenu.button.gateway);
  367. break;
  368.  
  369. case 9: // Login
  370. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  371. Delay(loginDelay);
  372.  
  373. controlData.setText(controlData.controls.login.editBox.accountName, me.account);
  374.  
  375. sendEventToOOG(D2NT_MGR_LOGIN, location.name, 0);
  376.  
  377. locationTimeout(5000, location);
  378. break;
  379.  
  380. case 10: // Login Error (this is a fatal error, so stop)
  381. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Bad Account or PW Entered.......Idling", 0);
  382. while(1) { Delay(500); }
  383. sendEventToOOG(D2NT_MGR_RESTART, location.name, 10);
  384. Delay(3500);
  385. break;
  386.  
  387. case 11: // Unable To Connect
  388. timeoutDelay(unableToConnectRetry*60*1000, location)
  389. controlData.click(controlData.controls.login.unableToConnect.button.ok);
  390. break;
  391.  
  392. case 12: // Character Select
  393. var _time, _control;
  394.  
  395. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  396.  
  397. for(_time = 0 ; _time < characterScreenTimeout ; _time += 500)
  398. {
  399. _control = controlData.get(controlData.controls.characterSelect.textBox.characterInfo[me.charloc]);
  400. if(_control && _control.GetText() != undefined)
  401. break;
  402.  
  403. Delay(500);
  404. }
  405.  
  406. if(_time < characterScreenTimeout)
  407. {
  408. Delay(characterSelectDelay);
  409.  
  410. controlData.click(controlData.controls.characterSelect.textBox.characters[me.charloc], 0, 0, 1);
  411. controlData.click(controlData.controls.characterSelect.textBox.characterInfo[me.charloc], 0, 0, 1);
  412.  
  413. // reset last game made, so it doesnt make a game immediately
  414. inGameAt = 0;
  415. setNextGameMake();
  416. }
  417. else
  418. {
  419. controlData.click(controlData.controls.characterSelect.button.exit);
  420. timeoutDelay(realmDownRetry*60*1000, location);
  421. }
  422. break;
  423.  
  424. case 13: // Realm Down - Character Select screen
  425. controlData.click(controlData.controls.characterSelect.button.exit);
  426. timeoutDelay(realmDownRetry*60*1000, location);
  427. break;
  428.  
  429. case 14: // Character Select - Disconnected
  430. timeoutDelay(disconnectedRetry*60*1000, location);
  431. controlData.click(controlData.controls.characterSelect.disconnected.button.ok);
  432. break;
  433.  
  434. case 15: // New Character
  435. break;
  436.  
  437. case 16: // Character Select - Please Wait popup
  438. if(!locationTimeout(pleaseWaitTimeout, location))
  439. controlData.click(controlData.controls.characterSelect.pleaseWait.button.cancel);
  440. break;
  441.  
  442. case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway
  443. controlData.click(controlData.controls.lobby.lostConnection.button.ok);
  444. break;
  445.  
  446. case 18: // D2 Splash
  447. controlData.click(controlData.controls.d2Splash.textBox.copyright);
  448. break;
  449.  
  450. case 19: // Login - Cdkey In Use
  451. timeoutDelay(cdkeyInUseRetry*60*1000, location);
  452. controlData.click(controlData.controls.login.cdkeyInUse.button.ok);
  453. break;
  454.  
  455. case 20: // Single Player - Select Difficulty
  456. controlData.click(controlData.singlePlayerDifficulties[me.diff]);
  457. break;
  458.  
  459. case 21: // Main Menu - Connecting
  460. if(!locationTimeout(connectingToBnetTimeout, location))
  461. controlData.click(controlData.controls.mainMenu.connecting.button.cancel);
  462. break;
  463.  
  464. case 22: // Login - Invalid Cdkey (classic or xpac)
  465. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Bad CD Key...........Idling", 0);
  466. while(1) { Delay(500); }
  467. sendEventToOOG(D2NT_MGR_RESTART, location.name, 3600);
  468. Delay(3500);
  469. break;
  470.  
  471. case 23: // Character Select - Connecting
  472. if(!locationTimeout(characterScreenTimeout, location))
  473. controlData.click(controlData.controls.characterSelect.button.exit);
  474. break;
  475.  
  476. case 24: // Server Down - not much to do but wait..
  477. break;
  478.  
  479. case 25: // Lobby - Please Wait
  480. if(!locationTimeout(pleaseWaitTimeout, location))
  481. controlData.click(controlData.controls.lobby.pleaseWait.button.cancel);
  482. break;
  483.  
  484. case 26: // Lobby - Game Name Exists
  485. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Game already exists", 0);
  486.  
  487. inGameAt = 0;
  488. lastGameStatus = 0;
  489. setNextGameMake();
  490.  
  491. locationTimeout(15000, location);
  492. break;
  493.  
  494. case 27: // Gateway Select
  495. controlData.clickRealmEntry(me.gatewayid);
  496. controlData.click(controlData.controls.gateway.button.ok);
  497. break;
  498.  
  499. case 28: // Lobby - Game Does Not Exist
  500. inGameAt = Random(gameDoesNotExistDelayMin, gameDoesNotExistDelayMax);
  501. //Delay(inGameAt);
  502. lastGameStatus = 0;
  503. setNextGameMake();
  504.  
  505. locationTimeout(gameDoesNotExistTimeout, location);
  506. break;
  507. default:
  508. if (lastGameStatus == 1) {
  509. sendEventToOOG(D2NT_MGR_PRINT_STATUS, "Please Wait...", 0);
  510. for (ftjcount=0; ftjcount<=10 && !me.ingame; ftjcount++) {
  511. Delay(1000)
  512. }
  513. }
  514. DebugInOOG("Unhandled location : "+location.id);
  515. break;
  516. }
  517. DebugInOOG("Location : "+location.id);
  518. }
  519.  
  520. function sendEventToOOG(locationId, statusString, pendingTime)
  521. {
  522. return SendCopyData("D2NT Manager", null, (locationId<<16)|pendingTime, statusString);
  523. }
  524.  
  525. function setNextGameMake()
  526. {
  527. lastGameMade = GetTickCount();
  528. nextGameMake = lastGameMade + createGameThreshold + Random(0-createGameThresholdRandom, createGameThresholdRandom) + inGameAt;
  529. inGameAt = 0;
  530. chatActionsDone = false;
  531. }
  532.  
  533. function outputGameLength()
  534. {
  535. if(inGameAt)
  536. {
  537. duration = GetTickCount() - inGameAt;
  538.  
  539. inGameAt = (duration < gameMinLength ? gameMinLength - duration : 0);
  540. }
  541. }
  542.  
  543. function locationTimeout(time, location)
  544. {
  545. endtime = GetTickCount() + time;
  546.  
  547. while(controlData.getLocation().id == location.id && endtime > GetTickCount())
  548. {
  549. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  550. Delay(500);
  551. }
  552.  
  553. return (controlData.getLocation().id != location.id);
  554. }
  555.  
  556. function timeoutDelay(time, location)
  557. {
  558. endtime = GetTickCount() + time;
  559.  
  560. while(endtime > GetTickCount())
  561. {
  562. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  563. Delay(1000);
  564. }
  565. }
  566.  
  567. function getRandomString(_length)
  568. {
  569. _retString = "";
  570. _charSet = "0123456789abcdefghijklmnopqrstuvwxyz";
  571.  
  572. while(_length--)
  573. {
  574. _retString += _charSet.charAt(Random(0, _charSet.length-1));
  575. Delay(1);
  576. }
  577.  
  578. return _retString;
  579. }
  580. function getGameName(lastGameString)
  581. {
  582. if(!lastGameString)
  583. return "";
  584. else
  585. return (lastGameString.split("-")[0] + "-");
  586. }
  587.  
  588. function getGameCounter(lastGameString, simple)
  589. {
  590. var myCount;
  591. if(!lastGameString)
  592. return "-1";
  593. else
  594. {
  595. switch(lastGameString.split("-")[1])
  596. {
  597. case "08":
  598. myCount = 9;
  599. break;
  600. case "09":
  601. myCount = 10;
  602. break;
  603. case "99":
  604. myCount = 00;
  605. break;
  606. default:
  607. myCount = parseInt(lastGameString.split("-")[1]) + 1;
  608. break;
  609. }
  610. if(!simple)
  611. {
  612. if(myCount <= 9)
  613. return ('0' + myCount);
  614. }
  615. return myCount;
  616. }
  617. }
  618.  
  619. function My_ExitGame_Check()
  620. {
  621. for (var i = 0; i < 40; i++)
  622. {
  623. if (controlData.getLocation().id != undefined)
  624. break;
  625.  
  626. if (i > 38)
  627. {
  628. LogPrintSimple(me.account + " StarterTest.txt", "White Screen of Death: Restarting")
  629. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "White Screen of Death: Restarting", 0);
  630. sendEventToOOG(D2NT_MGR_RESTART, "", 5);
  631. My_Delay(); // make sure and add this also
  632. }
  633.  
  634. Delay(500);
  635. }
  636. }
  637.  
  638. function My_Delay(retry)
  639. {
  640. if (arguments.length < 1)
  641. retry = 20;
  642.  
  643. while (retry-- > 0)
  644. Delay(1000);
  645. }
  646.  
  647. function LogPrintSimple(filepath, mesg){
  648.  
  649. var _filepath = filepath;
  650. var _mesg = mesg;
  651.  
  652. var date = new Date().toLocaleFormat("<%a, %b %d, %H:%M>");
  653. var logfile = FileOpen(_filepath, 2); // opens file
  654. if(!logfile)
  655. var logfile = FileOpen(_filepath, 1); // if file not there then creates it
  656.  
  657. logfile.WriteLine(date + " " + _mesg );
  658. logfile.Close();
  659. }
  660.  
  661. // modes 0 = read only, 1 = overwrite the file, 2 = add to file
  662. function NT_File(path, mode, msg, delay) { //big thanks to all the koreans out there
  663. var _msg = "";
  664. var _line = "";
  665. var _fileHandle;
  666. var _isFileCheck = false;
  667.  
  668. if (arguments.length < 3) { msg = ""; }
  669. if (arguments.length < 4) { delay = (mode > 0) ? 5 : 2; }
  670.  
  671. while (delay--) {
  672. if (mode == 2 && !_isFileCheck) {
  673. _fileHandle = FileOpen(path, 0);
  674. if (!_fileHandle)
  675. _fileHandle = FileOpen(path, 1);
  676.  
  677. if (_fileHandle)
  678. _fileHandle.Close();
  679.  
  680. _isFileCheck = true;
  681. }
  682.  
  683. _fileHandle = FileOpen(path, mode);
  684. if (_fileHandle)
  685. break;
  686.  
  687. if (delay)
  688. Delay(200);
  689. }
  690.  
  691. if (_fileHandle) {
  692. if (mode == 0) {
  693. while (!_fileHandle.eof) {
  694. _line = _fileHandle.ReadLine();
  695. if (_line || !_fileHandle.eof)
  696. _msg += _line + msg;
  697. }
  698. }
  699. else if (msg)
  700. _fileHandle.WriteLine(msg);
  701.  
  702. _fileHandle.Close();
  703. }
  704.  
  705. return _msg;
  706. }
  707.  
  708. function DebugInOOG(logString)
  709. {
  710. if (Debug)
  711. return SendCopyData("D2NT Manager", null, 9<<16, "-- Debug : " + logString);
  712. else
  713. return false;
  714. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement