enisn Posted December 26, 2020 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
enisn Posted December 27, 2020 Author Posted December 27, 2020 (edited) Will attached object position be synced? Edited December 27, 2020 by enisn
trolovecro Posted December 27, 2020 Posted December 27, 2020 If you used it in client side only, it will not be synced. 1
enisn Posted December 28, 2020 Author 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.
Xabi Posted December 29, 2020 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
enisn Posted December 29, 2020 Author 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.
Machiavelli Posted January 11, 2021 Posted January 11, 2021 @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); } }
enisn Posted October 24, 2021 Author Posted October 24, 2021 On 1/11/2021 at 8:37 PM, Machiavelli said: @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); } } Can you explain more detailed? I've tried, but server-side generated objects can't be moved, because they're scyning at same position always, so player can't drag them. Another way, client-side generated objects are not synced. They stays only created client.
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