Skip to content

Improve VehicleInfo Event Handling #1192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

DispersiaRoleplay
Copy link
Contributor

Improve VehicleInfo Event Handling with Fallbacks and Optional Key Check

Description:
This PR enhances the QBCore:Client:VehicleInfo event logic for improved compatibility and error safety: Added fallback method to retrieve the vehicle plate using QBCore.Functions.GetPlate() if not directly passed; Added support for checking if the player has vehicle keys only when qb-vehiclekeys is active; Defaulted hasKeys to true to avoid issues when the key system is not used; Cleaned up the logic for packaging and passing vehicle information.

These changes make the system more robust and prevent crashes on servers not using qb-vehiclekeys.

  • [yes] I have personally loaded this code into an updated qbcore project and checked all of its functionality.
  • [yes] My code fits the style guidelines.
  • [yes] My PR fits the contribution guidelines.

Improve VehicleInfo Event Handling with Fallbacks and Optional Key Check

Description:
This PR enhances the QBCore:Client:VehicleInfo event logic for improved compatibility and error safety:
Added fallback method to retrieve the vehicle plate using QBCore.Functions.GetPlate() if not directly passed;
Added support for checking if the player has vehicle keys only when qb-vehiclekeys is active;
Defaulted hasKeys to true to avoid issues when the key system is not used;
Cleaned up the logic for packaging and passing vehicle information.

These changes make the system more robust and prevent crashes on servers not using qb-vehiclekeys.
@Qwerty1Verified
Copy link
Member

Hello, thank you for your PR submission.

Currently in the codebase, plate is never passed through the info table, which makes that specific code somewhat redundant. I think I'd also prefer to send the event regardless of whether the plate is present since I'm not sure what the edge cases are there, and where that'd be preventing data from being sent.

The code does require a plate for the key check, but for that we could avoid the check if a plate isn't present, similar to how the check is avoided if qb-vehiclekeys isn't running.

Vehiclekeys starting after qb-core, added GetResourceState == starting
added GetResourceState == starting, because qb-vehiclekeys starting after qb-core
added GetResourceState == starting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants