public void AddCarshop(Client sender, string name, CarshopType type)
        {
            AccountEntity player = sender.GetAccountEntity();

            if (player.DbModel.ServerRank < ServerRank.AdministratorRozgrywki2)
            {
                sender.SendWarning("Nie posiadasz uprawnień do tworzenia salonu samochodowego.");
                return;
            }

            sender.SendInfo("Ustaw się w wybranej pozycji, a następnie wpisz \"tu\". użyj ctrl + alt + shift + d aby poznać swoją obecną pozycję.");

            player.HereHandler += client =>
            {
                CarshopModel data = new CarshopModel
                {
                    CreatorForumName = client.GetAccountEntity().DbModel.Name,
                    Position         = client.Position,
                    Type             = type,
                };
                data.CreatorForumName = client.GetAccountEntity().DbModel.Name;

                XmlHelper.AddXmlObject(data, Path.Combine(Utils.XmlDirectory, "Carshops"));
                Carshops.Add(new CarshopEntity(data));
                sender.SendInfo("Dodawanie salonu zakończyło się pomyślnie.");
            };
        }
Example #2
0
 public CarshopVehicleModel(string name, VehicleHash hash, VehicleClass category, decimal cost, CarshopType type)
 {
     Name         = name;
     Hash         = hash;
     Category     = category;
     Cost         = cost;
     CarshopTypes = type;
 }
        public void AddVehicleToCarshop(Client sender, VehicleHash hash, VehicleClass vehicleClass, decimal cost, string type, string type2 = "Empty")
        {
            if (!sender.HasRank(ServerRank.AdministratorRozgrywki2))
            {
                sender.SendWarning("Nie posiadasz uprawnień do tworzenia pojazdu w salonie.");
                return;
            }

            if (Vehicles.Any(v => v.Hash == hash))
            {
                sender.SendError("Podany pojazd jest już dodany.");
                return;
            }

            MoneyValidator validator = new MoneyValidator();

            if (!validator.IsValid(cost))
            {
                sender.SendError("Wprowadzona kwota gotówki jest nieprawidłowa.");
                return;
            }

            CarshopType endType      = CarshopType.Empty;
            CarshopType endType2     = CarshopType.Empty;
            var         carshopTypes = ((CarshopType[])Enum.GetValues(typeof(CarshopType))).ToList();

            if (carshopTypes.All(carshopType => carshopType.GetDescription() != type && carshopType.GetDescription() != type2))
            {
                sender.SendError("Wprowadzony typ salonu jest nieprawidłowy.");
            }

            foreach (CarshopType item in carshopTypes)
            {
                if (item.GetDescription() == type)
                {
                    endType = item;
                }
                if (item.GetDescription() == type2)
                {
                    endType2 = item;
                }
            }

            if (endType2 != CarshopType.Empty)
            {
                endType = endType | endType2;
            }

            CarshopVehicleModel vehicle =
                new CarshopVehicleModel(hash.ToString(), hash, vehicleClass, cost, endType)
            {
                CreatorForumName = sender.GetAccountEntity().DbModel.Name
            };

            XmlHelper.AddXmlObject(vehicle, Path.Combine(Utils.XmlDirectory, "CarshopVehicles"), vehicle.Name);
        }