Advertisement
Guest User

Untitled

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