change stuff with objects

This commit is contained in:
2021-04-13 17:57:33 +02:00
parent 2a82f72f14
commit 61da1edcb9
15 changed files with 200 additions and 108 deletions

View File

@@ -33,6 +33,9 @@ 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<Player, PlayerTimer> itemCooldown = new Dictionary<Player, PlayerTimer>();
private static Timer aTimer;
public class InventoryItem
@@ -528,10 +531,12 @@ namespace ReallifeGamemode.Server.Managers
if (iItem is IUsableItem usableItemObj)
{
usableItemObj.Use(fItem);
List<InventoryItem> items = backpackItems[player];
player.SetSharedData("backpackItems", JsonConvert.SerializeObject(items.ToArray()));
player.TriggerEvent("aproveUse", 1, iItem.Name);
if (usableItemObj.Use(fItem))
{
List<InventoryItem> items = backpackItems[player];
player.SetSharedData("backpackItems", JsonConvert.SerializeObject(items.ToArray()));
player.TriggerEvent("aproveUse", 1, iItem.Name);
}
}
else player.TriggerEvent("Error", "Du kannst dieses Item nicht benutzen.");
break;