Beispiel #1
0
        public override void UseItem(CharacterEntity sender)
        {
            if (sender.ItemsInUse.Any(item => item is Smartphone && !ReferenceEquals(item, this)))
            {
                sender.AccountEntity.Player.SendChatMessageError("Możesz mieć wlączony tylko jeden telefon!");
                return;
            }

            if (sender.ItemsInUse.Any(item => ReferenceEquals(item, this)))
            {
                DbModel.ItemInUse = false;

                sender.ItemsInUse.Remove(this);
                sender.CurrentSmartphone = null;

                EntityHelper.Remove(this);
            }
            else
            {
                DbModel.ItemInUse = true;

                sender.ItemsInUse.Add(this);
                sender.CurrentSmartphone = this;

                EntityHelper.Add(this);
                // TODO: wysylanie wszystkich danych
            }
        }
Beispiel #2
0
        public void AddBusStop(Client sender, string name)
        {
            if (!sender.HasRank(ServerRank.AdministratorRozgrywki2))
            {
                sender.SendError("Nie posiadasz uprawnień do usuwania przystanku autobusowego.");
                return;
            }

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

            Vector3 center = null;

            void Handler(Client o, string command)
            {
                if (center == null && o == sender && command == "tu")
                {
                    center = o.Position;
                    BusStopModel data = new BusStopModel
                    {
                        Name             = name,
                        Center           = center,
                        CreatorForumName = o.GetAccountEntity().DbModel.Name,
                    };
                    XmlHelper.AddXmlObject(data, Path.Combine(Utils.XmlDirectory, nameof(BusStopModel), data.Name));

                    sender.SendError("Dodawanie przystanku zakończyło się pomyślnie.");
                    BusStopEntity busStop = new BusStopEntity(data);
                    busStop.Spawn();
                    EntityHelper.Add(busStop);
                }
            }
        }
Beispiel #3
0
        public async Task Spawn(bool respawnNew = false) => await AltAsync.Do(async() =>
        {
            if (respawnNew)
            {
                Save(true);
            }

            ColShape = Alt.CreateColShapeCylinder(new Position(DbModel.PosX, DbModel.PosY, DbModel.PosZ), 1f, 2f);

            MarkerModel = new MarkerModel()
            {
                Type         = 27,
                Dimension    = 0,
                PosX         = DbModel.PosX,
                PosY         = DbModel.PosY,
                PosZ         = DbModel.PosZ,
                DirX         = 0,
                DirY         = 0,
                DirZ         = 0,
                RotX         = 0,
                RotY         = 0,
                RotZ         = 0,
                ScaleX       = 1f,
                ScaleY       = 1f,
                ScaleZ       = 1f,
                Red          = 0,
                Green        = 153,
                Blue         = 0,
                Alpha        = 100,
                BobUpAndDown = false,
                FaceCamera   = false,
                P19          = 2,
                Rotate       = false,
                TextureDict  = null,
                TextureName  = null,
                DrawOnEnts   = false,
                UniqueID     = $"ATM_MARKER{DbModel.Id}"
            };

            BlipModel = new BlipModel()
            {
                PosX       = DbModel.PosX,
                PosY       = DbModel.PosY,
                PosZ       = DbModel.PosZ + 1,
                Blip       = 277,
                Color      = 25,
                Size       = EBlipSize.Medium,
                Name       = "ATM",
                ShortRange = true,
                UniqueID   = $"ATM{DbModel.Id}"
            };

            await MarkerHelper.CreateGlobalMarker(MarkerModel);
            await BlipHelper.CreateGlobalBlip(BlipModel);

            ColShape.SetData("atm:data", this);

            EntityHelper.Add(this);
        });
Beispiel #4
0
        public void Create()
        {
            Marker = new MarkerModel()
            {
                Type         = 1,
                Dimension    = 0,
                PosX         = JobEntityModel.Position.X,
                PosY         = JobEntityModel.Position.Y,
                PosZ         = JobEntityModel.Position.Z - 0.9f,
                DirX         = 0,
                DirY         = 0,
                DirZ         = 0,
                RotX         = 0,
                RotY         = 0,
                RotZ         = 0,
                ScaleX       = 1f,
                ScaleY       = 1f,
                ScaleZ       = 1f,
                Red          = 0,
                Green        = 153,
                Blue         = 0,
                Alpha        = 100,
                BobUpAndDown = false,
                FaceCamera   = false,
                P19          = 2,
                Rotate       = false,
                TextureDict  = null,
                TextureName  = null,
                DrawOnEnts   = false,
                UniqueID     = $"JOB_MARKER{JobEntityModel.JobType}"
            };

            ColShape = Alt.CreateColShapeCylinder(new Position(JobEntityModel.Position.X, JobEntityModel.Position.Y, JobEntityModel.Position.Z - 0.9f), 1f, 2f);

            JobEntityFactory entityFactory = new JobEntityFactory();

            Job = entityFactory.Create(JobEntityModel);

            Blip = new BlipModel()
            {
                PosX       = JobEntityModel.Position.X,
                PosY       = JobEntityModel.Position.Y,
                PosZ       = JobEntityModel.Position.Z,
                Blip       = entityFactory.CreateBlip(JobEntityModel.JobType),
                Color      = entityFactory.CreateColor(JobEntityModel.JobType),
                Size       = EBlipSize.Medium,
                Name       = $"{JobEntityModel.JobName} (Praca dorywcza)",
                ShortRange = true,
                UniqueID   = $"JOB_BLIP{JobEntityModel.JobType}"
            };

            ColShape.SetData("job:data", this);
            EntityHelper.Add(this);
        }
        public async void Login(Character character)
        {
            Player.SetData("account:data", this);
            SetAccountDataToClient();

            characterEntity = new CharacterEntity(this, character);
            EntityHelper.Add(this);

            IsLogged = true;
            await characterEntity.Spawn();
        }
Beispiel #6
0
        public async Task Spawn() => await AltAsync.Do(async() =>
        {
            ColShape = Alt.CreateColShapeCylinder(new Position(DbModel.PosX, DbModel.PosY, DbModel.PosZ - 0.9f), 1f, 2f);

            MarkerModel = new MarkerModel()
            {
                Type         = 27,
                Dimension    = 0,
                PosX         = DbModel.PosX,
                PosY         = DbModel.PosY,
                PosZ         = DbModel.PosZ - 0.9f,
                DirX         = 0,
                DirY         = 0,
                DirZ         = 0,
                RotX         = 0,
                RotY         = 0,
                RotZ         = 0,
                ScaleX       = 1f,
                ScaleY       = 1f,
                ScaleZ       = 1f,
                Red          = 0,
                Green        = 153,
                Blue         = 0,
                Alpha        = 100,
                BobUpAndDown = false,
                FaceCamera   = false,
                P19          = 2,
                Rotate       = false,
                TextureDict  = null,
                TextureName  = null,
                DrawOnEnts   = false,
                UniqueID     = $"SHOP{DbModel.Id}"
            };

            BlipModel = new BlipModel()
            {
                PosX       = DbModel.PosX,
                PosY       = DbModel.PosY,
                PosZ       = DbModel.PosZ + 1,
                Blip       = 52,
                Color      = 38,
                Size       = EBlipSize.Medium,
                Name       = ShopEntityFactory.CreateShopName(DbModel.ShopEntityType),
                ShortRange = true,
                UniqueID   = $"SHOP{DbModel.Id}"
            };

            await MarkerHelper.CreateGlobalMarker(MarkerModel);
            await BlipHelper.CreateGlobalBlip(BlipModel);
            EntityHelper.Add(this);
            ColShape.SetData("shop:data", this);
        });
Beispiel #7
0
        public void CreateWorldItemObject(IPlayer player, uint objectHash, string positionJson, string rotationJson, int itemID)
        {
            Vector3 position = JsonConvert.DeserializeObject <Vector3>(positionJson);
            Vector3 rotation = JsonConvert.DeserializeObject <Vector3>(rotationJson);

            DynamicObject dynamicObject = ObjectStreamer.CreateDynamicObject(objectHash, position, rotation, player.Dimension, null, true, null, null, null, null, true, 275);

            dynamicObject.SetData("dynamicObject:ownerAccountId", player.GetAccountEntity().DbModel.Id);

            Alt.Log($"ID OBIEKTU STWORZONEGO: {dynamicObject.Id}");
            EntityHelper.Add(dynamicObject);

            player.SendSuccessNotify("Postawiono obiekt pomyślnie", "Twój obiekt został postawiony");
            player.Emit("item:synchronizateWorldObjectWithClient", dynamicObject.Id, itemID);
        }
Beispiel #8
0
        public void Spawn()
        {
            Alt.Log($"[WAREHOUSE-ENTITY] Warehouse dla grupy {GroupEntity.DbModel.Id} został stworzony");

            ColShape = Alt.CreateColShapeCylinder(new Position(DbModel.PosX, DbModel.PosY, DbModel.PosZ - 0.9f), 5f, 2f);
            ColShape.SetData("warehouse:data", this);


            Marker = new MarkerModel()
            {
                Type         = 1,
                Dimension    = 0,
                PosX         = DbModel.PosX,
                PosY         = DbModel.PosY,
                PosZ         = DbModel.PosZ - 0.9f,
                DirX         = 0,
                DirY         = 0,
                DirZ         = 0,
                RotX         = 0,
                RotY         = 0,
                RotZ         = 0,
                ScaleX       = 1f,
                ScaleY       = 1f,
                ScaleZ       = 1f,
                Red          = 0,
                Green        = 153,
                Blue         = 0,
                Alpha        = 100,
                BobUpAndDown = false,
                FaceCamera   = false,
                P19          = 2,
                Rotate       = false,
                TextureDict  = null,
                TextureName  = null,
                DrawOnEnts   = false,
                UniqueID     = $"WAREHOUSE_MARKER{DbModel.Id}"
            };

            // Do testów później nie będzie
            AltAsync.Do(async() =>
            {
                await MarkerHelper.CreateGlobalMarker(Marker);
            });

            EntityHelper.Add(this);
        }
        public void Login(Guid webApiToken)
        {
            Client.SetData("RP_ACCOUNT", this);

            DbModel.LastLogin = DateTime.Now;

            Client.SendInfo(
                $"Witaj, {DbModel.Name} zostałeś pomyślnie zalogowany. Ostatnie logowanie:" +
                $" {DbModel.LastLogin.ToShortDateString()} {DbModel.LastLogin.ToShortTimeString()} ");

            EntityHelper.Add(this);

            WebApiToken = webApiToken;

            // calling static event telling that player logged in
            AccountLoggedIn?.Invoke(Client, this);
        }
Beispiel #10
0
        public void CreateAtm(Client sender)
        {
            if (!sender.HasRank(ServerRank.AdministratorRozgrywki2))
            {
                sender.SendWarning("Nie posiadasz uprawnień do dodawania bankomatu.");
                return;
            }

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

            void Handler(Client o, string message)
            {
                if (o == sender && message == "tu")
                {
                    AtmModel data = new AtmModel
                    {
                        CreatorForumName = o.GetAccountEntity().DbModel.Name,
                        Position         = new FullPosition
                        {
                            Position = new Vector3
                            {
                                X = o.Position.X,
                                Y = o.Position.Y,
                                Z = o.Position.Z
                            },

                            Rotation = new Vector3
                            {
                                X = o.Rotation.X,
                                Y = o.Rotation.Y,
                                Z = o.Rotation.Z
                            }
                        }
                    };
                    XmlHelper.AddXmlObject(data, Path.Combine(Utils.XmlDirectory, nameof(AtmModel)));
                    AtmEntity atm = new AtmEntity(data);
                    atm.Spawn();
                    EntityHelper.Add(atm);
                    sender.SendInfo("Dodawanie bankomatu zakończyło się pomyślnie.");
                }
            }
        }
Beispiel #11
0
        public TEntity Create(TEntity newEntity, TEntityDetail[] details, Dictionary <long, long[]> taxonomyTypeIdTaxonomyIds = null, User user = null)
        {
            newEntity.Name = EntityHelper.GenerateEntityName(newEntity.Name);

            var entity = EntityHelper.Add(newEntity, user);

            if (details != null)
            {
                EntityHelper.CreateDetails(entity, details, user);
            }

            if (taxonomyTypeIdTaxonomyIds != null)
            {
                TaxonomyHelper.UpdateTaxonomiesForEntity <TEntityTaxonomy>(entity.Id, newEntity.EntityTypeId ?? 0, taxonomyTypeIdTaxonomyIds);
            }

            Save();

            return(entity);
        }
Beispiel #12
0
 public void Spawn()
 {
     Colshape = Alt.CreateColShapeCylinder(new Position(JobCenterModel.Position.X, JobCenterModel.Position.Y, JobCenterModel.Position.Z - 0.9f), 1f, 2f);
     Marker   = new MarkerModel()
     {
         Type         = 1,
         Dimension    = 0,
         PosX         = JobCenterModel.Position.X,
         PosY         = JobCenterModel.Position.Y,
         PosZ         = JobCenterModel.Position.Z - 0.9f,
         DirX         = 0,
         DirY         = 0,
         DirZ         = 0,
         RotX         = 0,
         RotY         = 0,
         RotZ         = 0,
         ScaleX       = 1f,
         ScaleY       = 1f,
         ScaleZ       = 1f,
         Red          = 0,
         Green        = 153,
         Blue         = 0,
         Alpha        = 100,
         BobUpAndDown = false,
         FaceCamera   = false,
         P19          = 2,
         Rotate       = false,
         TextureDict  = null,
         TextureName  = null,
         DrawOnEnts   = false,
         UniqueID     = $"JOB_CENTER_MARKER{JobCenterModel.Id}"
     };
     // TODO: Stworzenie PEDa
     Colshape.SetData("job-center:data", this);
     EntityHelper.Add(this);
 }
Beispiel #13
0
        public virtual void Drop(CharacterEntity characterEntity)
        {
            if (DbModel.ItemInUse)
            {
                return;
            }

            if (DbModel.CharacterId == null)
            {
                return;
            }

            DbModel.CharacterId = null;
            ItemInWorldModel itemInWorld = new ItemInWorldModel()
            {
                ItemEntity = this,
                Position   = characterEntity.AccountEntity.Player.Position,
                Dimension  = characterEntity.AccountEntity.Player.Dimension
            };

            EntityHelper.Add(itemInWorld);

            // Wykonanie animacji + stworzenie obiektu + dxText
        }
Beispiel #14
0
        public void Create()
        {
            EntityHelper.Add(this);

            Save();
        }
Beispiel #15
0
        public override void Spawn()
        {
            GameVehicle = NAPI.Vehicle.CreateVehicle(NAPI.Util.VehicleNameToModel(DbModel.VehicleHash),
                                                     new Vector3(DbModel.SpawnPositionX, DbModel.SpawnPositionY, DbModel.SpawnPositionZ),
                                                     DbModel.SpawnPositionX, DbModel.PrimaryColor.ToColor(),
                                                     DbModel.SecondaryColor.ToColor(),
                                                     DbModel.NumberPlate, 255, true);
            GameVehicle.Rotation = new Vector3(DbModel.SpawnRotationX,
                                               DbModel.SpawnRotationY,
                                               DbModel.SpawnRotationZ);
            GameVehicle.NumberPlateStyle       = DbModel.NumberPlateStyle;
            GameVehicle.EnginePowerMultiplier  = DbModel.EnginePowerMultiplier;
            GameVehicle.EngineTorqueMultiplier = DbModel.EngineTorqueMultiplier;
            GameVehicle.WheelType    = DbModel.WheelType;
            GameVehicle.WheelColor   = DbModel.WheelColor;
            GameVehicle.EngineStatus = false;
            DbModel.IsSpawned        = true;
            NAPI.Vehicle.BreakVehicleDoor(GameVehicle, 1, DbModel.Door1Damage);
            NAPI.Vehicle.BreakVehicleDoor(GameVehicle, 2, DbModel.Door2Damage);
            NAPI.Vehicle.BreakVehicleDoor(GameVehicle, 3, DbModel.Door3Damage);
            NAPI.Vehicle.BreakVehicleDoor(GameVehicle, 4, DbModel.Door4Damage);
            NAPI.Vehicle.BreakVehicleWindow(GameVehicle, 1, DbModel.Window1Damage);
            NAPI.Vehicle.BreakVehicleWindow(GameVehicle, 2, DbModel.Window2Damage);
            NAPI.Vehicle.BreakVehicleWindow(GameVehicle, 3, DbModel.Window3Damage);
            NAPI.Vehicle.BreakVehicleWindow(GameVehicle, 4, DbModel.Window4Damage);

            //Dodajemy tuning do pojazdu
            float engineMultipier = 0f;
            float torqueMultipier = 0f;

            foreach (ItemModel tuning in DbModel.ItemsInVehicle)
            {
                if (tuning.ItemEntityType == ItemEntityType.Tuning && tuning.FourthParameter.HasValue)
                {
                    if (tuning.FirstParameter != null && (TuningType)tuning.FirstParameter == TuningType.Speed)
                    {
                        if (tuning.SecondParameter != null)
                        {
                            engineMultipier += (float)tuning.SecondParameter;
                        }
                        if (tuning.ThirdParameter != null)
                        {
                            torqueMultipier += (float)tuning.ThirdParameter;
                        }
                    }
                }
            }

            //Te metody działają tak, że ujemny mnożnik zmniejsza | 0 to normalnie | a dodatni poprawia
            //Pola są potrzebne, ponieważ w salonie będą dostępne 3 wersje pojazdu
            //TODO: tańsza o 10% zmniejszone osiągi o -5f
            //TODO: normalna
            //TODO: droższa o 25% zwiększone osiągi o 5f
            NAPI.Vehicle.SetVehicleEnginePowerMultiplier(GameVehicle, engineMultipier);
            NAPI.Vehicle.SetVehicleEngineTorqueMultiplier(GameVehicle, torqueMultipier);

            //NAPI.Data.SetEntitySharedData(GameVehicle.Handle, "_maxfuel", DbModel.Fuel);
            //NAPI.Data.SetEntitySharedData(GameVehicle.Handle, "_fuel", DbModel.Fuel);
            //NAPI.Data.SetEntitySharedData(GameVehicle.Handle, "_fuelConsumption", DbModel.FuelConsumption);
            //NAPI.Data.SetEntitySharedData(GameVehicle.Handle, "_milage", DbModel.Milage);
            GameVehicle.SetData("VehicleEntity", this);
            GameVehicle.SetSharedData("Id", DbModel.Id);
            GameVehicle.SetSharedData("milage", DbModel.Milage);
            GameVehicle.SetSharedData("fuel", DbModel.Fuel);
            GameVehicle.SetSharedData("fuelConsumption", DbModel.FuelConsumption);
            GameVehicle.SetSharedData("maxFuel", DbModel.FuelTank);
            EntityHelper.Add(this);
            Save();
        }
Beispiel #16
0
        public async Task Spawn()
        {
            InteriorColshape           = Alt.CreateColShapeCylinder(new Position(DbModel.InternalPickupPositionX, DbModel.InternalPickupPositionY, DbModel.InternalPickupPositionZ - 0.9f), 1f, 2f);
            ExteriorColshape           = Alt.CreateColShapeCylinder(new Position(DbModel.ExternalPickupPositionX, DbModel.ExternalPickupPositionY, DbModel.ExternalPickupPositionZ - 0.9f), 1f, 2f);
            ExteriorColshape.Dimension = DbModel.Id;

            InteriorMarker = new MarkerModel()
            {
                Type         = 1,
                Dimension    = 0,
                PosX         = DbModel.InternalPickupPositionX,
                PosY         = DbModel.InternalPickupPositionY,
                PosZ         = DbModel.InternalPickupPositionZ - 0.9f,
                DirX         = 0,
                DirY         = 0,
                DirZ         = 0,
                RotX         = 0,
                RotY         = 0,
                RotZ         = 0,
                ScaleX       = 1f,
                ScaleY       = 1f,
                ScaleZ       = 1f,
                Red          = 0,
                Green        = 153,
                Blue         = 0,
                Alpha        = 100,
                BobUpAndDown = false,
                FaceCamera   = false,
                P19          = 2,
                Rotate       = false,
                TextureDict  = null,
                TextureName  = null,
                DrawOnEnts   = false,
                UniqueID     = $"BUILDING_MARKER{DbModel.Id}"
            };

            ExteriorMarker = new MarkerModel()
            {
                Type         = 1,
                Dimension    = DbModel.Id,
                PosX         = DbModel.ExternalPickupPositionX,
                PosY         = DbModel.ExternalPickupPositionY,
                PosZ         = DbModel.ExternalPickupPositionZ - 0.9f,
                DirX         = 0,
                DirY         = 0,
                DirZ         = 0,
                RotX         = 0,
                RotY         = 0,
                RotZ         = 0,
                ScaleX       = 1f,
                ScaleY       = 1f,
                ScaleZ       = 1f,
                Red          = 0,
                Green        = 153,
                Blue         = 0,
                Alpha        = 100,
                BobUpAndDown = false,
                FaceCamera   = false,
                P19          = 2,
                Rotate       = false,
                TextureDict  = null,
                TextureName  = null,
                DrawOnEnts   = false,
                UniqueID     = $"BUILDING_MARKER{DbModel.Id}"
            };

            await MarkerHelper.CreateGlobalMarker(InteriorMarker);

            await MarkerHelper.CreateGlobalMarker(ExteriorMarker);

            // Później to zmienić i dodać do bazy może, ale to się zobaczy
            if (DbModel.BuildingType == BuildingType.Apartament)
            {
                BlipVisable = false;
            }


            if (BlipVisable)
            {
                string blipName = BuildingFactory.CreateName(DbModel.BuildingType);
                int    blip     = BuildingFactory.CreateBlip(DbModel.BuildingType, DbModel.OnSale);
                int    color    = BuildingFactory.CreateColor(DbModel.OnSale, DbModel.BuildingType);
                Blip = new BlipModel()
                {
                    PosX       = DbModel.InternalPickupPositionX,
                    PosY       = DbModel.InternalPickupPositionY,
                    PosZ       = DbModel.InternalPickupPositionZ + 1,
                    Blip       = blip,
                    Color      = color, // Kolor pózniej do zmiany jak budynek będzie kupiony
                    Size       = EBlipSize.Medium,
                    Name       = blipName,
                    ShortRange = true,
                    UniqueID   = $"BUILDING{DbModel.Id}"
                };
                Alt.Log("Tworze blipa z budynkiem");
                await BlipHelper.CreateGlobalBlip(Blip);
            }
            EntityHelper.Add(this);
            InteriorColshape.SetData("building:data", this);
            ExteriorColshape.SetData("building:data", this);
        }
 public BuildingEntity(BuildingModel dbModel)
 {
     DbModel = dbModel;
     EntityHelper.Add(this);
 }
 public static void CreateGlobalDrawText(DrawTextModel drawTextModel)
 {
     EntityHelper.Add(drawTextModel);
     Alt.EmitAllClients("drawText:create", drawTextModel);
 }
Beispiel #19
0
 protected GroupEntity(GroupModel dbModel)
 {
     DbModel = dbModel;
     EntityHelper.Add(this);
 }
Beispiel #20
0
 public void Spawn()
 {
     EntityHelper.Add(this);
 }