Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var gamelist = FileOpen("gamelist.txt", 0); //Opens the file in read only mode.
  2. var games = []; //Its better to initialize arrays this way, also clears the array so next cycle we don't have to worry about length causing bs issues like recursion
  3. var arrayIndex = 0 //Index for array loading
  4. if(!usestaticpw){
  5. var gamepw = FileOpen("gamepw.txt", 0);
  6. var pws = [];
  7. }
  8. var logs
  9. if(!gamelist) {
  10. DebugInOOG("no games");//Failed to open file, likely doesnt exist. Insert error crap...Should probably retry incase file is being accessed by another hunter.. but that would be rare
  11. }
  12. if(!usestaticpw){
  13. if(!gamepw) {
  14. DebugInOOG("no game pws");//Failed to open file, likely doesnt exist. Insert error crap...Should probably retry incase file is being accessed by another hunter.. but that would be rare
  15. }}
  16. //Loading array from text file
  17. while(!gamelist.eof){ //This probably would be better as a quirky for loop, but w/e
  18.     games[arrayIndex] = gamelist.ReadLine();
  19.         if(!usestaticpw)
  20.     pws[arrayIndex] = gamepw.ReadLine();
  21.    
  22.     arrayIndex++
  23. }
  24. gamelist.Close(); //MUST close filehandler as long as it doesn't return null to prevent memory leak!
  25.     if(!usestaticpw)
  26. gamepw.Close(); //MUST close filehandler as long as it doesn't return null to prevent memory leak! 
  27.  
  28. Delay(100)
  29. //Now we will write back all the other games besides the first if there is more than one game..
  30. if(arrayIndex > 1)
  31. {
  32.  
  33.     gamelist = FileOpen("gamelist.txt", 1); //Opens file in Append mode. Should probably catch null and retry incase file is being accessed by another hunter.. but that would be rare
  34.     if(!usestaticpw)
  35.     gamepw = FileOpen("gamepw.txt", 1); //Opens file in Append mode. Should probably catch null and retry incase file is being accessed by another hunter.. but that would be rare
  36.  
  37.     for (arrayIndex = 1;arrayIndex < games.length; arrayIndex++)//Heres our sexy for loop
  38.     {
  39.         gamelist.WriteLine(games[arrayIndex]);
  40.         if(!usestaticpw)
  41.         gamepw.WriteLine(pws[arrayIndex]);
  42.     }
  43.     Delay(100)
  44.     gamelist.Close(); //Once again closing the file handler so the programing gods don't smite me
  45.     if(!usestaticpw)
  46.     gamepw.Close();
  47. }
  48.    
  49.    
  50. //Game Enter stuff below here
  51. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  52.  
  53. controlData.setText( controlData.controls.lobby.join.editBox.gameName, games[0]); //It will always be the 0th index because we re-write the array
  54. Delay (1250);
  55. if(usestaticpw){
  56. controlData.setText( controlData.controls.lobby.join.editBox.password, staticpassword);
  57. }
  58. else{
  59. controlData.setText( controlData.controls.lobby.join.editBox.password, pws[0]);
  60. }
  61. Delay (1250);
  62. controlData.click(controlData.controls.lobby.join.button.joinGame);
  63. logs =  FileOpen("logs/CompleatedGames.txt", 2);
  64. logs.WriteLine(games[0]);
  65. logs.Close();
  66.             lastGameStatus = 1;
  67.            
  68.             break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement