Jump to content

How to fix the C# Attachment Sync resource on 1.1?


Recommended Posts

Hi, I've downloaded the C# 1.1 Attachment Sync but it doesn't work for me as I don't see the object on myself nor on other players when I/they try the /soda command. mapObject returns the correct .Model number, but on using .Exists it returns false.

Console logs server:
[COMMAND] Machiavelli: /soda
current attachments: 337428855

Clientside Changes:

     private void EntityStreamIn(RAGE.Elements.Entity entity)
            var attachments = entity.GetData<List<uint>>("Attachments");

            if (attachments != null)
                foreach (var key in attachments)
                    AttachObject(entity, key);

private void AttachObject(RAGE.Elements.Entity entity, uint key)
            var entityObjects = entity.GetData<Dictionary<uint, MapObject>>("Objects");
            if (AttachmentDictionary.ContainsKey(key) && !entityObjects.ContainsKey(key))
                var entityAttachment = AttachmentDictionary[key];
                var mapObject = new MapObject(entityAttachment.Model, new Vector3(0, 0, 0), new Vector3(0, 0, 0))
                { Dimension = uint.MaxValue };
                mapObject.NotifyStreaming = true; // <----------------------------------------- added
                Chat.Output("attach model: " + entityAttachment.Model); //result: attach model: 114933932  --> (same result for mapObject.Model)

                var gameEntity = entity.GetGameEntity();

                Entity.AttachEntityToEntity(mapObject.Handle, gameEntity.Handle, RAGE.Game.Ped.GetPedBoneIndex(gameEntity.Handle, entityAttachment.BoneId),
                    entityAttachment.Offset.X, entityAttachment.Offset.Y, entityAttachment.Offset.Z,
                    entityAttachment.Rotation.X, entityAttachment.Rotation.Y, entityAttachment.Rotation.Z,
                    false, false, false, false, 2, true);

                if (Entity.IsEntityAttachedToEntity(mapObject.Handle, gameEntity.Handle))
                    OnEntityAttachedEvent?.Invoke(gameEntity, entityAttachment.AttachmentEvent);

                entityObjects.Add(key, mapObject);
                entity.SetData("Objects", entityObjects);

Can anybody tell me what exactly I need to change and where I have to change it?  Like, how do you check if it's streamed/loaded in or not? Might have to change more code in the other files too.

Link to comment
Share on other sites

As an option: When an object enters the stream zone, you create the object and put it in list / dictionary / queue. In "Events.Tick" you check list / dictionary / queue for the presence of values, if any, then attach the object. I couldn't think of a better solution. Sorry for my English

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...