[Release][OneSync][ESX/ExM] Persistent Vehicles

I’ll be referring to the latest updated version:
It doesn’t work automatically on each vehicle you enter. You’ll have to trigger it somehow.
You can trigger it on each vehicle you enter with this rough snippet, but then you’d need to forget them with another script if they need to be deleted:

Citizen.CreateThread(function() 
	while true do
		Wait(1000)
		local newvehicle = GetVehiclePedIsIn(PlayerPedId(), false)
		if GetPedInVehicleSeat(GetVehiclePedIsIn(PlayerPedId(), false), - 1) == PlayerPedId() then
			TriggerEvent('persistent-vehicles/register-vehicle', newvehicle)
		end
	end
end)

I use a command to ‘park’ and ‘unpark’ vehicles:

RegisterCommand('park', function()
	local newvehicle = GetVehiclePedIsIn(PlayerPedId(), false)
	if GetPedInVehicleSeat(GetVehiclePedIsIn(PlayerPedId(), false), - 1) == PlayerPedId() then
		FreezeEntityPosition(newvehicle, true)
		SetVehicleEngineOn(newvehicle, false, true, true)
		TriggerEvent('persistent-vehicles/register-vehicle', newvehicle)
		ESX.ShowHelpNotification('Vehicle Parked')
	else
		ESX.ShowNotification('Not driving a vehicle')
	end
end)

RegisterCommand('unpark', function()
	local newvehicle = GetVehiclePedIsIn(PlayerPedId(), false)
	if GetPedInVehicleSeat(GetVehiclePedIsIn(PlayerPedId(), false), - 1) == PlayerPedId() then
		FreezeEntityPosition(newvehicle, false)
		SetVehicleEngineOn(newvehicle, true, true, true)
		TriggerEvent('persistent-vehicles/forget-vehicle', newvehicle)
		ESX.ShowHelpNotification('Vehicle UnParked')
	else
		ESX.ShowNotification('Not driving a vehicle')
	end
end)

Check vehicle-data.json after running the commands

I’m getting some duplications also but this script is deprecated and I don’t expect support