Beispiel #1
0
 public void sellfish(Client player)
 {
     if (API.getPlayersInRadiusOfPosition(4F, SellFishSpot).Contains(player))
     {
         Player user = Player.PlayerData[player];
         if (user.Inventory.Any(f => f.Type.Equals(InventoryType.Fish)))
         {
             int count = 0;
             int price = 0;
             List <Inventory> fishlist = user.Inventory.Where(f => f.Type.Equals(InventoryType.Fish)).ToList();
             foreach (Inventory i in fishlist)
             {
                 count++;
                 price += Int32.Parse(i.Value.Split(',')[0]);
                 user.Inventory.Remove(i);
                 InventoryRepository.RemoveInventoryItem(i);
             }
             API.SendInfoNotification(player, "Sold " + count + " fish for a total of $" + price + ".");
             user.Money += price;
         }
         else
         {
             API.SendErrorNotification(player, "You don't have any fish to sell.");
         }
     }
     else
     {
         API.SendInfoNotification(player, "Marker added to the selling point.");
         showSidejobLocationMarker(player, SellFishSpot.Subtract(new Vector3(0, 0, 1)));
     }
 }
        private void DestroyInventoryItem(Client sender, int id)
        {
            Player    player = Player.PlayerData[sender];
            Inventory item   = player.Inventory.First(i => i.Id == id);

            player.Inventory.Remove(item);
            InventoryRepository.RemoveInventoryItem(item);

            UpdatePlayerInventory(player);

            API.SendInfoNotification(sender, "You've destroyed: " + item.Name);
        }
Beispiel #3
0
        public static void GaragePaymentCash(Player p, Inventory inv)
        {
            Vehicle veh = Vehicle.VehicleData[p.Client.vehicle];

            if (long.Parse(inv.Value) >= veh.RepairCost)
            {
                inv.Value = (long.Parse(inv.Value) - (long)veh.RepairCost).ToString();

                if (inv.Value == "0")
                {
                    p.Inventory.Remove(inv);
                    InventoryRepository.RemoveInventoryItem(inv);
                }
                else
                {
                    InventoryRepository.UpdateAsync(inv);
                }

                switch (veh.RepairType)
                {
                case VehicleRepairType.Engine: PerformEngineRepair(veh); break;

                case VehicleRepairType.Body: PerformBodyRepair(veh); break;

                case VehicleRepairType.Tyres: PerformTyreRepair(veh); break;
                }

                VehicleRepository.UpdateAsync(veh);

                p.Client.warpOutOfVehicle();
                veh.Entity.Delete(false);
                p.Client.position  = p.BusinessInteractingWith.EnterPosition;
                p.Client.dimension = 0;
                API.shared.triggerClientEvent(p.Client, "closeShopUI");
                InventoryManager.HidePlayerInventory(p);

                API.shared.ShowPopupMessage(p.Client, "Repair In Progress...",
                                            String.Format("Your {0} is now booked in for repair!<br />The vehicle should be available for collection anytime after {1}.", veh.Name, veh.RepairTime.ToString("dd/MM/yy HH:mm")));
                p.InEvent = PlayerEvent.None;
            }
            else
            {
                API.shared.SendErrorNotification(p.Client, "Insufficient funds.");
                API.shared.SendInfoNotification(p.Client, "Select new payment method:");
                InventoryManager.UpdatePlayerInventory(p);
            }
        }
Beispiel #4
0
        public static void OnBankDeposit(Player p, Inventory inv)
        {
            BankAccount bankAccount = BankRepository.GetAccountById(p.AccessingBank);

            bankAccount.Balance += long.Parse(inv.Value);

            InventoryRepository.RemoveInventoryItem(inv);
            p.Inventory.Remove(inv);

            CashLogRepository.AddNew(new CashLog(p.Id, bankAccount.Id, long.Parse(inv.Value), MoneyTransferMethod.BankDeposit));

            API.shared.SendInfoNotification(p.Client,
                                            $"Your new bank balance is {bankAccount.Balance}", 10);
            BankRepository.UpdateAsync(bankAccount);
            InventoryManager.RefreshPlayerInventory(p);
            InventoryManager.HidePlayerInventory(p, true);
        }
        public async void DeleteAllPropertyKeys(int id)
        {
            Property         property = Properties[(id - 1)];
            List <Inventory> items    = await InventoryRepository.GetInventoryItemByName(property.Name + " key");

            // --- Go through all actively loaded properties and remove the key
            foreach (Inventory item in items)
            {
                foreach (KeyValuePair <Client, Player> player in Player.PlayerData)
                {
                    Player    ply = Player.PlayerData[player.Key];
                    Inventory itm = ply.Inventory.FirstOrDefault(i => i.Id == item.Id);
                    if (itm == null)
                    {
                        continue;
                    }

                    ply.Inventory.Remove(itm);
                }

                foreach (Property prop in Properties)
                {
                    Inventory itm = prop.Inventory?.FirstOrDefault(i => i.Id == item.Id);
                    if (itm == null)
                    {
                        continue;
                    }

                    prop.Inventory.Remove(itm);
                }

                foreach (KeyValuePair <NetHandle, Vehicle> vehicle in Vehicle.VehicleData)
                {
                    Vehicle   veh = Vehicle.VehicleData[vehicle.Key];
                    Inventory itm = veh.TrunkItems?.FirstOrDefault(i => i.Id == item.Id);
                    if (itm == null)
                    {
                        continue;
                    }

                    veh.TrunkItems.Remove(itm);
                }

                InventoryRepository.RemoveInventoryItem(item);
            }
        }
Beispiel #6
0
        public static void ShopPaymentCash(Player p, Inventory inv)
        {
            if (p.ShoppingCart != null)
            {
                int total = p.ShoppingCart.Sum(sc => sc.Price * sc.Quantity);
                if (long.Parse(inv.Value) >= total)
                {
                    inv.Value = (long.Parse(inv.Value) - total).ToString();

                    foreach (ShopItem item in p.ShoppingCart)
                    {
                        for (int i = 0; i < item.Quantity; i++)
                        {
                            p.GiveInventoryItmeOfType(item.Type);
                        }

                        ShopItem shopItem = p.BusinessInteractingWith.BusinessItems.Single(bi => bi.Id == item.Id);
                        shopItem.ReservedStock -= item.Quantity;
                        shopItem.Quantity      -= item.Quantity;
                        ShopItemRepository.UpdateAsync(shopItem);
                    }
                    if (inv.Value == "0")
                    {
                        p.Inventory.Remove(inv);
                        InventoryRepository.RemoveInventoryItem(inv);
                    }
                    else
                    {
                        InventoryRepository.UpdateAsync(inv);
                    }
                }
                else
                {
                    API.shared.SendErrorNotification(p.Client, "Insufficient funds.");
                    API.shared.SendInfoNotification(p.Client, "Select new payment method:");
                    InventoryManager.UpdatePlayerInventory(p);
                }
            }
        }