Fix inventar cooldown

This commit is contained in:
hydrant
2021-04-24 02:49:32 +02:00
parent bc2975b490
commit d10695fc22
2 changed files with 6 additions and 6 deletions

View File

@@ -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;
}

View File

@@ -34,7 +34,7 @@ namespace ReallifeGamemode.Server.Managers
public static Dictionary<Player, List<InventoryItem>> backpackItems { get; set; } = new Dictionary<Player, List<InventoryItem>>();
public static Dictionary<Player, List<InventoryItem>> vehicleItems { get; set; } = new Dictionary<Player, List<InventoryItem>>();
public static Dictionary<User, DateTime> itemCooldown = new Dictionary<User, DateTime>();
public static Dictionary<int, DateTime> itemCooldown = new Dictionary<int, DateTime>();
public class InventoryItem
{