mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

New events - onElementAttach/onElementDetach

Open Allerek opened this issue 2 years ago • 9 comments

Is your feature request related to a problem? Please describe.

Currently we have no event to tell if element has ben attached/detached to any other element

Describe the solution you'd like

Two events

onElementAttach \ onElementDetach

Params: element to which source has been attached Vector 3 with global position of element after attaching Vector3 with offset of attachment Vector3 with rotation offset of attachment

(we may want vectors with detach as some people might want to keep rotation and position of element after for example deatching)

Describe alternatives you've considered

No response

Additional context

No response

Security Policy

  • [X] I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.

Allerek avatar Dec 17 '23 23:12 Allerek

Also add onClientElementAttach and onClientElementDetach right?

Fernando-A-Rocha avatar Dec 18 '23 00:12 Fernando-A-Rocha

Also add onClientElementAttach and onClientElementDetach right?

Yeah, sure, its pretty straightforward

Allerek avatar Dec 18 '23 00:12 Allerek

I wanted to extend my sincere thanks for your idea shared on GitHub! With your inspiration, I've created a pull request that implements the concept you've proposed. I hope you'll continue to share your ideas and feedback for future developments.

Thank you, and I look forward to hearing more of your ideas! #3353

Best regards, Nico

Nico8345 avatar Mar 30 '24 18:03 Nico8345

What is the purpose of those events? Could you give an example of how to use it?

TheNormalnij avatar Mar 31 '24 15:03 TheNormalnij

What is the purpose of those events? Could you give an example of how to use it?

You have a box attached to sadler. You want to detach it and drop it right behind the vehicle, keeping its rotation - you can do so using this.

Allerek avatar Apr 02 '24 21:04 Allerek

You have a box attached to sadler. You want to detach it and drop it right behind the vehicle, keeping its rotation - you can do so using this.

By the way, I also fixed the rotation bug in this PR, now the rotation remains even after detach.

Nico8345 avatar Apr 02 '24 21:04 Nico8345

You have a box attached to sadler. You want to detach it and drop it right behind the vehicle, keeping its rotation - you can do so using this.

It doesn't look like a valid usage example. In this case, you should call a function that does deattach and handles next object position. There is no reason for spaghetti code.

TheNormalnij avatar Apr 03 '24 15:04 TheNormalnij

You have a box attached to sadler. You want to detach it and drop it right behind the vehicle, keeping its rotation - you can do so using this.

It doesn't look like a valid usage example. In this case, you should call a function that does deattach and handles next object position. There is no reason for spaghetti code.

This would work only if you write the code yourself, and not use open-source resources from the web. This allows integration between resources coming from different developers without using exports.

Allerek avatar Apr 03 '24 18:04 Allerek

Recently, someone uploaded a resource, which can be used to improve the prelight of attached objects using a shader, for example these event would be very useful for that, so you don't need to export it from a util resource, just use the new built-in events.

Nico8345 avatar Apr 03 '24 19:04 Nico8345