перепиши более понятно, используй более внятные названия переменных:


script_name		"g-meter"
script_author	"plasma"
script_version	"2.0"

local mad 		= require 'MoonAdditions'
local memory 	= require "memory"

-- Настройка отображения g-метра
local gMeterConfig = {
    color = 0x00000000,
    borderColor = 0xCCFF5544,
    pointColor = 0xFF1100CC,
    pointBorderColor = 0xFFFFFFFF,
    borderSize = 4,
    posX = 20,
    posY = 320,
    sizeX = 150,
    sizeY = 150,
    maxLongG = 7.5,
    maxLatG = 7.5
}

-- Переменные состояния
local state = {
    sp1 = 0,
    sp2 = 0,
    acel = 0,
    acelL = 0,
    deltaTime = 0,
    car = 0,
    angZ = 0,
    angZ2 = 0
}

function getTimeScale()
	print(memory.getfloat(0xB7CB64, false))
    return memory.getfloat(0xB7CB64, false)
end

function updateDeltaTime()
    while true do
        local time1 = gameClock()
        wait(0)
		print(gameClock())
        state.deltaTime = gameClock() - time1
    end
end

function getZAngle(vehicle)
    return getCarHeading(vehicle)
end

function calculateAcceleration()
    state.sp2 = getCharSpeed(PLAYER_PED)
    state.acel = ((state.sp2 - state.sp1) / state.deltaTime) / getTimeScale()
    state.sp1 = state.sp2  -- Обновляем sp1

    state.angZ = getZAngle(state.car)
    local radian = ((state.angZ - state.angZ2) / state.deltaTime) * 0.01745
    state.acelL = (radian * state.sp2) / getTimeScale()
    state.angZ2 = state.angZ  -- Обновляем angZ2
end

function draw_text(str, x, y, r, g, b)
    mad.draw_text(str, x, y, 1, 0.3, 0.6, mad.font_align.LEFT, 2000, true, false, r, g, b, 255, 1, 0, 30, 30, 30, 120)
end

function drawGraphics()
    local gx, gy, gSizeX, gSizeY, gBorderSize = gMeterConfig.posX, gMeterConfig.posY, gMeterConfig.sizeX, gMeterConfig.sizeY, gMeterConfig.borderSize
    local halfX, halfY = gSizeX / 2, gSizeY / 2
    
    local pointCenterX = gx + halfX + gBorderSize / 2
    local pointCenterY = gy + halfY - gBorderSize
    
    local maxX, maxY = gx + gSizeX, gy + gSizeY
    local x = pointCenterX + (state.acelL / 9.8) * ((maxX - pointCenterX) / gMeterConfig.maxLatG)
    local y = pointCenterY + (state.acel / 9.8) * ((maxY - pointCenterY) / gMeterConfig.maxLongG)
    
    renderDrawBoxWithBorder(gx, gy, gSizeX, gSizeY, gMeterConfig.color, gBorderSize, gMeterConfig.borderColor)
    renderDrawLine(gx + 1, gy + halfY - gBorderSize, gx + gSizeX, gy + halfY - gBorderSize, gBorderSize / 2, gMeterConfig.borderColor)
    renderDrawLine(gx + halfX + gBorderSize, gy + 1, gx + halfX + gBorderSize, gy + gSizeY, gBorderSize / 2, gMeterConfig.borderColor)
    
    x = math.max(gx + gBorderSize, math.min(x, maxX - gBorderSize))
    y = math.max(gy + gBorderSize, math.min(y, maxY - gBorderSize))
    
    renderDrawPolygon(x, y, 7, 7, 16, 0.0, gMeterConfig.pointBorderColor)
    renderDrawPolygon(x, y, 5, 5, 16, 0.0, gMeterConfig.pointColor)
    
    draw_text(string.format("Lat: %.2f g", state.acelL / 9.8), gx + halfX / 2, gy + gSizeY + gBorderSize, 255, 255, 255)
    draw_text(string.format("Long: %.2f g", state.acel / 9.8), gx + gSizeX + gBorderSize * 2, gy + halfY, 255, 255, 255)
end

function main()
    local threadTime = lua_thread.create(updateDeltaTime)
    while true do
        wait(0)
        if isPlayerPlaying(PLAYER_HANDLE) and not isCharOnFoot(PLAYER_PED) then
            state.car = getCarCharIsUsing(PLAYER_PED)
            calculateAcceleration()
            drawGraphics()
        end
    end
end


function calculateAcceleration()
    -- Получаем текущую скорость персонажа
    local currentSpeed = getCharSpeed(PLAYER_PED)
    
    -- Рассчитываем поступательное ускорение
    local acceleration = ((currentSpeed - state.sp1) / state.deltaTime) / getTimeScale()
    
    -- Обновляем сохраненное состояние скорости
    state.sp1 = currentSpeed
    
    -- Получаем текущий угол поворота по оси Z
    local currentAngleZ = getZAngle(state.car)
    
    -- Конвертируем изменение угла в радианы и расчитываем угловое ускорение
    local angleRadians = ((currentAngleZ - state.angZ2) / state.deltaTime) * 0.01745
    local angularAcceleration = (angleRadians * currentSpeed) / getTimeScale()
    
    -- Обновляем сохраненное состояние угла Z
    state.angZ2 = currentAngleZ
    
    -- Обновляем состояние
    state.sp2 = currentSpeed
    state.acel = acceleration
    state.acelL = angularAcceleration
end