public CornerPedEntity(string name, PedHash pedHash, FullPosition spawnPosition, IEnumerable <FullPosition> nextPositions,
                        DrugType drugType, decimal moneyCount, string greeting, string goodFarewell, string badFarewell, CharacterEntity seller, int botId)
     : base(name, pedHash, spawnPosition)
 {
     BotId         = botId;
     NextPositions = nextPositions.ToList();
     DrugType      = drugType;
     MoneyCount    = moneyCount;
     Greeting      = greeting;
     GoodFarewell  = goodFarewell;
     BadFarewell   = badFarewell;
     Seller        = seller;
 }
Exemple #2
0
        public static VehicleEntity Create(FullPosition spawnPosition, VehicleHash hash, string numberPlate, int numberPlateStyle,
                                           int?creatorId, Color primaryColor, Color secondaryColor, float enginePowerMultiplier = 0f, float engineTorqueMultiplier = 0f,
                                           CharacterModel character = null, GroupModel groupModel = null)
        {
            VehicleModel vehicleModel = new VehicleModel
            {
                VehicleHash            = hash.ToString(),
                NumberPlate            = numberPlate,
                NumberPlateStyle       = numberPlateStyle,
                Character              = character,
                Group                  = groupModel,
                CreatorId              = creatorId,
                SpawnPositionX         = spawnPosition.Position.X,
                SpawnPositionY         = spawnPosition.Position.Y,
                SpawnPositionZ         = spawnPosition.Position.Z,
                SpawnRotationX         = spawnPosition.Rotation.X,
                SpawnRotationY         = spawnPosition.Rotation.Y,
                SpawnRotationZ         = spawnPosition.Rotation.Z,
                PrimaryColor           = primaryColor.ToHex(),
                SecondaryColor         = secondaryColor.ToHex(),
                EnginePowerMultiplier  = enginePowerMultiplier,
                EngineTorqueMultiplier = engineTorqueMultiplier,
                ItemsInVehicle         = new List <ItemModel>(),
                Milage                 = 0.0f,
            };

            vehicleModel.FuelTank        = GetFuelTankSize((VehicleClass)NAPI.Vehicle.GetVehicleClass(NAPI.Util.VehicleNameToModel(vehicleModel.VehicleHash)));
            vehicleModel.Fuel            = vehicleModel.FuelTank * 0.2f;
            vehicleModel.FuelConsumption = NAPI.Vehicle.GetVehicleMaxAcceleration(NAPI.Util.VehicleNameToModel(vehicleModel.VehicleHash)) / 0.2f;

            bool nonDbVehicle = character == null && groupModel == null;

            if (!nonDbVehicle)
            {
                RoleplayContext ctx = Singletons.RoleplayContextFactory.Create();
                using (VehiclesRepository repository = new VehiclesRepository(ctx))
                {
                    repository.Insert(vehicleModel);
                    repository.Save();
                }
            }

            return(new VehicleEntity(vehicleModel)
            {
                _nonDbVehicle = nonDbVehicle
            });
        }
        public CrimePedEntity(AccountEntity player, CrimeGroup group, FullPosition vehiclePosition,
                              string name, PedHash hash, FullPosition position) : base(name, hash, position)
        {
            Player          = player;
            Group           = group;
            VehiclePosition = vehiclePosition;

            RoleplayContext ctx = Singletons.RoleplayContextFactory.Create();

            using (CrimeBotsRepository repository = new CrimeBotsRepository(ctx))
                DbModel = repository.Get(crimeBot => crimeBot.GroupModel.Id == group.Id);

            List <PropertyInfo> properties = new List <PropertyInfo> {
                null
            };

            properties.AddRange(typeof(CrimeBotModel).GetProperties()
                                .Where(f => f.GetValue(DbModel) != null && (f.PropertyType == typeof(int?) || f.PropertyType == typeof(decimal?))));

            if (properties.Count % 3 != 1)
            {
                player.Client.SendError($"Konfiguracja bota grupy {Group} jest nieporawna, skontaktuj się z administratorem.");
                return;
            }

            for (int i = 0; i < properties.Count; i += 3)
            {
                if (i == 0)
                {
                    continue;
                }

                Tuple <string, ItemEntityType> info = Constant.Items.GetCrimeBotItemName(properties[i - 2].Name);
                Items.Add(new CrimeBotItem(info.Item1, ((decimal?)properties[i - 2].GetValue(DbModel)).Value, ((int?)properties[i - 1].GetValue(DbModel)).Value, ((int?)properties[i].GetValue(DbModel)).Value, info.Item2, properties[i - 1].Name));
            }
            Items.ForEach(
                x => NAPI.Chat.SendChatMessageToPlayer(Player.Client, $"Nazwa {x.Name} Koszt {x.Cost}, Ilość {x.Count}, Pole {x.DatabaseField}"));
        }
        public void AddCrimeBot(Client sender, string name)
        {
            if (!sender.HasRank(ServerRank.AdministratorRozgrywki3))
            {
                sender.SendWarning("Nie posiadasz uprawnień do tworzenia bota przestępczego.");
                return;
            }

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

            FullPosition  botPosition = null;
            VehicleEntity botVehicle  = null;

            void Handler(Client o, string message)
            {
                if (o == sender && message == "tu" && botPosition == null)
                {
                    botPosition = new FullPosition
                    {
                        Position = new Vector3
                        {
                            X = sender.Position.X,
                            Y = sender.Position.Y,
                            Z = sender.Position.Z
                        },

                        Rotation = new Vector3
                        {
                            X = sender.Rotation.X,
                            Y = sender.Rotation.Y,
                            Z = sender.Rotation.Z
                        },

                        Direction = new Vector3(0f, 0f, 0f)
                    };

                    NAPI.ClientEvent.TriggerClientEvent(sender,
                                                        "DrawAddingCrimeBotComponents",
                                                        new Vector3(botPosition.Position.X, botPosition.Position.Y, botPosition.Position.Z - 1));

                    sender.SendInfo("Ustaw pojazd w wybranej pozycji następnie wpisz \"tu\".");

                    botVehicle = VehicleEntity.Create(
                        new FullPosition(new Vector3(
                                             sender.Position.X + 2,
                                             sender.Position.Y + 2,
                                             sender.Position.Z), sender.Rotation),
                        VehicleHash.Sentinel, name, 0, sender.GetAccountEntity().DbModel.Id, new Color(0, 0, 0), new Color(0, 0, 0));

                    NAPI.Player.SetPlayerIntoVehicle(sender, botVehicle.GameVehicle, -1);
                }
                else if (o == sender && message == "tu" && botPosition != null && botVehicle != null)
                {
                    FullPosition botVehiclePosition = new FullPosition
                    {
                        Position = new Vector3
                        {
                            X = botVehicle.GameVehicle.Position.X,
                            Y = botVehicle.GameVehicle.Position.Y,
                            Z = botVehicle.GameVehicle.Position.Z
                        },

                        Rotation = new Vector3
                        {
                            X = botVehicle.GameVehicle.Rotation.X,
                            Y = botVehicle.GameVehicle.Rotation.Y,
                            Z = botVehicle.GameVehicle.Rotation.Z
                        },

                        Direction = new Vector3(0f, 0f, 0f)
                    };

                    NAPI.ClientEvent.TriggerClientEvent(sender, "DisposeAddingCrimeBotComponents");

                    XmlHelper.AddXmlObject(new CrimeBotPosition
                    {
                        CreatorForumName = o.GetAccountEntity().DbModel.Name,
                        Name             = name,
                        BotPosition      = botPosition,
                        VehiclePosition  = botVehiclePosition
                    }, Path.Combine(Utils.XmlDirectory, "CrimeBotPositions"));

                    sender.SendInfo("Dodawanie pozycji bota zakończyło się pomyślnie!");
                    NAPI.Player.WarpPlayerOutOfVehicle(sender);
                    botVehicle.Dispose();
                }
            };
        }
Exemple #5
0
 public EmployerPedEntity(string name, PedHash pedHash, FullPosition position) : base(name, pedHash, position)
 {
 }
        public void AddCorner(Client sender, string ids)
        {
            List <string> botIds = ids.Split(',').ToList();

            //Sprawdzamy czy gracz podał prawidłowe ID NPC
            if (!CornerBotHelper.TryGetCornerBotIds(botIds, out List <int> correctBotIds))
            {
                sender.SendError("Podano dane w nieprawidłowym formacie. Lub podany NPC nie istnieje.");
                return;
            }

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

            FullPosition        position     = null;
            List <FullPosition> botPositions = new List <FullPosition>();

            void Handler(Client o, string message)
            {
                if (position == null && o == sender && message == "tu")
                {
                    position = new FullPosition
                    {
                        Position = new Vector3
                        {
                            X = sender.Position.X,
                            Y = sender.Position.Y,
                            Z = sender.Position.Z - 0.5f
                        },

                        Rotation = new Vector3
                        {
                            X = sender.Rotation.X,
                            Y = sender.Rotation.Y,
                            Z = sender.Rotation.Z
                        }
                    };

                    sender.SendInfo("Wyznacz trasę npc na rogu. Ustaw się w danym punkcie i wpisz \"poz\".");
                    sender.SendInfo("Aby zacząć od nowa wpisz \"reset\"");
                    sender.SendInfo("Aby usunąć ostatnią pozycję wpisz \"usun\"");
                }
                else if (position != null && o == sender && message == "/poz")
                {
                    botPositions.Add(new FullPosition
                    {
                        Position = new Vector3
                        {
                            X = sender.Position.X,
                            Y = sender.Position.Y,
                            Z = sender.Position.Z
                        },

                        Rotation = new Vector3
                        {
                            X = sender.Rotation.X,
                            Y = sender.Rotation.Y,
                            Z = sender.Rotation.Z
                        }
                    });

                    sender.SendInfo($"Obecna liczba punktów: {botPositions.Count}. Aby zakończyć wpisz \"zakoncz\"");
                    sender.SendInfo("Aby zacząć od nowa wpisz /reset");
                }
                else if (position != null && botPositions.Count != 0 && o == sender && message == "zakoncz")
                {
                    CornerModel data = new CornerModel
                    {
                        CreatorForumName = o.GetAccountEntity().DbModel.Name,
                        Position         = position,
                        CornerBots       = XmlHelper.GetXmlObjects <CornerBotModel>(Path.Combine(Utils.XmlDirectory, "CornerBots"))
                                           .Where(bot => correctBotIds.Contains(bot.BotId)).ToList(),
                        BotPositions = botPositions
                    };
                    //Dodajemy nowy plik .xml
                    XmlHelper.AddXmlObject(data, Path.Combine(Utils.XmlDirectory, "Corners"));
                    CornerEntity corner = new CornerEntity(data);
                    Corners.Add(corner);

                    sender.SendInfo("Dodawanie rogu zakończyło się pomyślnie.");
                }
                else if (botPositions.Count != 0 && position != null && o == sender && message == "usun")
                {
                    botPositions.RemoveAt(botPositions.Count);
                }
                else if (botPositions.Count != 0 && position != null && o == sender && message == "reset")
                {
                    position     = null;
                    botPositions = new List <FullPosition>();
                    sender.SendInfo("Ustaw się w wybranej pozycji, a następnie wpisz \"tu\".");
                    sender.SendInfo("...użyj /diag aby poznać swoją obecną pozycję.");
                }
            };
        }
Exemple #7
0
 public PedEntity(string name, PedHash pedHash, FullPosition spawnPosition)
 {
     Name          = name;
     PedHash       = pedHash;
     SpawnPosition = spawnPosition;
 }