From e15503e04ba17f2752c3e0e5f5280f9a925f8fdc Mon Sep 17 00:00:00 2001 From: roobr Date: Sat, 6 Nov 2021 00:03:27 +1100 Subject: [PATCH] Add in Shared function for Trimming whitespace in plates This PR is the foundation for Trimming plates in all resources that reference vehicle plates, this will allow plates with less than 8 Characters to work with QB resources (mechanic and garage mainly), and not return white spaces. For example, the plate "TEST" would return " TEST " so when trying to put it back into the garage or add mods to it, it would fail. For example in qb-garages: TriggerEvent("vehiclekeys:client:SetOwner", QBCore.Functions.GetPlate(veh)) would return "TEST instead of " TEST " when using the native. What I did was replace GetVehicleNumberPlateText( with QBCore.Functions.GetPlate( in all resources that contain the QBCore object. --- client/functions.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/functions.lua b/client/functions.lua index f217a62..70bd678 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -315,6 +315,11 @@ function QBCore.Functions.DeleteVehicle(vehicle) DeleteVehicle(vehicle) end +function QBCore.Functions.GetPlate(vehicle) + if vehicle == 0 then return end + return Trim(GetVehicleNumberPlateText(vehicle)) +end + function QBCore.Functions.GetVehicleProperties(vehicle) if DoesEntityExist(vehicle) then local colorPrimary, colorSecondary = GetVehicleColours(vehicle) @@ -628,4 +633,4 @@ function QBCore.Functions.SetVehicleProperties(vehicle, props) SetVehicleLivery(vehicle, props.modLivery) end end -end \ No newline at end of file +end