qbcore-framework / qb-garages

Garage System Used With QB-Core :car:
GNU General Public License v3.0
48 stars 260 forks source link

[BUG] Error when you store a motorcycle #314

Closed Skybrick closed 11 months ago

Skybrick commented 11 months ago

When you store a motorcycle, it gives an error on the client side F8 which is the following ‘Script Error: citizen:/scripting/lua/scheduler.lua:739: Script Error: @qb-garages/client/main-lua:189: bad argument #1 to ‘for iterator’ (table expected, got nil)’. While investigating, I discovered that the error comes from the fact that motorcycles do not have windows. The solution I made was the following

local function doCarDamage(currentVehicle, stats, props) local engine = stats.engine + 0.0 local body = stats.body + 0.0 if not next(props) then return end if IsPedOnAnyBike(PlayerPedId()) then for k, v in pairs(props.doorStatus) do if v then SetVehicleDoorBroken(currentVehicle, tonumber(k), true) end end for k, v in pairs(props.tireBurstState) do if v then SetVehicleTyreBurst(currentVehicle, tonumber(k), true) end end for k, v in pairs(props.windowStatus) do if not v then SmashVehicleWindow(currentVehicle, tonumber(k)) end end end SetVehicleEngineHealth(currentVehicle, engine) SetVehicleBodyHealth(currentVehicle, body) end

I would like you to check and give an official fix, thank you

GhzGarage commented 11 months ago

https://github.com/qbcore-framework/qb-garages/commit/bfd040cb010415b609276f25663ea5273a71b62d