public void BuyItemInShop(IPlayer player, int countToBuy, string jsonItemObject) { CharacterEntity characterEntity = player.GetAccountEntity().characterEntity; //int countToBuy = (int)(long)args[0]; if (countToBuy == 0) { return; } ShopAssortmentModel itemObject = JsonConvert.DeserializeObject <ShopAssortmentModel>(jsonItemObject); int itemCountCalculate = itemObject.Count * countToBuy; int itemCostCalculate = itemObject.Cost * countToBuy; if (!characterEntity.HasEnoughMoney(itemCostCalculate, false)) { player.SendErrorNotify("Nie posiadasz tylu pieniędzy", "Udaj się do banku i wypłać pieniądze, aby móc kupić ten przedmiot"); return; } ItemModel itemToCreate = new ItemModel() { Name = itemObject.Name, FirstParameter = itemObject.FirstParameter, ThirdParameter = itemObject.ThirdParameter, FourthParameter = itemObject.FourthParameter, ItemEntityType = itemObject.ItemEntityType, Count = itemCountCalculate, CharacterId = characterEntity.DbModel.Id }; characterEntity.RemoveMoney(itemCostCalculate, false); player.SendSuccessNotify($"Kupiłeś {itemCountCalculate}x {itemObject.Name.ToLower()}", "Zakupione itemy znajdują się w twoim ekwipunku"); ItemEntity itemEntity = InventoryScript.ItemFactory.Create(itemToCreate); itemEntity.Create(characterEntity); }
public void CreateItemCMD(IPlayer sender, int playerId, string name, double first, double second, double third, double fourth, int itemEntityType) { if (!sender.GetAccountEntity().HasRank((int)EAdmin.Supporter)) { return; } if (!sender.GetAccountEntity().OnAdminDuty) { sender.SendErrorNotify("Wystąpił bląd!", "Aby użyć tej komendy musisz wejść na służbę administratora"); return; } IPlayer getter = PlayerExtenstion.GetPlayerById(playerId); if (getter == null) { sender.SendErrorNotify(null, $"Gracz o ID {playerId} nie jest w grze"); return; } ItemModel item = new ItemModel() { Name = name, CreatorId = sender.GetAccountEntity().DbModel.Id, FirstParameter = first, SecondParameter = second, ThirdParameter = third, FourthParameter = fourth, ItemEntityType = (ItemEntityType)itemEntityType, CharacterId = getter.GetAccountEntity().characterEntity.DbModel.Id, VehicleId = null, BuildingId = null, ItemInUse = false }; ItemEntity itemEntity = ItemFactory.Create(item); itemEntity.Create(getter.GetAccountEntity().characterEntity); }