/// <summary>
        /// Get a HelpText by it's ID.
        /// </summary>
        /// <param name="dynamicTextLabelId">The ID of the textlabel.</param>
        /// <returns>The dynamic textlabel or null if not found.</returns>
        public static HelpText GetHelpText(ulong dynamicTextLabelId)
        {
            if (!AltEntitySync.TryGetEntity(dynamicTextLabelId, 4, out IEntity entity))
            {
                Console.WriteLine($"[OBJECT-STREAMER] [GetDynamicTextLabel] ERROR: Entity with ID { dynamicTextLabelId } couldn't be found.");
                return(null);
            }

            return((HelpText)entity);
        }
Example #2
0
        private IEntity GetGameEntity(long id, long type)
        {
            IEntity entity;

            if (!AltEntitySync.TryGetEntity((ulong)id, (ulong)type, out entity))
            {
                return(null);
            }

            return(entity);
        }
        /// <summary>
        /// Get a dynamic marker by it's ID.
        /// </summary>
        /// <param name="dynamicMarkerId">The ID of the marker.</param>
        /// <returns>The dynamic marker or null if not found.</returns>
        public static Marker GetMarker(ulong MarkerId)
        {
            if (!AltEntitySync.TryGetEntity(MarkerId, 0, out IEntity entity))
            {
                Console.WriteLine($"[MARKER-STREAMER] [GetDynamicMarker] ERROR: Entity with ID { MarkerId } couldn't be found.");
                return null;
            }

            if (!(entity is Marker))
                return null;

            return (Marker)entity;
        }
        private void OnGetFlameLevel(IPlayer player, ulong flameId)
        {
            if (!AltEntitySync.TryGetEntity(flameId, 992_002, out AltV.Net.EntitySync.IEntity entity))
            {
                return;
            }

            if (entity is not Flame flame)
            {
                return;
            }

            player.Emit("FireFighters:Debug:Log", $"Flame {flame.Id} has level {flame.Level}");
        }
        private void OnSetFlameLevel(IPlayer player, ulong flameId, uint level)
        {
            if (!AltEntitySync.TryGetEntity(flameId, 992_002, out AltV.Net.EntitySync.IEntity entity))
            {
                return;
            }

            if (entity is not Flame flame)
            {
                return;
            }

            flame.Level = level;
        }
Example #6
0
        /// <summary>
        /// Get a dynamic marker by it's ID.
        /// </summary>
        /// <param name="dynamicMarkerId">The ID of the marker.</param>
        /// <returns>The dynamic marker or null if not found.</returns>
        public static DynamicMarker GetDynamicMarker(ulong dynamicMarkerId)
        {
            if (!AltEntitySync.TryGetEntity(dynamicMarkerId, out IEntity entity))
            {
                Console.WriteLine($"[MARKER-STREAMER] [GetDynamicMarker] ERROR: Entity with ID { dynamicMarkerId } couldn't be found.");
                return(null);
            }

            if (!(entity is DynamicMarker))
            {
                return(null);
            }

            return(( DynamicMarker )entity);
        }
        private void OnClientFlameFoundPositionGround(IPlayer player, ulong entityId, float ground)
        {
            if (!AltEntitySync.TryGetEntity(entityId, (ulong)EntityTypes.Flame, out AltV.Net.EntitySync.IEntity entity))
            {
                return;
            }

            if (entity is not Flame flame)
            {
                return;
            }

            flame.Position = new Vector3(flame.Position.X, flame.Position.Y, ground);
            flame.IsPositionGroundValidated = true;
        }
        private void OnServerFireRemove(ulong fireId)
        {
            // Console.WriteLine($"Try to stop fire {fireId}");

            if (!AltEntitySync.TryGetEntity(fireId, (ulong)EntityTypes.Fire, out AltV.Net.EntitySync.IEntity entity))
            {
                return;
            }

            if (entity is not Fire fire)
            {
                return;
            }

            fire.MainFlame.Extinguished = true;

            // Console.WriteLine($"Fire {fireId} stopped");
        }
        private void OnClientFlameScriptFireExtinguished(IPlayer player, ulong entityId)
        {
            if (!AltEntitySync.TryGetEntity(entityId, (ulong)EntityTypes.Flame, out AltV.Net.EntitySync.IEntity entity))
            {
                return;
            }

            if (entity is not Flame flame)
            {
                return;
            }

            if (flame.Children.Any())
            {
                player.Emit("FireFighters:Flame:RespawnScriptFire", entityId);
                return;
            }

            flame.Extinguished = true;
        }
Example #10
0
        public void AddRepositoryTest()
        {
            var entity2 = new Entity(0, Vector3.Zero, 0, 2);

            AltEntitySync.AddEntity(entity2);
            if (AltEntitySync.TryGetEntity(entity2.Id, 0, out var foundEntity2))
            {
                Assert.AreSame(entity2, foundEntity2);
            }
            var entity = new Entity(1, Vector3.Zero, 0, 2);

            AltEntitySync.AddEntity(entity);
            if (AltEntitySync.TryGetEntity(entity.Id, 1, out var foundEntity))
            {
                Assert.AreSame(entity, foundEntity);
            }
            AltEntitySync.RemoveEntity(entity2);
            Assert.False(AltEntitySync.TryGetEntity(entity2.Id, 0, out _));
            AltEntitySync.RemoveEntity(entity);
            Assert.False(AltEntitySync.TryGetEntity(entity.Id, 1, out _));
        }
 public static Prop GetProp(ulong dynamicObjectId)
 {
     if (!AltEntitySync.TryGetEntity(dynamicObjectId, 2, out IEntity entity))
     {
         Console.WriteLine($"[Prop-Stream] [GetProp] ERROR: Entity with ID { dynamicObjectId } couldn't be found.");
         return(default);
Example #12
0
 /// <summary>
 /// Get a dynamic object by it's ID.
 /// </summary>
 /// <param name="dynamicObjectId">The ID of the object.</param>
 /// <returns>The dynamic object or null if not found.</returns>
 public static DynamicObject GetDynamicObject(ulong dynamicObjectId)
 {
     if (!AltEntitySync.TryGetEntity(dynamicObjectId, out IEntity entity))
     {
         Console.WriteLine($"[OBJECT-STREAMER] [GetDynamicObject] ERROR: Entity with ID { dynamicObjectId } couldn't be found.");
         return(default);