Advertisement
KidaCoding

Untitled

Jun 23rd, 2024
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | Source Code | 0 0
  1. case "reset_exp":
  2. {
  3.     WindowsAPI.IniFile ini = new WindowsAPI.IniFile("");
  4.     string usersDirectory = Program.ServerConfig.DbLocation + "\\Users\\";
  5.     string[] userFiles = System.IO.Directory.GetFiles(usersDirectory);
  6.  
  7.     int totalUsers = userFiles.Length;
  8.     int resetUsers = 0;
  9.  
  10.     foreach (string fname in userFiles)
  11.     {
  12.         ini.FileName = fname;
  13.  
  14.         ulong experience = ini.ReadUInt64("Character", "Experience", 0);
  15.         if (experience > 0)
  16.         {
  17.             ulong newExperience = experience / 2;
  18.             ini.Write<ulong>("Character", "Experience", newExperience);
  19.             resetUsers++;
  20.             string playerId = System.IO.Path.GetFileNameWithoutExtension(fname);
  21.  
  22.             Console.WriteLine($"Experience reduced for player ID: {playerId}, previous Experience: {experience}, new Experience: {newExperience}");
  23.         }
  24.     }
  25.  
  26.     Console.WriteLine($"Total players: {totalUsers}");
  27.     Console.WriteLine($"Players with Experience reduced: {resetUsers}");
  28.  
  29.     break;
  30. }
  31.  
Tags: MS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement