Handling editor online. Trouble

Hello. My programmer wrote this script for my server. The script includes: tire wear, changeable gearbox, and changeable suspension settings. But I ran into a problem, rubber wear does not work on all cars. On some cars everything is fine, and on some tires always show full wear, even after its replacement. Also, the gearbox changes (initial driveforce and maximum speed) do not apply, and the suspension settings do not work. In the RolePlay server, the mechanic job function does not work - when the mechanic repairs the car, the body and the rubber is restored, but if the player gets into his car, the rubber is completely erased again. I don’t understand why it doesn’t work? Here is my script:

ESX = nil
local Vehicles = {}

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
	ESX.TriggerServerCallback('esx_vehicleshop:getVehicles', function(vehicles)
		Vehicles = vehicles
	end)
end)


local changetyresPrice  = {
	['street'] = 2500,
	['sport'] = 5000,
	['muscle'] = 2500,
	['drag'] = 10000,
	['vaz'] = 500,
	['suv'] = 1000,
}

local repairEnginePrice = 1000 
local repairBodyPrice = 2000 -- Цена за ремонт кузова

local maxfInitialDragCoeff = 20-- максимальное значение fInitialDriveMaxFlatVel 
local minfInitialDragCoeff = 1 -- минимальное значение fInitialDriveMaxFlatVel 

-- меню Количество передач

local maxfnInitialDriveGears = 8 
local minfnInitialDriveGears = 2 

-- меню Тормозное усилие

local maxfBrakeForce = 2 
local minfBrakeForce = 0.01 

-- меню Баланс тормозов пер\зад

local minfBrakeBiasFront = 0.01
local maxfBrakeBiasFront = 1.0 

-- меню Жесткость пруэин

local minSuspensionForce = 1.0
local maxSuspensionForce = 5.0 

-- меню Аммортизаторы сжатие

local minSuspensionCompDamp = 0.5
local maxSuspensionCompDamp = 3.0

-- меню Аммортизаторы отбой

local minfSuspensionReboundDamp = 0.5
local maxfSuspensionReboundDamp = 3.0

-- меню Жесткость стабилизатора

local minAntiRollBarForce = 1.0
local maxAntiRollBarForce = 5.0

-- меню Жесткость стабилизатора

local minAntiRollBarBiasFront = 0.01
local maxAntiRollBarBiasFront = 1.0
function openMenu()
	ESX.UI.Menu.CloseAll()

	local elements = {}

    table.insert(elements, {label = 'НАЧАТЬ ГОНКУ', value = "menu_1"})             
	table.insert(elements, {label = 'РЕМОНТ ДВИГАТЕЛЯ 1000$', value = "menu_2"})  
	table.insert(elements, {label = 'РЕМОНТ КУЗОВА 2000$', value = "menu_3"})  
	--table.insert(elements, {label = 'СМЕНИТЬ РЕЗИНУ', value = "menu_5"})  
	table.insert(elements, {label = 'НАСТРОЙКА АВТО', value = "menu_6"})  

	ESX.UI.Menu.Open(
        'default', GetCurrentResourceName(), 'menu',
        {
            title = 'Menu',
            align = 'bottom-right',
            elements = elements 
        },     
        function(data, menu)            
			if data.current.value == 'menu_1' then 
				
			ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'race_rate', {
				title = 'СТАВКА'
			}, function(data2, menu2)
				menu2.close()
				local rate = tonumber(data2.value)
				
				ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'race_delay', {
					title = 'ВРЕМЯ НА ПОДГОТОВКУ'
				}, function(data3, menu3)
					menu3.close()
					local delay = tonumber(data3.value)
					TriggerEvent("StreetRaces:startRaceMenu", rate, delay)
				
				
				end, function(data3, menu3)
					menu3.close()
				end)
			
				
			end, function(data2, menu2)
				menu2.close()
			end)
			menu.close()
			
			end
			if data.current.value == 'menu_2' then 
				if IsPedInAnyVehicle(GetPlayerPed(-1), false) then
					ESX.TriggerServerCallback('esx_menu:isUpdateAvailable', function(add)
						if add then 
							local vehicle = GetVehiclePedIsUsing(GetPlayerPed(-1))
							SetVehicleEngineHealth(vehicle, 1000.0)
							SetVehicleOnGroundProperly(vehicle)
						    SetVehicleUndriveable(vehicle, false)
						else
							ESX.ShowNotification('Недостаточно денег')
						end
					end, repairEnginePrice)
				else
					ESX.ShowNotification('Вы должны быть в машине')
				end
				menu.close()
			end
			if data.current.value == 'menu_3' then 
				if IsPedInAnyVehicle(GetPlayerPed(-1), false) then
					ESX.TriggerServerCallback('esx_menu:isUpdateAvailable', function(add)
						if add then 
							TriggerEvent("iens:repairNotMecano")			
						else
							ESX.ShowNotification('Недостаточно денег')
						end
					end, repairBodyPrice)
				else
					ESX.ShowNotification('Вы должны быть в машине')
				end
				menu.close()
			end
			if data.current.value == 'menu_4' then 
				TriggerEvent('xgc-tuner:openTuner')
				menu.close()
			end
			if data.current.value == 'menu_5' then 
				if IsPedInAnyVehicle(GetPlayerPed(-1), false) then
					local vehicle = GetVehiclePedIsUsing(GetPlayerPed(-1))
					for i=1, #Vehicles, 1 do
						if GetHashKey(Vehicles[i].model) == GetEntityModel(vehicle) then
							local price = changetyresPrice[Vehicles[i].category]
							ESX.TriggerServerCallback('esx_menu:isUpdateAvailable', function(add)
								if add then 
									TriggerEvent("TireWear:fixCar", vehicle)
								else
									ESX.ShowNotification('Недостаточно денег')
								end
							end, price)
							break
						end
					end
				
				
					
				else
					ESX.ShowNotification('Вы должны быть в машине')
				end
				menu.close()
			end
			if data.current.value == 'menu_6' then 
				if IsPedInAnyVehicle(GetPlayerPed(-1), false) then
					local vehicle = GetVehiclePedIsUsing(GetPlayerPed(-1))
					local selemets = {}
					--table.insert(selemets, {
					  --name    = "fInitialDragCoeff",
					  --label   = 'КОРОБКА ПЕРЕДАЧ',
					  --defaultValue = DecorGetFloat(vehicle, "fInitialDragCoeff"),
					  --value   = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDragCoeff"),
					  --defaultFInitialDriveForce = DecorGetFloat(vehicle, "fInitialDriveForce"),
					  --type    = 'slider',
					  --max     = maxfInitialDragCoeff,
					  --min	  = minfInitialDragCoeff,
					--})
					table.insert(selemets, {
					  name    = "fSteeringLock",
					  label   = 'ВЫВОРОТ КОЛЁС',
					  value   = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fSteeringLock"),
					  type    = 'slider',
					  max     = maxfSteeringLock,
					  min	  = minfSteeringLock,
					})
				    table.insert(selemets, {
					  name    = "nInitialDriveGears",
					  label   = 'КОЛИЧЕСТВО ПЕРЕДАЧ',
					  value   = GetVehicleHandlingFloat(vehicle, "CHandlingData", "nInitialDriveGears"),
					  type    = 'slider',
					  max     = maxnInitialDriveGears,
					  min	  = minnInitialDriveGears,
					})
					table.insert(selemets, {
					  name    = "fBrakeForce",
					  label   = 'ТОРМОЗНОЕ УСИЛИЕ',
					  value   = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fBrakeForce"),
					  type    = 'slider',
					  max     = maxnfBrakeForce,
					  min	  = minnfBrakeForce,
					})
					table.insert(selemets, {
					  name    = "fBrakeBiasFront",
					  label   = 'БАЛАНС ТОРМОЗОВ ПЕР/ЗАД',
					  value   = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fBrakeBiasFront"),
					  type    = 'slider',
					  max     = maxfBrakeBiasFront,
					  min	  = minfBrakeBiasFront,
					})
					table.insert(selemets, {
					  name    = "SuspensionForce",
					  label   = 'ЖЕСТКОСТЬ ПРУЖИН',
					  value   = GetVehicleHandlingFloat(vehicle, "CHandlingData", "SuspensionForce"),
					  type    = 'slider',
					  max     = maxSuspensionForce,
					  min	  = minSuspensionForce,
					})
					table.insert(selemets, {
					  name    = "SuspensionCompDamp",
					  label   = 'АММОРТИЗАТОРЫ СЖАТИЕ',
					  value   = GetVehicleHandlingFloat(vehicle, "CHandlingData", "SuspensionCompDamp"),
					  type    = 'slider',
					  max     = maxSuspensionCompDamp,
					  min	  = minSuspensionCompDamp,
					})
					table.insert(selemets, {
					  name    = "fSuspensionReboundDamp",
					  label   = 'АММОРТИЗАТОРЫ ОТБОЙ',
					  value   = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fSuspensionReboundDamp"),
					  type    = 'slider',
					  max     = maxfSuspensionReboundDamp,
					  min	  = minfSuspensionReboundDamp,
					})
					table.insert(selemets, {
					  name    = "AntiRollBarForce",
					  label   = 'ЖЕСТКОСТЬ СТАБИЛИЗАТОРОВ',
					  value   = GetVehicleHandlingFloat(vehicle, "CHandlingData", "AntiRollBarForce"),
					  type    = 'slider',
					  max     = maxAntiRollBarForce,
					  min	  = minAntiRollBarForce,
					})
					table.insert(selemets, {
					  name    = "AntiRollBarBiasFront",
					  label   = 'БАЛАНС СТАБИЛИЗАТОРОВ ПЕР/ЗАД',
					  value   = GetVehicleHandlingFloat(vehicle, "CHandlingData", "AntiRollBarBiasFront"),
					  type    = 'slider',
					  max     = maxAntiRollBarBiasFront,
					  min	  = minAntiRollBarBiasFront,
					})
					ESX.UI.Menu.Open(
					'default', GetCurrentResourceName(), 'fInitialDragCoeff',
					{
						title = 'Menu',
						align = 'bottom-right',
						elements = selemets 
					},     
					function(data, menu)  
			

					end,
					function(data, menu)
						menu.close()
					end,
					function(data, menu)
						if data.current.name == 'fInitialDragCoeff' then 
							data.current.value = data.current.value + 0.0
							SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fInitialDragCoeff', data.current.value)
							if data.current.defaultValue ~= data.current.value then 
								local difference = (data.current.defaultValue - data.current.value) / 1000 
								local newvalue = data.current.defaultFInitialDriveForce - difference
								SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fInitialDriveForce', newvalue)
							else 
								SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fInitialDriveForce', data.current.defaultFInitialDriveForce)
							end
							print('fInitialDriveForce ' .. GetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveForce"))
							print('fInitialDragCoeff ' .. GetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDragCoeff"))
						end
						if data.current.name == 'fSteeringLock' then 
							data.current.value = data.current.value + 0.00
							SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fSteeringLock', data.current.value)
						end
                        if data.current.name == 'nInitialDriveGears' then 
							data.current.value = data.current.value + 0.00
							SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'nInitialDriveGears', data.current.value)
						end
						if data.current.name == 'fBrakeForce' then 
							data.current.value = data.current.value + 0.00
							SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fBrakeForce', data.current.value)
						end
						if data.current.name == 'fBrakeBiasFront' then 
							data.current.value = data.current.value + 0.00
							SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fBrakeBiasFront', data.current.value)
						end
						if data.current.name == 'SuspensionForce' then 
							data.current.value = data.current.value + 0.00
							SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'SuspensionForce', data.current.value)
						end
						if data.current.name == 'SuspensionCompDamp' then 
							data.current.value = data.current.value + 0.00
							SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'SuspensionCompDamp', data.current.value)
						end
						if data.current.name == 'fSuspensionReboundDamp' then 
							data.current.value = data.current.value + 0.00
							SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fSuspensionReboundDamp', data.current.value)
						end
						if data.current.name == 'AntiRollBarForce' then 
							data.current.value = data.current.value + 0.00
							SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'AntiRollBarForce', data.current.value)
						end
						if data.current.name == 'AntiRollBarBiasFront' then 
							data.current.value = data.current.value + 0.00
							SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'AntiRollBarBiasFront', data.current.value)
						end
					end

					)
				else
					ESX.ShowNotification('Вы должны быть в машине')
				end	
			end
        end,
		function(data, menu)
			menu.close()
		end
    )


end




Citizen.CreateThread(function()
	if not DecorIsRegisteredAsType("fInitialDragCoeff", 1) then 
		DecorRegister("fInitialDragCoeff", 1)
	end
	if not DecorIsRegisteredAsType("fInitialDriveForce", 1) then
		DecorRegister("fInitialDriveForce", 1)
	end
    while true do
	Citizen.Wait(0)
		if IsControlJustPressed(0, 244) then
			openMenu()
		end
		if IsPedInAnyVehicle(GetPlayerPed(-1), false) then
			local vehicle = GetVehiclePedIsUsing(GetPlayerPed(-1))
			if not DecorExistOn(vehicle, 'fInitialDragCoeff') then 
				DecorSetFloat(vehicle, 'fInitialDragCoeff', GetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDragCoeff"))
			end
			if not DecorExistOn(vehicle, 'fInitialDriveForce') then 
				DecorSetFloat(vehicle, 'fInitialDriveForce', GetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveForce"))
			end
		end		
			
   end
end)