private Property TransformToProperty(Data.Property config)
        {
            var data = new Property();

            data.Name                  = config.Name;
            data.Inherited             = config.Inherited;
            data.Type                  = config.Type;
            data.IgnoreSerialization   = config.IgnoreSerialization;
            data.EmitDefaultValue      = config.EmitDefaultValue;
            data.Default               = config.Default;
            data.Text                  = config.Text ?? config.Name;
            data.IsEntity              = config.IsEntity;
            data.BubblePropertyChanged = config.BubblePropertyChanged || config.IsEntity;
            data.Nullable              = config.Nullable ?? !config.UniqueKey;
            data.UnqiueKey             = config.UniqueKey;
            data.Immutable             = false;
            data.Clean                 = !data.Immutable && !data.Inherited && !config.ExcludeCleanup;
            data.DisplayName           = data.Name.ToDisplayName();

            if (data.IsString)
            {
                data.StringTrim      = "UseDefault";
                data.StringTransform = "UseDefault";
            }

            if (data.IsDateTime)
            {
                data.DateTimeTransform = "UseDefault";
            }

            return(data);
        }
Example #2
0
 public PropertyViewModel(Data.Property row)
 {
     this.Id       = row.Id;
     this.Name     = row.Name;
     this.Unit     = row.Unit;
     this.Building = row.Building;
     this.Street   = row.Street;
     this.City     = row.City;
     this.Region   = row.Region;
     this.Country  = row.Country;
     this.ZipCode  = row.ZipCode;
     this.Rating   = row.Rating;
 }
Example #3
0
        public static void CreateProperty(Client player, string ownerType, PropertyType type, string Name)
        {
            Data.Property propertyData = new Data.Property();
            string        ownerName;

            if (ownerType == "player")
            {
                AccountController TargetAccountController = AccountController.GetAccountControllerFromName(Name);
                if (TargetAccountController == null)
                {
                    return;
                }
                propertyData.Character = TargetAccountController.CharacterController.Character;
                ownerName = TargetAccountController.CharacterController.FormatName;
            }
            else if (ownerType == "group")
            {
                Groups.GroupController GroupController = EntityManager.GetGroup(player, Name);
                if (GroupController == null)
                {
                    return;
                }

                propertyData.Group = GroupController.Group;
                ownerName          = GroupController.Group.Name;
            }
            else
            {
                API.shared.sendChatMessageToPlayer(player, "~r~ERROR: ~w~You specified an invalid owner type (player/group");
                return;
            }

            PropertyController PropertyController = new PropertyController(propertyData);

            propertyData.Type            = type;
            propertyData.ExtPosX         = player.position.X;
            propertyData.ExtPosY         = player.position.Y;
            propertyData.ExtPosZ         = player.position.Z;
            PropertyController.ownername = ownerName;

            ContextFactory.Instance.Property.Add(propertyData);
            ContextFactory.Instance.SaveChanges();
            PropertyController.CreateWorldEntity();
            API.shared.sendChatMessageToPlayer(player, "~g~Server: ~w~ Added a " + PropertyController.Type() + " owned by " + ownerName);
        }
        private void OnClientEventTrigger(Client player, string eventName, object[] args)
        {
            CharacterController characterController = player.getData("CHARACTER");

            if (characterController == null)
            {
                return;
            }
            var character  = characterController.Character;
            var formatName = character.Name.Replace("_", " ");

            if (eventName == "onKeyUp")
            {
                var key = (int)args[0];

                if (key == 2)
                {
                    PropertyController propertyController;
                    if ((propertyController = player.getData("AT_PROPERTY")) != null)
                    {
                        propertyController.PropertyDoor(player);
                    }
                }
                else if (key == 3)
                {
                    if (player.isInVehicle)
                    {
                        player.vehicle.specialLight = true;
                    }
                }
                else if (key == 4)
                {
                    if (player.isInVehicle)
                    {
                        player.vehicle.specialLight = true;
                    }
                }
                else if (key == 5)
                {
                    if (player.isInVehicle)
                    {
                        VehicleController.TriggerDoor(player.vehicle, 4);
                    }
                }
                else if (key == 6)
                {
                    if (player.isInVehicle)
                    {
                        VehicleController.TriggerDoor(player.vehicle, 5);
                    }
                }
                else if (key == 8)
                {
                    CharacterController.StopAnimation(player);
                }
                // Get info about Player:
                else if (key == 9)
                {
                    if (character == null)
                    {
                        return;
                    }
                    var job = "";
                    switch (character.JobId)
                    {
                    case JobsIdNonDataBase.Homeless: job = "Бомж"; break;

                    case JobsIdNonDataBase.Loader1: job = "Грузчик: С1"; break;

                    case JobsIdNonDataBase.Loader2: job = "Грузчик: С2"; break;

                    case JobsIdNonDataBase.TaxiDriver: job = "Таксист"; break;

                    case JobsIdNonDataBase.BusDriver1: job = "Водитель автобуса: М1"; break;

                    case JobsIdNonDataBase.BusDriver2: job = "Водитель автобуса: М2"; break;

                    case JobsIdNonDataBase.BusDriver3: job = "Водитель автобуса: М3"; break;

                    case JobsIdNonDataBase.BusDriver4: job = "Водитель автобуса: М4"; break;

                    case JobsIdNonDataBase.Mechanic: job = "Автомеханик"; break;
                    }

                    var getGroup = ContextFactory.Instance.Group.FirstOrDefault(x => x.Id == character.ActiveGroupID);
                    if (getGroup == null)
                    {
                        return;
                    }
                    var groupType      = (GroupType)Enum.Parse(typeof(GroupType), getGroup.Type.ToString());
                    var groupExtraType = (GroupExtraType)Enum.Parse(typeof(GroupExtraType), getGroup.ExtraType.ToString());

                    var driverLicense = character.DriverLicense == 1 ? "Да" : "Нет";

                    API.shared.triggerClientEvent(player, "character_menu",
                                                  2,                                                 // 0
                                                  "Ваша статистика",                                 // 1
                                                  "Ваше имя: " + formatName,                         // 2
                                                  character.Age,                                     // 3
                                                  character.Level.ToString(),                        // 4
                                                  job,                                               // 5
                                                  character.Bank.ToString(),                         // 6
                                                  driverLicense,                                     // 7
                                                  character.Debt,                                    // 8
                                                  EntityManager.GetDisplayName(groupType),           // 9
                                                  EntityManager.GetDisplayName(groupExtraType),      // 10
                                                  character.Material,                                // 11
                                                  CharacterController.IsCharacterInMafia(character), // 12
                                                  CharacterController.IsCharacterInGang(character),  // 13
                                                  character.Narco,                                   // 14
                                                  character.MobilePhone);                            // 15
                }
                // GET info about car
                else if (key == 10)
                {
                    try
                    {
                        VehicleController vehicleController;

                        bool inVehicleCheck;
                        if (player.isInVehicle)
                        {
                            vehicleController = EntityManager.GetVehicle(player.vehicle);
                            inVehicleCheck    = true;
                        }
                        else
                        {
                            vehicleController = EntityManager.GetVehicleControllers().Find(x => x.Vehicle.position.DistanceTo(player.position) < 3.0f);
                            inVehicleCheck    = false;
                        }
                        if (vehicleController == null)
                        {
                            API.sendNotificationToPlayer(player, "Вы находитесь далеко от транспорта.");
                            return;
                        }

                        int engineStatus = 0;
                        if (API.getVehicleEngineStatus(vehicleController.Vehicle))
                        {
                            engineStatus = 1;
                        }

                        int driverDoorStatus = 1;
                        if (API.getVehicleLocked(vehicleController.Vehicle))
                        {
                            driverDoorStatus = 0;
                        }
                        var fuel = vehicleController.VehicleData.FuelTank;

                        var getGroup = ContextFactory.Instance.Group.FirstOrDefault(x => x.Id == character.ActiveGroupID);
                        if (getGroup == null)
                        {
                            return;
                        }

                        var    groupType = (GroupType)Enum.Parse(typeof(GroupType), getGroup.Type.ToString());
                        string owner;
                        if (vehicleController.VehicleData.GroupId == null)
                        {
                            owner = "Владелец: " + formatName;
                        }
                        else
                        {
                            owner = "Владелец: " + EntityManager.GetDisplayName(groupType);
                        }

                        API.shared.triggerClientEvent(player, "vehicle_menu",
                                                      2,                                       // 0
                                                      "Меню транспорта",                       // 1
                                                      owner,                                   // 2
                                                      engineStatus,                            // 3
                                                      fuel.ToString(),                         // 4
                                                      inVehicleCheck,                          // 5
                                                      driverDoorStatus,                        // 6
                                                      vehicleController.VehicleData.Material); // 7
                    }
                    catch (Exception)
                    {
                    }
                }
                // Get info about work possibilities:
                else if (key == 12)
                {
                    try
                    {
                        if (character == null)
                        {
                            return;
                        }
                        var getGroup = ContextFactory.Instance.Group.FirstOrDefault(x => x.Id == character.ActiveGroupID);
                        if (getGroup == null)
                        {
                            return;
                        }
                        var groupType      = (GroupType)Enum.Parse(typeof(GroupType), getGroup.Type.ToString());
                        var groupExtraType = (GroupExtraType)Enum.Parse(typeof(GroupExtraType), getGroup.ExtraType.ToString());

                        var playerWeapons = API.getPlayerWeapons(player);
                        var weaponList    = "";
                        for (var i = 0; i < playerWeapons.Length; i++)
                        {
                            weaponList += playerWeapons[i] + "-";
                        }

                        var materialProperty = new Data.Property();

                        var moneyStockGroup = new Group();
                        var groupStockName  = GroupController.GetGroupStockName(character);
                        var moneyBankGroup  = character.GroupType * 100;

                        var gangRank = (int)groupExtraType - (int)groupType * 100;

                        try { materialProperty = ContextFactory.Instance.Property.First(x => x.Name == groupStockName); }
                        catch (Exception)
                        {
                            // ignored
                        }
                        try { moneyStockGroup = ContextFactory.Instance.Group.First(x => x.Id == moneyBankGroup); }
                        catch (Exception)
                        {
                            // ignored
                        }

                        var gangsSectors          = GroupController.GetGangsSectors();
                        var gangCurrentSector     = CharacterController.InWhichSectorOfGhetto(player).Split(';');
                        var gangCurrentSectorData = GroupController.GetGangSectorData(Convert.ToInt32(gangCurrentSector[0]), Convert.ToInt32(gangCurrentSector[1]));
                        if (gangCurrentSectorData > 100)
                        {
                            gangCurrentSectorData /= 10;
                        }
                        var isSectorInYourGang = gangCurrentSectorData == (int)groupType;
                        if (gangCurrentSectorData > 100 && isSectorInYourGang == false)
                        {
                            isSectorInYourGang = true;
                        }

                        var emergencyCost = ContextFactory.Instance.Group.FirstOrDefault(x => x.Id == 200);

                        API.shared.triggerClientEvent(player, "workposs_menu",
                                                      1,                                                                             // 0
                                                      character.ActiveGroupID,                                                       // 1
                                                      character.JobId,                                                               // 2
                                                      character.TempVar,                                                             // 3
                                                      character.Admin,                                                               // 4
                                                      EntityManager.GetDisplayName(groupType),                                       // 5
                                                      EntityManager.GetDisplayName(groupExtraType),                                  // 6
                                                      character.Material,                                                            // 7
                                                      CharacterController.IsCharacterInGang(characterController),                    // 8
                                                      CharacterController.IsCharacterGangBoss(characterController),                  // 9
                                                      CharacterController.IsCharacterArmyHighOfficer(characterController.Character), // 10
                                                      CharacterController.IsCharacterInGhetto(player),                               // 11
                                                      CharacterController.IsCharacterArmyGeneral(characterController),               // 12
                                                      weaponList,                                                                    // 13
                                                      character.OID,                                                                 // 14
                                                      materialProperty.Stock,                                                        // 15
                                                      moneyStockGroup.MoneyBank,                                                     // 16
                                                      CharacterController.IsCharacterHighRankInGang(character),                      // 17
                                                      gangRank,                                                                      // 18
                                                      (int)groupType,                                                                // 19
                                                      gangsSectors,                                                                  // 20
                                                      isSectorInYourGang,                                                            // 21
                                                      groupStockName,                                                                // 22
                                                      CharacterController.IsCharacterInMafia(characterController),                   // 23
                                                      emergencyCost.MoneyBank);                                                      // 24
                    }
                    catch (Exception)
                    {}
                }
                // MOBILE PHONE:
                else if (key == 13)
                {
                    if (player.getData("MOBILEPHONE") == 0)
                    {
                        API.sendNotificationToPlayer(player, "~r~У вас нет мобильного телефона. Купите его в 24/7!");
                        return;
                    }
                    var allMessages = ContextFactory.Instance.Mobile.Where(x => x.To == character.MobilePhone).ToList();
                    foreach (var message in allMessages)
                    {
                        var fromPlayers = message.From;
                    }
                }
                else if (key == 14)
                {
                }
                else if (key == 15)
                {
                    player.setData("BUTTON_VOICE", player.getData("BUTTON_VOICE") == 0 ? 1 : 0);
                    API.shared.sendNotificationToPlayer(player, "~y~Микрофон: " + (player.getData("BUTTON_VOICE") == 0 ? "~r~Выкл" : "~g~Вкл"));
                }
            }
        }
Example #5
0
 public PropertyController(Data.Property PropertyData)
 {
     this.PropertyData = PropertyData;
 }
Example #6
0
        public static void SpawnCharacter(Client player, CharacterController characterController)
        {
            API.shared.triggerClientEvent(player, "destroyCamera");
            API.shared.resetPlayerNametagColor(player);

            if (characterController.Character.RegistrationStep == 0)
            {
                var face = ContextFactory.Instance.Faces.FirstOrDefault(x => x.CharacterId == characterController.Character.Id);
                if (face == null)
                {
                    CharacterController.InitializePedFace(player.handle);
                    API.shared.triggerClientEvent(player, "face_custom");
                    return;
                }
                SetCharacterFace(player, characterController.Character);
                ClothesManager.SetPlayerSkinClothes(player, 0, characterController.Character, true);
                ClothesManager.WardrobeInit(characterController.Character);
                WeaponManager.SetPlayerWeapon(player, characterController.Character, 0);
                API.shared.setEntityPosition(player, FirstPlayerPosition);
                API.shared.setEntityRotation(player, FirstPlayerRotation);
                characterController.Character.RegistrationStep = -1; // 'Tutorial Done'
            }
            else
            {
                SetCharacterFace(player, characterController.Character);
                ClothesManager.SetPlayerSkinClothes(player, 0, characterController.Character, false);
                WeaponManager.SetPlayerWeapon(player, characterController.Character, 1);
                API.shared.setEntityPosition(player, NewPlayerPosition);
                API.shared.setEntityRotation(player, NewPlayerRotation);
            }

            if (CharacterController.IsCharacterArmySoldier(characterController))
            {
                var placeArmy = characterController.Character.ActiveGroupID < 2003 ?
                                ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 2000)
                    : ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 2100);

                if (placeArmy != null)
                {
                    API.shared.setEntityPosition(player, new Vector3(placeArmy.ExtPosX, placeArmy.ExtPosY, placeArmy.ExtPosZ));
                    API.shared.setEntityRotation(player, NewPlayerRotation);
                }
            }
            if (CharacterController.IsCharacterInGang(characterController))
            {
                var placeGangs = new Data.Property();

                if (characterController.Character.ActiveGroupID > 1300 &&
                    characterController.Character.ActiveGroupID <= 1310)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1300);
                }
                if (characterController.Character.ActiveGroupID > 1400 &&
                    characterController.Character.ActiveGroupID <= 1410)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1400);
                }
                if (characterController.Character.ActiveGroupID > 1500 &&
                    characterController.Character.ActiveGroupID <= 1510)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1500);
                }
                if (characterController.Character.ActiveGroupID > 1600 &&
                    characterController.Character.ActiveGroupID <= 1610)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1600);
                }
                if (characterController.Character.ActiveGroupID > 1700 &&
                    characterController.Character.ActiveGroupID <= 1710)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1700);
                }

                if (placeGangs != null)
                {
                    API.shared.setEntityPosition(player, new Vector3(placeGangs.ExtPosX, placeGangs.ExtPosY, placeGangs.ExtPosZ));
                    API.shared.setEntityRotation(player, NewPlayerRotation);
                }
            }
            var userHouse = ContextFactory.Instance.Property.FirstOrDefault(x => x.CharacterId == characterController.Character.Id);

            if (userHouse != null)
            {
                API.shared.setEntityPosition(player, new Vector3(userHouse.IntPosX, userHouse.IntPosY, userHouse.IntPosZ));
                API.shared.setEntityRotation(player, NewPlayerRotation);
            }
            if (player.getData("ISDYED") == true && !CharacterController.IsCharacterInGang(characterController))
            {
                API.shared.setEntityPosition(player, new Vector3(260.26f, -1357.64f, 24.54f));
                player.setData("ISDYED", false);
                player.health = 20;
            }
            ContextFactory.Instance.SaveChanges();
        }
        public static void SpawnCharacter(Client player, CharacterController characterController)
        {
            API.shared.triggerClientEvent(player, "destroyCamera");
            API.shared.resetPlayerNametagColor(player);

            if (characterController.Character.RegistrationStep == 0)
            {
                SetCharacterFace(player, characterController.Character);
                ClothesManager.SetPlayerSkinClothes(player, 0, characterController.Character, 0);
                WeaponManager.SetPlayerWeapon(player, characterController.Character, 0);
                API.shared.setEntityPosition(player, FirstPlayerPosition);
                API.shared.setEntityRotation(player, FirstPlayerRotation);
                characterController.Character.RegistrationStep = -1; // 'Tutorial Done'
            }
            else
            {
                SetCharacterFace(player, characterController.Character);
                ClothesManager.SetPlayerSkinClothes(player, 0, characterController.Character, 1);
                WeaponManager.SetPlayerWeapon(player, characterController.Character, 1);
                API.shared.setEntityPosition(player, NewPlayerPosition);
                API.shared.setEntityRotation(player, NewPlayerRotation);
            }

            if (CharacterController.IsCharacterArmySoldier(characterController))
            {
                var placeArmy = new Data.Property();

                if (characterController.Character.ActiveGroupID < 2003)
                {
                    placeArmy = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 2000);
                }
                else
                {
                    placeArmy = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 2100);
                }

                if (placeArmy != null)
                {
                    API.shared.setEntityPosition(player, new Vector3(placeArmy.ExtPosX, placeArmy.ExtPosY, placeArmy.ExtPosZ));
                    API.shared.setEntityRotation(player, NewPlayerRotation);
                }
            }
            if (CharacterController.IsCharacterInGang(characterController))
            {
                var placeGangs = new Data.Property();

                if (characterController.Character.ActiveGroupID > 1300 &&
                    characterController.Character.ActiveGroupID <= 1310)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1300);
                }
                if (characterController.Character.ActiveGroupID > 1400 &&
                    characterController.Character.ActiveGroupID <= 1410)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1400);
                }
                if (characterController.Character.ActiveGroupID > 1500 &&
                    characterController.Character.ActiveGroupID <= 1510)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1500);
                }
                if (characterController.Character.ActiveGroupID > 1600 &&
                    characterController.Character.ActiveGroupID <= 1610)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1600);
                }
                if (characterController.Character.ActiveGroupID > 1700 &&
                    characterController.Character.ActiveGroupID <= 1710)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1700);
                }

                if (placeGangs != null)
                {
                    API.shared.setEntityPosition(player, new Vector3(placeGangs.ExtPosX, placeGangs.ExtPosY, placeGangs.ExtPosZ));
                    API.shared.setEntityRotation(player, NewPlayerRotation);
                }
            }
            var userHouse = ContextFactory.Instance.Property.FirstOrDefault(x => x.CharacterId == characterController.Character.Id);

            if (userHouse != null)
            {
                API.shared.setEntityPosition(player, new Vector3(userHouse.ExtPosX, userHouse.ExtPosY, userHouse.ExtPosZ));
                API.shared.setEntityRotation(player, NewPlayerRotation);
            }
            ContextFactory.Instance.SaveChanges();
        }