Skip to content

Commit

Permalink
fix: save vehicle props on vehicle storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason committed Apr 29, 2024
1 parent a46f9b3 commit 9f855af
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 35 deletions.
32 changes: 0 additions & 32 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,36 +53,6 @@ local function isOfType(category, vehicle)
return classSet[GetVehicleClass(vehicle)] == true
end

---@param currentVehicle number
---@param vehicle table
local function doCarDamage(currentVehicle, vehicle)
local engine = vehicle.engine + 0.0
local body = vehicle.body + 0.0
local data = json.decode(vehicle.mods)

if config.visuallyDamageCars then
for k, v in pairs(data.doors) do
if v then
SetVehicleDoorBroken(currentVehicle, k, true)
end
end
for k, v in pairs(data.tyres) do
if v then
local random = math.random(1, 1000)
SetVehicleTyreBurst(currentVehicle, k, true, random)
end
end
for k, v in pairs(data.windows) do
if not v then
SmashVehicleWindow(currentVehicle, k)
end
end
end

SetVehicleEngineHealth(currentVehicle, engine)
SetVehicleBodyHealth(currentVehicle, body)
end

---@param vehicle number
local function checkPlayers(vehicle)
for i = -1, 5, 1 do
Expand Down Expand Up @@ -255,8 +225,6 @@ RegisterNetEvent('qb-garages:client:takeOutGarage', function(data)
return
end

SetVehicleFuelLevel(veh, data.vehicle.fuel)
doCarDamage(veh, data.vehicle)
TriggerServerEvent('qb-garage:server:updateVehicleState', VehicleState.OUT, data.vehicle.plate, data.garageName)

if not sharedConfig.takeOut.engineOff then
Expand Down
1 change: 0 additions & 1 deletion config/client.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
return {
useTarget = false,
debugPoly = false,
visuallyDamageCars = true, -- True == Visually damage cars that go out of the garage depending of body damage, false == Do not visually damage cars (damage is still applied to car values)
}
7 changes: 5 additions & 2 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ lib.callback.register('qb-garage:server:spawnvehicle', function (source, vehInfo

local veh = NetworkGetEntityFromNetworkId(netId)

SetVehicleNumberPlateText(veh, vehInfo.plate)

if sharedConfig.takeOut.doorsLocked then
SetVehicleDoorsLocked(veh, 2)
end
Expand All @@ -104,6 +102,11 @@ lib.callback.register('qb-garage:server:IsSpawnOk', function(_, plate, type)
return true
end)

RegisterNetEvent('qb-vehicletuning:server:SaveVehicleProps', function(vehicleProps)
MySQL.update('UPDATE player_vehicles SET mods = ? WHERE plate = ?',
{ json.encode(vehicleProps), vehicleProps.plate })
end)

RegisterNetEvent('qb-garage:server:updateVehicle', function(state, fuel, engine, body, plate, garage, type, gang)
local owned = checkOwnership(source, plate, type, garage, gang) --Check ownership
if not owned then
Expand Down

0 comments on commit 9f855af

Please sign in to comment.