Fix Inventory, add different Trunk sizes
This commit is contained in:
@@ -2250,6 +2250,91 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
}
|
||||
|
||||
[Command("setshopitem", "~m~Benutzung: ~s~/setshopitem [Item ID]")]
|
||||
public void CmdAdminSetItemInShop(Player player, int itemId)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
IItem item = InventoryManager.GetItemById(itemId);
|
||||
if (item is null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Item existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
|
||||
|
||||
if (nearestItemShopPoint is null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du bist nicht an einem Item Shop");
|
||||
return;
|
||||
}
|
||||
|
||||
using var dbContext = new DatabaseContext();
|
||||
|
||||
if (dbContext.ShopItems.Where(i => i.ShopId == nearestItemShopPoint.itemShop.id && i.ItemId == item.Id).FirstOrDefault() != null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Item ist bereits im Shop");
|
||||
return;
|
||||
}
|
||||
|
||||
ShopItem shopItem = new ShopItem
|
||||
{
|
||||
ShopId = nearestItemShopPoint.itemShop.id,
|
||||
ItemId = item.Id,
|
||||
Amount = 20,
|
||||
Price = item.Price
|
||||
};
|
||||
|
||||
dbContext.ShopItems.Add(shopItem);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
nearestItemShopPoint.itemShop.LoadItems();
|
||||
}
|
||||
|
||||
[Command("rmshopitem", "~m~Benutzung: ~s~/rmshopitem [Item ID]")]
|
||||
public void CmdAdminRemoveItemInShop(Player player, int itemId)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
IItem item = InventoryManager.GetItemById(itemId);
|
||||
if (item is null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Item existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
|
||||
|
||||
if (nearestItemShopPoint is null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du bist nicht an einem Item Shop");
|
||||
return;
|
||||
}
|
||||
|
||||
using var dbContext = new DatabaseContext();
|
||||
|
||||
ShopItem shopItem = dbContext.ShopItems.Where(i => i.ShopId == nearestItemShopPoint.itemShop.id && i.ItemId == item.Id).FirstOrDefault();
|
||||
|
||||
if(shopItem is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dbContext.ShopItems.Remove(shopItem);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
nearestItemShopPoint.itemShop.LoadItems();
|
||||
}
|
||||
|
||||
[Command("inventory", "~m~Benutzung: ~s~/inventory [Spieler]")]
|
||||
public void CmdAdminGiveItem(Player player, string targetname)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user