Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var gamelist = FileOpen("gamelist.txt", 0); //Opens the file in read only mode.
- 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
- var arrayIndex = 0 //Index for array loading
- if(!usestaticpw){
- var gamepw = FileOpen("gamepw.txt", 0);
- var pws = [];
- }
- var logs
- if(!gamelist) {
- 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
- }
- if(!usestaticpw){
- if(!gamepw) {
- 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
- }}
- //Loading array from text file
- while(!gamelist.eof){ //This probably would be better as a quirky for loop, but w/e
- games[arrayIndex] = gamelist.ReadLine();
- if(!usestaticpw)
- pws[arrayIndex] = gamepw.ReadLine();
- arrayIndex++
- }
- gamelist.Close(); //MUST close filehandler as long as it doesn't return null to prevent memory leak!
- if(!usestaticpw)
- gamepw.Close(); //MUST close filehandler as long as it doesn't return null to prevent memory leak!
- Delay(100)
- //Now we will write back all the other games besides the first if there is more than one game..
- if(arrayIndex > 1)
- {
- 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
- if(!usestaticpw)
- 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
- for (arrayIndex = 1;arrayIndex < games.length; arrayIndex++)//Heres our sexy for loop
- {
- gamelist.WriteLine(games[arrayIndex]);
- if(!usestaticpw)
- gamepw.WriteLine(pws[arrayIndex]);
- }
- Delay(100)
- gamelist.Close(); //Once again closing the file handler so the programing gods don't smite me
- if(!usestaticpw)
- gamepw.Close();
- }
- //Game Enter stuff below here
- sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
- controlData.setText( controlData.controls.lobby.join.editBox.gameName, games[0]); //It will always be the 0th index because we re-write the array
- Delay (1250);
- if(usestaticpw){
- controlData.setText( controlData.controls.lobby.join.editBox.password, staticpassword);
- }
- else{
- controlData.setText( controlData.controls.lobby.join.editBox.password, pws[0]);
- }
- Delay (1250);
- controlData.click(controlData.controls.lobby.join.button.joinGame);
- logs = FileOpen("logs/CompleatedGames.txt", 2);
- logs.WriteLine(games[0]);
- logs.Close();
- lastGameStatus = 1;
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement