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

Hidden default vehicle components are being redisplayed when changing handling/variant/parts states(fix)

Open C0DELEVEL opened this issue 1 year ago • 7 comments

Describe the bug

Hey,

if we hide one of the default vehicle components, e.g., bump_rear_dummy, using the setVehicleComponentVisible function and then change the vehicle's variant, modify its handling value, or fix the vehicle (fixVehicle), all default components ignore the fact that they were hidden using setVehicleComponentVisible and are displayed again.

This becomes a significant challenge when using the component system for vehicle tuning, especially if we want to implement it optimally without sending unnecessary data between the server and frequently analyzing and updating the current components status.

As for proposed solutions to address this issue, I see two options:

  1. Add client-side awareness of hidden components for a given vehicle so that they remain hidden during vehicle reinitialization. This would prevent them from being displayed again after events like handling changes, variant switches, or fixes.
  2. Introduce a new event, e.g., onVehicleInitialized or onVehicleReinitialized, which would allow us to reapply the appropriate visibility settings for components whenever the vehicle is reinitialized due to the aforementioned reasons.

Steps to reproduce

  1. Create vehicle
  2. Hide one of default components, eg.: setVehicleComponentVisible(veh,'bump_rear_dummy',false)
  3. Switch variant or change handling or fixVehicle, eg.: setVehicleVariant(veh,1,1)
  4. That's it! You will see the bump_rear_dummy component visible again

Version

latest, not relevant

Additional context

No response

Relevant log output


Security Policy

  • [x] I have read and understood the Security Policy and this issue is not security related.

C0DELEVEL avatar Dec 15 '24 15:12 C0DELEVEL

This seems similar to #1556 .

FileEX avatar Dec 15 '24 16:12 FileEX

It's easy to fix, but is it necessary, why do we need car variants?

G-Moris avatar Dec 29 '24 18:12 G-Moris

It's easy to fix, but is it necessary, why do we need car variants?

Customization (and also because a lot of vehicles have them and its nice to be able to choose which variants you want)

Image

PlatinMTA avatar Dec 29 '24 18:12 PlatinMTA

Customization (and also because a lot of vehicles have them and its nice to be able to choose which variants you want)

Perhaps it is worth making a parameter so that there would be no reloading of hidden components? I can implement it if it's really necessary.

Upd: But it seems to me that the function was not created for this

G-Moris avatar Dec 29 '24 18:12 G-Moris

@C0DELEVEL If you want to save a variant of the machine for values, then use element data to save your variant.

G-Moris avatar Dec 29 '24 19:12 G-Moris

@C0DELEVEL If you want to save a variant of the machine for values, then use element data to save your variant.

It seems you might not fully understand the issue. This is about components (not variants), which are separate entities. If you need more details or a clearer description to help resolve the problem, feel free to reach out to me on Discord (xskyex_)

C0DELEVEL avatar Dec 29 '24 19:12 C0DELEVEL

@C0DELEVEL Did you solve the problem? If yes, can I know how you did it?

0morgus avatar Apr 22 '25 12:04 0morgus