Qbox-project / qbx_vehiclekeys

GNU General Public License v3.0
4 stars 31 forks source link

Motorcycles and bicycles taken out of the garage are unable to be unlocked. #114

Open andreutu opened 2 weeks ago

andreutu commented 2 weeks ago

Summary

Bikes cannot be unlocked when they are taken out of a garage.

Reproduction

  1. Own a motorcycle / bicycle (if not, buy one from a dealership, then store it).
  2. Take it out of a garage.

NOTE: In qbx_garages, the config option doorsLocked must be set to true.

Expected behavior

The vehicle should be unlocked upon taken out, while other vehicles, like cars, for example, should be locked, considering doorsLocked is true in qbx_garage's config.

Actual behavior

The motorcycle/bicycle is locked. The owner can't get in the vehicle, and it can't be unlocked due to qbx_vehiclekeys preventing bikes to lock/unlock.

Additional context

I have tried to open a pull request for qbx_garages that adds a config option for vehicle classes that won't be locked upon taken out, but I have been informed that this is not a needed feature. I will link this PR down below.

https://github.com/Qbox-project/qbx_garages/pull/121

Current Version

v1.0.0, latest commit: 91778f2

Custom Resources

None that interfere with this.

Manason commented 2 weeks ago

So the root of the issue is a conflict between qbx_vehiclekeys and qbx_garages. qbx_garages uses the native to lock vehicles by default, assuming that all vehicles should have locks. However qbx_vehiclekeys makes some vehicles not have a lock like bikes.

qbx_garages seems wrong to blindly lock any vehicle being spawned. qbx_vehiclekeys is the source of truth on which vehicles have locks and which do not. Some possible solutions:

  1. modify qbx_garages to add a dependency on qbx_vehiclekeys, and do the locking through API call which will exempt the same vehicles that qbx_vehiclekeys exempts
  2. remove the feature from qbx_garages altogether; instead trigger an event that qbx_vehiclekeys can consume to lock the vehicle, putting business logic of what to do when a vehicle is spawned from a garage on qbx_vehiclekeys.

The choice here comes down to whether garages should depend on vehiclekeys or whether vehiclekeys should depend on garages. I lean towards number 1 as it is the same solution we used in core.

ArturMichalak commented 2 weeks ago

I can additionally add a workaround to qbx_vehiclekeys, which allows you to unlock vehicles that are always unlocked in the configuration

Manason commented 2 weeks ago

I can additionally add a workaround to qbx_vehiclekeys, which allows you to unlock vehicles that are always unlocked in the configuration

While that would help, this bug still exists where vehicles that aren't supposed to have locks spawned locked because a different resource is doing so bypassing qbx_vehiclekeys. I think the best thing to do is to update qbx_garages to check if qbx_vehiclekeys is running and if so, to call it to lock rather than native.