Skip to content

Commit

Permalink
refactor: nil check for GetVehicleNumberPlateText (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
solareon committed Jan 22, 2024
1 parent c5d6575 commit bcf9539
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ end

---Returns the number plate of the given vehicle.
---@param vehicle integer
---@return string
---@return string?
function qbx.getVehiclePlate(vehicle)
return qbx.string.trim(GetVehicleNumberPlateText(vehicle))
local plate = GetVehicleNumberPlateText(vehicle)
if not plate then return end
return qbx.string.trim(plate)
end

---Generates and returns a random number plate with the given pattern.
Expand Down

0 comments on commit bcf9539

Please sign in to comment.