Advertisement
kolton

Untitled

Oct 9th, 2011
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. // cdkey library by kolton
  2.  
  3. // configure this
  4.  
  5. var debug = false;
  6.  
  7. var p1 = new cdKey("kol8-a", ["n2.mpq", "d3.mpq", "d1.mpq", "12.mpq", "s2.mpq", "u3.mpq", "5.mpq"]);
  8. var p2 = new cdKey("kol8-b", ["s10.mpq", "18.mpq", "u10.mpq", "d4.mpq", "s3.mpq", "u4.mpq", "u8.mpq"]);
  9. var p3 = new cdKey("kol8-c", ["u12.mpq", "d5.mpq", "g3.mpq", "g2.mpq", "s1.mpq", "u1.mpq", "1.mpq"]);
  10. var p4 = new cdKey("kol8-d", ["n4.mpq", "d6.mpq", "g14.mpq", "g12.mpq", "s11.mpq", "s6.mpq", "s15.mpq", "d10.mpq"]);
  11. var p5 = new cdKey("kol8-e", ["g7.mpq", "u5.mpq", "17.mpq", "g1.mpq", "s7.mpq", "d2.mpq", "g13.mpq"]);
  12. var p6 = new cdKey("kol8-i", ["d8.mpq", "u6.mpq", "s14.mpq", "g9.mpq", "s8.mpq", "g8.mpq", "g4.mpq"]);
  13. var p7 = new cdKey("kol8-j", ["14.mpq", "2.mpq", "u7.mpq", "d9.mpq", "u9.mpq", "3.mpq", "n5.mpq"]);
  14. var p8 = new cdKey("kol8-k", ["d7.mpq", "9.mpq", "13.mpq", "s12.mpq", "s13.mpq", "12.mpq", "u2.mpq"]);
  15.  
  16. var accountArray = [p1, p2, p3, p4, p5, p6, p7, p8];
  17.  
  18. // internal stuff
  19.  
  20. function dPrint(text)
  21. {
  22. if(debug)
  23. sendEventToOOG(D2NT_MGR_PRINT_LOG, text, 0);
  24. }
  25.  
  26. function cdKey(accName, keys) {
  27. this.accName = accName;
  28. this.keys = keys;
  29. }
  30.  
  31. function getAccount(accName) {
  32. for (var i in accountArray) {
  33. if (accName === accountArray[i].accName) {
  34. return accountArray[i];
  35. }
  36. }
  37. }
  38.  
  39. function getCurrentKey(accName) {
  40. var cKey = parseInt(NT_File("data/" + accName + ".txt", 0).split("|")[1], 10);
  41.  
  42. if (cKey) {
  43. return cKey;
  44. } else {
  45. return 0;
  46. }
  47. }
  48.  
  49. function getCurrentGame(accName) {
  50. var cGame = parseInt(NT_File("data/" + accName + ".txt", 0).split("|")[0], 10);
  51.  
  52. if (cGame) {
  53. return cGame;
  54. } else {
  55. return 0;
  56. }
  57. }
  58.  
  59. function increaseKey(accName) {
  60. var cGame = parseInt(NT_File("data/" + accName + ".txt", 0).split("|")[0], 10);
  61. var cKey = parseInt(NT_File("data/" + accName + ".txt", 0).split("|")[1], 10);
  62.  
  63. cKey = cKey + 1;
  64.  
  65. dPrint("ΓΏc1Increasing key count to " + cKey);
  66.  
  67. NT_File("data/" + accName + ".txt", 1, cGame + "|" + cKey);
  68. }
  69.  
  70. function increaseGame(accName) {
  71. var cGame = parseInt(NT_File("data/" + accName + ".txt", 0).split("|")[0], 10);
  72. var cKey = parseInt(NT_File("data/" + accName + ".txt", 0).split("|")[1], 10);
  73.  
  74. cGame = cGame + 1;
  75.  
  76. dPrint("ΓΏc1Increasing game count to " + cGame);
  77.  
  78. NT_File("data/" + accName + ".txt", 1, cGame + "|" + cKey);
  79. }
  80.  
  81. function setKey(accName, key) {
  82. var cGame = parseInt(NT_File("data/" + accName + ".txt", 0).split("|")[0], 10);
  83.  
  84. NT_File("data/" + accName + ".txt", 1, cGame + "|" + key);
  85. }
  86.  
  87. function setGame(accName, game) {
  88. var cKey = parseInt(NT_File("data/" + accName + ".txt", 0).split("|")[1], 10);
  89.  
  90. NT_File("data/" + accName + ".txt", 1, game + "|" + cKey);
  91. }
  92.  
  93. function NT_File(path, mode, msg, delay) {
  94. var _msg = "";
  95. var _line = "";
  96. var _fileHandle;
  97. var _isFileCheck = false;
  98.  
  99. if (arguments.length < 3) msg = "";
  100. if (arguments.length < 4) delay = (mode > 0) ? 5 : 2;
  101.  
  102. while (delay--) {
  103. if (mode == 2 && !_isFileCheck) {
  104. _fileHandle = FileOpen(path, 0);
  105. if (!_fileHandle)
  106. _fileHandle = FileOpen(path, 1);
  107.  
  108. if (_fileHandle)
  109. _fileHandle.Close();
  110.  
  111. _isFileCheck = true;
  112. }
  113.  
  114. _fileHandle = FileOpen(path, mode);
  115. if (_fileHandle)
  116. break;
  117.  
  118. if (delay)
  119. Delay(200);
  120. }
  121.  
  122. if (_fileHandle) {
  123. if (mode == 0) {
  124. while (!_fileHandle.eof) {
  125. _line = _fileHandle.ReadLine();
  126. if (_line || !_fileHandle.eof)
  127. _msg += _line + msg;
  128. }
  129. }
  130. else if (msg)
  131. _fileHandle.WriteLine(msg);
  132.  
  133. _fileHandle.Close();
  134. }
  135.  
  136. return _msg;
  137. }
  138.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement