Vehicle Properties
How clamps are kept on vehicles, and how to save them in ESX, QBCore or Qbox vehicle properties.
#How Clamps Are Kept
Fitted clamps are saved in the zyke_wheelclamp_clamps table, which is created on the first start.
Owned vehicles keep their clamps through disconnects, despawns and restarts. A vehicle counts as owned when it is in owned_vehicles on ESX, player_vehicles on QBCore, or qbx_vehicles on Qbox. Vehicles nobody owns, such as spawned or job vehicles, lose their clamps once the vehicle is deleted.
Clamped vehicles that are still out when zyke_wheelclamp restarts get their clamps back.
Skip the rest of this guide if you use zyke_garages or qbx_garages. They keep clamps on stored vehicles on their own.
For any other garage, add the clamp data to your framework's vehicle properties below, so a clamped vehicle taken out of the garage gets its clamps back. The properties only store a pointer to the saved clamps under zykeWheelclamp, and the server checks that the vehicle and its owner match before restoring.
#ESX
Open es_extended/client/functions.lua.
References:
In ESX.Game.GetVehicleProperties, add zykeWheelclamp to the returned table:
diff modWindows = GetVehicleMod(vehicle, 46),
modLivery = GetVehicleMod(vehicle, 48) == -1 and GetVehicleLivery(vehicle) or GetVehicleMod(vehicle, 48),
modLightbar = GetVehicleMod(vehicle, 49),
+ zykeWheelclamp = exports["zyke_wheelclamp"]:GetVehicleClampData(vehicle),
}
end
In ESX.Game.SetVehicleProperties, apply it after ESX restores props.tyreBurst, before the function closes:
diff if props.tyreBurst ~= nil then
for k, v in pairs(props.tyreBurst) do
if v then
k = tonumber(k)
if k then
SetVehicleTyreBurst(vehicle, k, true, 1000.0)
end
end
end
end
+
+ if (props.zykeWheelclamp ~= nil) then
+ exports["zyke_wheelclamp"]:SetVehicleClampData(vehicle, props.zykeWheelclamp)
+ end
end
#QBCore
Open qb-core/client/functions.lua.
References:
In QBCore.Functions.GetVehicleProperties, add zykeWheelclamp to the returned table:
diff modLivery = modLivery,
modKit49 = GetVehicleMod(vehicle, 49),
liveryRoof = GetVehicleRoofLivery(vehicle),
+ zykeWheelclamp = exports["zyke_wheelclamp"]:GetVehicleClampData(vehicle),
}
else
return
end
end
In QBCore.Functions.SetVehicleProperties, apply it after the existing vehicle properties, before the outer end:
diff if props.liveryRoof then
SetVehicleRoofLivery(vehicle, props.liveryRoof)
end
+ if (props.zykeWheelclamp ~= nil) then
+ exports["zyke_wheelclamp"]:SetVehicleClampData(vehicle, props.zykeWheelclamp)
+ end
end
end
#Qbox / ox_lib
Open ox_lib/resource/vehicleProperties/client.lua.
References:
In lib.getVehicleProperties, add zykeWheelclamp to the returned table:
diff tyres = damage.tyres,
bulletProofTyres = GetVehicleTyresCanBurst(vehicle),
driftTyres = gameBuild >= 2372 and GetDriftTyresEnabled(vehicle),
+ zykeWheelclamp = exports["zyke_wheelclamp"]:GetVehicleClampData(vehicle),
-- no setters?
-- leftHeadlight = GetIsLeftVehicleHeadlightDamaged(vehicle),
In lib.setVehicleProperties, apply it after fixVehicle, before the final return:
diff if fixVehicle then
SetVehicleFixed(vehicle)
end
+
+ if (props.zykeWheelclamp ~= nil) then
+ exports["zyke_wheelclamp"]:SetVehicleClampData(vehicle, props.zykeWheelclamp)
+ end
return not NetworkGetEntityIsNetworked(vehicle) or NetworkGetEntityOwner(vehicle) == cache.playerId
end
#Restore Requirements
SetVehicleClampData only asks the server to restore. The server puts the clamps back only when the vehicle is an owned vehicle of the same model matching the saved clamps, and those clamps aren't already on another vehicle that is still out. The player spawning it must be the vehicle's owner, control the vehicle, and stand within 30 metres of it.