Skip to content
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

Update vehicles.lua #592

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

Update vehicles.lua #592

wants to merge 2 commits into from

Conversation

i-kulgu
Copy link

@i-kulgu i-kulgu commented Oct 27, 2024

Fix spaces in GetVehicleNumberPlateText

Description

This fixes an issue with trunks.
When fetching with GetVehicleNumberPlateText it adds a space when the plate is shorter then 8 characters:

image

Added gsub to trim whitespaces out and the outcome is without spaces:

image

This will fix issues when adding items to trunk where it can't match the plate numbers because the actual plate is without spaces.

Checklist

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

Fix spaces in GetVehicleNumberPlateText
@Qwerty1Verified
Copy link
Contributor

Qwerty1Verified commented Nov 8, 2024

Can you give me reproducible steps to reproduce the issue you're referencing? I do see that whitespace padding is added, but it doesn't hinder basic functionality. I'd like to take a look at where the issue is occurring.

I also see this being an issue elsewhere like garages, which would mean modifying it to handle trimming in those cases, similar to this PR.

@i-kulgu
Copy link
Author

i-kulgu commented Nov 9, 2024

You can reproduce it by following steps:

  1. Create a stash with the plate number like stash-HD3333 in db or from inventory script.
  2. Put items in the stash
  3. Get the car with that plate number
  4. Open the trunk and you won't see the items

Thats because it's trying to match stash- HD3333 with stash-HD3333 and thats never gonna be true so it won't show you the items.

@Qwerty1Verified
Copy link
Contributor

Yeah I think this is mainly an issue in cases where you're trying to add an item or get the stash. I checked the database, and it's not just the whitespace at the beginning it's also at the end which can cause more problems than expected in this case.

If there's concerns about backwards compatibility with pre-existing custom plate stashes we can just sanitise on the way back from the database.

@GhzGarage GhzGarage self-assigned this Nov 13, 2024
@GhzGarage GhzGarage added bug Something isn't working help wanted Extra attention is needed labels Nov 13, 2024
@@ -36,7 +36,7 @@ QBCore.Functions.CreateClientCallback('qb-inventory:client:vehicleCheck', functi
if inVehicle ~= 0 then
local plate = GetVehicleNumberPlateText(inVehicle)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try replacing this native with QBCore.Functions.GetPlate

@@ -53,7 +53,7 @@ QBCore.Functions.CreateClientCallback('qb-inventory:client:vehicleCheck', functi
OpenTrunk(vehicle)
local class = GetVehicleClass(vehicle)
local plate = GetVehicleNumberPlateText(vehicle)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try replacing this native with QBCore.Functions.GetPlate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants