enisn 3 Posted December 26, 2020 Share Posted December 26, 2020 (edited) AttachEntityToEntity - GTA Network Wiki NAPI.Entity.AttachEntityToEntity(...) Method doesn't exist in v1.1, How can I attach entities at v1.1? Edited December 26, 2020 by enisn Link to post Share on other sites
Xabi 214 Posted December 27, 2020 Share Posted December 27, 2020 You have to do it clientside. Link to post Share on other sites
enisn 3 Posted December 27, 2020 Author Share Posted December 27, 2020 (edited) Will attached object position be synced? Edited December 27, 2020 by enisn Link to post Share on other sites
trolovecro 7 Posted December 27, 2020 Share Posted December 27, 2020 If you used it in client side only, it will not be synced. 1 Link to post Share on other sites
enisn 3 Posted December 28, 2020 Author Share Posted December 28, 2020 Doesn't work. Nothing happens when attached at client-side, It doesn't throw an exception too. Object stays first spawned position. Link to post Share on other sites
Xabi 214 Posted December 29, 2020 Share Posted December 29, 2020 14 hours ago, enisn said: Doesn't work. Nothing happens when attached at client-side, It doesn't throw an exception too. Object stays first spawned position. You need to wait for object to be streamed before attaching it. Created objects have a property called 'notifyStreaming' that you can set to true, that way, the object will call the 'entityStreamIn' event when it's created. 1 Link to post Share on other sites
enisn 3 Posted December 29, 2020 Author Share Posted December 29, 2020 I've tried but I'm not sure if I write code properly, So, I've tried following script which it says working on v1.1 but it doesn't work and treat same. Object stayed at same position. Efficient Attachment Sync - Libraries - RAGE Multiplayer Community But I'll try to use `notifyStreaming` property and handle `entityStreamIn` event. Link to post Share on other sites
Shourya90 0 Posted January 10 Share Posted January 10 same problem... Link to post Share on other sites
Machiavelli 13 Posted Monday at 05:37 PM Share Posted Monday at 05:37 PM @enisn @Shourya90try to replace the AttachObject function in EntityAttachmentService.cs with this: private async 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, RAGE.Elements.Player.LocalPlayer.Position, new Vector3(0, 0, 0)); var gameEntity = entity.GetGameEntity(); Events.OnEntityStreamInDelegate handler = null; handler = (entity) => { if (entity != mapObject) return; 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); Events.OnEntityStreamIn -= handler; }; Events.OnEntityStreamIn += handler; mapObject.NotifyStreaming = true; if (Entity.IsEntityAttachedToEntity(mapObject.Handle, gameEntity.Handle)) { OnEntityAttachedEvent?.Invoke(gameEntity, entityAttachment.AttachmentEvent); } entityObjects.Add(key, mapObject); entity.SetData("Objects", entityObjects); } } Link to post Share on other sites
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now