Ejemplo n.º 1
0
        public void ConfirmVehicleModificationEvent(Client player, int slot, int mod)
        {
            // Get the vehicle's id
            int vehicleId = player.Vehicle.GetData(EntityData.VEHICLE_ID);

            // Get player's product amount
            int playerId = player.GetData(EntityData.PLAYER_SQL_ID);
            var item     = Globals.GetPlayerItemModelFromHash(playerId, Constants.ITEM_HASH_BUSINESS_PRODUCTS);

            // Calculate the cost for the tunning
            var totalProducts = Constants.TUNNING_PRICE_LIST.Where(x => x.slot == slot).First().products;

            if (item != null && item.amount >= totalProducts)
            {
                // Add component to database
                var tunningModel = new TunningModel();
                {
                    tunningModel.slot      = slot;
                    tunningModel.component = mod;
                    tunningModel.vehicle   = vehicleId;
                }

                Task.Factory.StartNew(() => {
                    tunningModel.id = DBMechanicCommands.AddTunning(tunningModel);
                    tunningList.Add(tunningModel);

                    // Remove consumed products
                    item.amount -= totalProducts;

                    // Update the amount into the database
                    Database.UpdateItem(item);

                    // Confirmation message
                    player.SendChatMessage(Constants.COLOR_INFO + InfoRes.vehicle_tunning);
                });
            }
            else
            {
                var message = string.Format(ErrRes.not_required_products, totalProducts);
                player.SendChatMessage(Constants.COLOR_ERROR + message);
            }
        }
Ejemplo n.º 2
0
 public void LoadRuningList()
 {
     tunningList = DBMechanicCommands.LoadAllTunning();
 }