From d10695fc22af22b60f753ff157e3cbfeb45fb65d Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 24 Apr 2021 02:49:32 +0200 Subject: [PATCH] Fix inventar cooldown --- .../Inventory/Items/ConsumableItem.cs | 10 +++++----- ReallifeGamemode.Server/Managers/InventoryManager.cs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ReallifeGamemode.Server/Inventory/Items/ConsumableItem.cs b/ReallifeGamemode.Server/Inventory/Items/ConsumableItem.cs index 076b28cd..d5a96232 100644 --- a/ReallifeGamemode.Server/Inventory/Items/ConsumableItem.cs +++ b/ReallifeGamemode.Server/Inventory/Items/ConsumableItem.cs @@ -30,14 +30,14 @@ namespace ReallifeGamemode.Server.Inventory.Items if (!HasCooldownElapsed(user)) { - DateTime time = InventoryManager.itemCooldown[user]; + DateTime time = InventoryManager.itemCooldown[user.Id]; int timeUntillNextUse = (int)(time - DateTime.Now).TotalSeconds; uItem.GetUser().Player.TriggerEvent("Error", $"Versuche es nach {timeUntillNextUse} Sekunden erneut."); return false; } DateTime cooldown = DateTime.Now.AddMilliseconds(Cooldown); - InventoryManager.itemCooldown.Add(user, cooldown); + InventoryManager.itemCooldown.Add(user.Id, cooldown); Consume(uItem); return true; @@ -48,13 +48,13 @@ namespace ReallifeGamemode.Server.Inventory.Items if (user.Player == null || !user.Player.IsLoggedIn()) return false; - if (!InventoryManager.itemCooldown.ContainsKey(user)) + if (!InventoryManager.itemCooldown.ContainsKey(user.Id)) return true; - int timeRemaining = (int)(InventoryManager.itemCooldown[user] - DateTime.Now).TotalSeconds; + int timeRemaining = (int)(InventoryManager.itemCooldown[user.Id] - DateTime.Now).TotalSeconds; if (timeRemaining <= 0) - InventoryManager.itemCooldown.Remove(user); + InventoryManager.itemCooldown.Remove(user.Id); return timeRemaining <= 0; } diff --git a/ReallifeGamemode.Server/Managers/InventoryManager.cs b/ReallifeGamemode.Server/Managers/InventoryManager.cs index 42953d00..d20a69b8 100644 --- a/ReallifeGamemode.Server/Managers/InventoryManager.cs +++ b/ReallifeGamemode.Server/Managers/InventoryManager.cs @@ -34,7 +34,7 @@ namespace ReallifeGamemode.Server.Managers public static Dictionary> backpackItems { get; set; } = new Dictionary>(); public static Dictionary> vehicleItems { get; set; } = new Dictionary>(); - public static Dictionary itemCooldown = new Dictionary(); + public static Dictionary itemCooldown = new Dictionary(); public class InventoryItem {