Advertisement
Fastmapler

A part of the saving system

Dec 18th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. static void saveGame(int id, bool notify)
  2.         {
  3.             var item = userstats.FirstOrDefault(o => o.userid == id);
  4.             string userFileName = item.name + ".txt";
  5.             string fullPath = @"C:\Users\SomeusernameidkLOL\Desktop\eebotdata\savedata\" + userFileName;
  6.             string[] lines = File.ReadAllLines(fullPath).Concat(new string[99]).ToArray();
  7.             int digStartIndex = Array.FindIndex(lines, row => row.Contains("START_DIGBOT"));
  8.             int generalStartIndex = Array.FindIndex(lines, row => row.Contains("START_GENERAL"));
  9.             lines[2] = "2";
  10.             lines[digStartIndex + 1] = item.picklvl.ToString();
  11.             lines[digStartIndex + 2] = item.picklife.ToString();
  12.             lines[digStartIndex + 3] = item.gold.ToString();
  13.             lines[digStartIndex + 4] = item.dirt.ToString();
  14.             lines = lines.Where(x => !string.IsNullOrEmpty(x)).ToArray();
  15.             File.WriteAllLines(fullPath, EMPTY_STR_LIST);
  16.             File.WriteAllLines(fullPath, lines);
  17.             if (notify)
  18.                 conn.Send("say", "/pm " + item.name + " [DigBot] Your data has been successfully saved!");
  19.             //justshop.Add(item.userid, DateTime.Now);
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement