Don't like ads? PRO users don't see any ads ;-)
Guest

leederstarter2.2

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