Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case "@rui":
- {
- if (line.Length != 3)
- {
- Console.WriteLine("Usage: @rui <playerUID> <itemID>", ConsoleColor.Red);
- break;
- }
- uint playerUID;
- if (!uint.TryParse(line[1], out playerUID))
- {
- Console.WriteLine("Invalid player UID", ConsoleColor.Red);
- break;
- }
- uint itemID;
- if (!uint.TryParse(line[2], out itemID))
- {
- Console.WriteLine("Invalid item ID", ConsoleColor.Red);
- break;
- }
- WindowsAPI.BinaryFile binary = new WindowsAPI.BinaryFile();
- string filePath = Program.ServerConfig.DbLocation + "\\PlayersItems\\" + playerUID + ".bin";
- if (!System.IO.File.Exists(filePath))
- {
- Console.WriteLine("Player file not found", ConsoleColor.Red);
- break;
- }
- uint clientUID = uint.Parse(System.IO.Path.GetFileName(filePath).Replace(".bin", ""));
- Client.GameClient client = new Client.GameClient(null);
- client.Player.UID = clientUID;
- client.Inventory = new Role.Instance.Inventory(client);
- client.Equipment = new Role.Instance.Equip(client);
- client.Warehouse = new Role.Instance.Warehouse(client);
- Database.ServerDatabase.LoadClientItems(client);
- List<Task> tasks = new List<Task>();
- tasks.Add(Task.Run(() =>
- {
- var list = client.Equipment.ClientItems.Values.ToList();
- foreach (var item in list)
- {
- if (item.ITEM_ID == itemID)
- {
- client.Equipment.ClientItems.Remove(item.UID);
- Console.WriteLine($"Item {item.ITEM_ID} removed from equipment", ConsoleColor.Green);
- }
- }
- }));
- tasks.Add(Task.Run(() =>
- {
- foreach (var a in client.Warehouse.ClientItems)
- {
- foreach (var b in a.Value.Values)
- {
- if (b.ITEM_ID == itemID)
- {
- client.Warehouse.ClientItems[a.Key].Remove(b.UID);
- Console.WriteLine($"Item {b.ITEM_ID} removed from warehouse", ConsoleColor.Green);
- }
- }
- }
- }));
- tasks.Add(Task.Run(() =>
- {
- var list = client.Inventory.ClientItems.Values.ToList();
- foreach (var item in list)
- {
- if (item.ITEM_ID == itemID)
- {
- client.Inventory.ClientItems.Remove(item.UID);
- Console.WriteLine($"Item {item.ITEM_ID} removed from inventory", ConsoleColor.Green);
- }
- }
- }));
- Task.WaitAll(tasks.ToArray());
- Database.ServerDatabase.SaveClientItems(client);
- Console.WriteLine("Done processing player items", ConsoleColor.DarkRed);
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement