помощь с ошибкой в имгуи

Kegwineye.

Участник
Автор темы
478
21
call caused an unhandled exception
stack traceback:
[C]: in function 'getCarSpeed'

как исправить ?
 

Kegwineye.

Участник
Автор темы
478
21
ты бы код кину
Lua:
require 'lib.moonloader'
local samp = require 'lib.samp.events'
local memory = require 'memory'
local imgui = require 'imgui'
local encoding = require "encoding"
local inicfg = require 'inicfg'
encoding.default = 'CP1251'
u8 = encoding.UTF8


local Matrix3X3 = require "matrix3x3"
local TextBID = imgui.ImBuffer(256)
local TextBWP = imgui.ImBuffer(256)
local clickwarp = imgui.ImBool(false)
local AirBrake = imgui.ImBool(false)
local gmCar = imgui.ImBool(false)

local rInfo = {
    state = false,
    id = -1,
    nickname = ''
}

local HLcfg = inicfg.load({
    config = {
        speed_airbrake = 1,
        staticObjectMy = 29056040,
        dinamicObjectMy = 90139629,
        pedPMy = 18629728,
        carPMy = 62825729,
        staticObject = 29056040,
        dinamicObject = 90139629,
        pedP = 18629728,
        carP = 62825729,
        colorPlayerI = 23222712,
        drawMyBullets = true,
        drawBullets = true,
        cbEndMy = true,
        cbEnd = true,
        showPlayerInfo = false,
        onlyId = true,
        onlyNick = true,
        timeRenderMyBullets = 10,
        timeRenderBullets = 10, -- время линий
        sizeOffMyLine = 1,
        sizeOffLine = 1, -- толщина линий
        sizeOffMyPolygonEnd = 1,
        sizeOffPolygonEnd = 1, -- размер окончания
        rotationMyPolygonEnd = 10,
        rotationPolygonEnd = 10, -- количество углов окончания
        degreeMyPolygonEnd = 50,
        degreePolygonEnd = 50,  -- градус поворота окончаний
        maxLineMyLimit = 30,
        maxLineLimit = 30 -- макс кол-во линий
    }
}, "traicer.ini")
inicfg.save(HLcfg, "traicer.ini")

local noBike = imgui.ImBool(false)
local gmCar = imgui.ImBool(false)
local SpeedHack = imgui.ImBool(false)
local window = imgui.ImBool(false)
local enabled = imgui.ImBool(false)
local line = imgui.ImBool(true)
local info = imgui.ImBool(true)
local my_cords = {getCharCoordinates(playerPed)}
-- BOOL

local elements = {
    checkbox = {
        drawMyBullets = imgui.ImBool(HLcfg.config.drawMyBullets),
        drawBullets = imgui.ImBool(HLcfg.config.drawBullets),
        cbEndMy = imgui.ImBool(HLcfg.config.cbEndMy),
        cbEnd = imgui.ImBool(HLcfg.config.cbEnd),
        showPlayerInfo = imgui.ImBool(HLcfg.config.showPlayerInfo),
        onlyId = imgui.ImBool(HLcfg.config.onlyId),
        onlyNick = imgui.ImBool(HLcfg.config.onlyNick)
    },
    int = {
        timeRenderMyBullets = imgui.ImInt(HLcfg.config.timeRenderMyBullets),
        timeRenderBullets = imgui.ImInt(HLcfg.config.timeRenderBullets),
        sizeOffMyLine = imgui.ImInt(HLcfg.config.sizeOffMyLine),
        sizeOffLine = imgui.ImInt(HLcfg.config.sizeOffLine),
        sizeOffMyPolygonEnd = imgui.ImInt(HLcfg.config.sizeOffMyPolygonEnd),
        sizeOffPolygonEnd = imgui.ImInt(HLcfg.config.sizeOffPolygonEnd),
        rotationMyPolygonEnd = imgui.ImInt(HLcfg.config.rotationMyPolygonEnd),
        rotationPolygonEnd = imgui.ImInt(HLcfg.config.rotationPolygonEnd),
        degreeMyPolygonEnd = imgui.ImInt(HLcfg.config.degreeMyPolygonEnd),
        degreePolygonEnd = imgui.ImInt(HLcfg.config.degreePolygonEnd),
        maxLineMyLimit = imgui.ImInt(HLcfg.config.maxLineMyLimit),
        maxLineLimit = imgui.ImInt(HLcfg.config.maxLineLimit)
    }
}

-- BOOL

local bulletSync = {lastId = 0, maxLines = elements.int.maxLineLimit.v}
for i = 1, bulletSync.maxLines do
    bulletSync[i] = { other = {time = 0, t = {x,y,z}, o = {x,y,z}, type = 0, color = 0, id = -1, colorText = 0}}
end

local bulletSyncMy = {lastId = 0, maxLines = elements.int.maxLineMyLimit.v}
for i = 1, bulletSyncMy.maxLines do
    bulletSyncMy[i] = { my = {time = 0, t = {x,y,z}, o = {x,y,z}, type = 0, color = 0}}
end

local font = renderCreateFont("Tahoma", 10, 1);

function explode_argb(argb)
    local a = bit.band(bit.rshift(argb, 24), 0xFF)
    local r = bit.band(bit.rshift(argb, 16), 0xFF)
    local g = bit.band(bit.rshift(argb, 8), 0xFF)
    local b = bit.band(argb, 0xFF)
    return a, r, g, b
end

local staticObject = imgui.ImFloat4( imgui.ImColor( explode_argb(HLcfg.config.staticObject) ):GetFloat4() )   
local dinamicObject = imgui.ImFloat4( imgui.ImColor( explode_argb(HLcfg.config.dinamicObject) ):GetFloat4() )   
local pedP = imgui.ImFloat4( imgui.ImColor( explode_argb(HLcfg.config.pedP) ):GetFloat4() )   
local carP = imgui.ImFloat4( imgui.ImColor( explode_argb(HLcfg.config.carP) ):GetFloat4() )
local staticObjectMy = imgui.ImFloat4( imgui.ImColor( explode_argb(HLcfg.config.staticObjectMy) ):GetFloat4() )   
local dinamicObjectMy = imgui.ImFloat4( imgui.ImColor( explode_argb(HLcfg.config.dinamicObjectMy) ):GetFloat4() )   
local pedPMy = imgui.ImFloat4( imgui.ImColor( explode_argb(HLcfg.config.pedPMy) ):GetFloat4() )   
local carPMy = imgui.ImFloat4( imgui.ImColor( explode_argb(HLcfg.config.carPMy) ):GetFloat4() ) 
local colorPlayerI = imgui.ImFloat4( imgui.ImColor( explode_argb(HLcfg.config.colorPlayerI) ):GetFloat4() )

function main()
    while not isSampLoaded() do wait(1000) end
    sampRegisterChatCommand('fh', function()
        window.v = not window.v
    end)
    while true do
        wait(0)
        imgui.Process = true
        if not window.v then
        local _, id = sampGetPlayerIdByCharHandle(playerPed)
            imgui.ShowCursor = false
        end   
       if SpeedHack.v then
        if isKeyDown(VK_LMENU) then
                    if getCarSpeed(storeCarCharIsInNoSave(playerPed)) * 2.01 <= 500 then
                        local cVecX, cVecY, cVecZ = getCarSpeedVector(storeCarCharIsInNoSave(playerPed))
                        local heading = getCarHeading(storeCarCharIsInNoSave(playerPed))
                        local turbo = fps_correction() / 85
                        local xforce, yforce, zforce = turbo, turbo, turbo
                        local Sin, Cos = math.sin(-math.rad(heading)), math.cos(-math.rad(heading))
                        if cVecX > -0.01 and cVecX < 0.01 then xforce = 0.0 end
                        if cVecY > -0.01 and cVecY < 0.01 then yforce = 0.0 end
                        if cVecZ < 0 then zforce = -zforce end
                        if cVecZ > -2 and cVecZ < 15 then zforce = 0.0 end
                        if Sin > 0 and cVecX < 0 then xforce = -xforce end
                        if Sin < 0 and cVecX > 0 then xforce = -xforce end
                        if Cos > 0 and cVecY < 0 then yforce = -yforce end
                        if Cos < 0 and cVecY > 0 then yforce = -yforce end
                        applyForceToCar(storeCarCharIsInNoSave(playerPed), xforce * Sin, yforce * Cos, zforce / 2, 0.0, 0.0, 0.0)
                    end


            if noBike.v then
                setCharCanBeKnockedOffBike(playerPed, true)
            else
                setCharCanBeKnockedOffBike(playerPed, false)
            end
        end
    end
if clickwarp.v then
 while isPauseMenuActive() do
                if cursorEnabled then
                    showCursor(false)
                end
                wait(100)
            end
            if isKeyDown(VK_MBUTTON) then
                cursorEnabled = not cursorEnabled
                click_warp()
                showCursor(cursorEnabled)
                while isKeyDown(VK_MBUTTON) do wait(80) end
            end
        end
        if AirBrake.v then
            if isKeyJustPressed(VK_RSHIFT) and not sampIsChatInputActive() then
                enAirBrake = not enAirBrake
                if enAirBrake then
                    local posX, posY, posZ = getCharCoordinates(playerPed)
                    airBrkCoords = {posX, posY, posZ, 0.0, 0.0, getCharHeading(playerPed)}
                end
            end
        end
        if enAirBrake then
            if isCharInAnyCar(playerPed) then heading = getCarHeading(storeCarCharIsInNoSave(playerPed))
            else heading = getCharHeading(playerPed) end
            local camCoordX, camCoordY, camCoordZ = getActiveCameraCoordinates()
            local targetCamX, targetCamY, targetCamZ = getActiveCameraPointAt()
            local angle = getHeadingFromVector2d(targetCamX - camCoordX, targetCamY - camCoordY)
            if isCharInAnyCar(playerPed) then difference = 0.79 else difference = 1.0 end
            setCharCoordinates(playerPed, airBrkCoords[1], airBrkCoords[2], airBrkCoords[3] - difference)
            if not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() then
                if isKeyDown(VK_W) then
                airBrkCoords[1] = airBrkCoords[1] + HLcfg.config.speed_airbrake * math.sin(-math.rad(angle))
                airBrkCoords[2] = airBrkCoords[2] + HLcfg.config.speed_airbrake * math.cos(-math.rad(angle))
                if not isCharInAnyCar(playerPed) then setCharHeading(playerPed, angle)
                else setCarHeading(storeCarCharIsInNoSave(playerPed), angle) end
                elseif isKeyDown(VK_S) then
                    airBrkCoords[1] = airBrkCoords[1] - HLcfg.config.speed_airbrake * math.sin(-math.rad(heading))
                    airBrkCoords[2] = airBrkCoords[2] - HLcfg.config.speed_airbrake * math.cos(-math.rad(heading))
                end
                if isKeyDown(VK_A) then
                    airBrkCoords[1] = airBrkCoords[1] - HLcfg.config.speed_airbrake * math.sin(-math.rad(heading - 90))
                    airBrkCoords[2] = airBrkCoords[2] - HLcfg.config.speed_airbrake * math.cos(-math.rad(heading - 90))
                elseif isKeyDown(VK_D) then
                    airBrkCoords[1] = airBrkCoords[1] - HLcfg.config.speed_airbrake * math.sin(-math.rad(heading + 90))
                    airBrkCoords[2] = airBrkCoords[2] - HLcfg.config.speed_airbrake * math.cos(-math.rad(heading + 90))
                end
                if isKeyDown(VK_LSHIFT) then airBrkCoords[3] = airBrkCoords[3] + HLcfg.config.speed_airbrake / 2.0 end
                if isKeyDown(VK_LCONTROL) and airBrkCoords[3] > -95.0 then airBrkCoords[3] = airBrkCoords[3] - HLcfg.config.speed_airbrake / 2.0 end
                if isKeyJustPressed(VK_OEM_PLUS) then
                    HLcfg.config.speed_airbrake = HLcfg.config.speed_airbrake + 0.2
                    printStyledString('Speed increased by + 0.2', 1000, 4) save()
                end
                if isKeyJustPressed(VK_OEM_MINUS) then
                    HLcfg.config.speed_airbrake = HLcfg.config.speed_airbrake - 0.2
                    printStyledString('Speed reduced by - 0.2', 1000, 4) save()
                end
            end
        end
        local oTime = os.time()
        if elements.checkbox.drawBullets.v then
            for i = 1, bulletSync.maxLines do
                if bulletSync[i].other.time >= oTime then
                    local result, wX, wY, wZ, wW, wH = convert3DCoordsToScreenEx(bulletSync[i].other.o.x, bulletSync[i].other.o.y, bulletSync[i].other.o.z, true, true)
                    local resulti, pX, pY, pZ, pW, pH = convert3DCoordsToScreenEx(bulletSync[i].other.t.x, bulletSync[i].other.t.y, bulletSync[i].other.t.z, true, true)
                    if result and resulti then
                        local xResolution = memory.getuint32(0x00C17044)
                        if wZ < 1 then
                            wX = xResolution - wX
                        end
                        if pZ < 1 then
                            pZ = xResolution - pZ
                        end
                        if elements.checkbox.showPlayerInfo.v then
                            if bulletSync[i].other.id ~= -1 then
                                if sampIsPlayerConnected(bulletSync[i].other.id) then
                                    if elements.checkbox.onlyId.v and elements.checkbox.onlyNick.v then
                                        renderFontDrawText(font, sampGetPlayerNickname(bulletSync[i].other.id)..'['..bulletSync[i].other.id..']', wX + 0.5, wY, bulletSync[i].other.colorText, false)
                                    elseif elements.checkbox.onlyId.v then
                                        renderFontDrawText(font, '['..bulletSync[i].other.id..']', wX + 0.5, wY, bulletSync[i].other.colorText, false)
                                    elseif elements.checkbox.onlyNick.v then
                                        renderFontDrawText(font, sampGetPlayerNickname(bulletSync[i].other.id), wX + 0.5, wY, bulletSync[i].other.colorText, false)
                                    end
                                end
                            end
                        end
                        renderDrawLine(wX, wY, pX, pY, elements.int.sizeOffLine.v, bulletSync[i].other.color)
                        if elements.checkbox.cbEnd.v then
                            renderDrawPolygon(pX, pY-1, 3 + elements.int.sizeOffPolygonEnd.v, 3 + elements.int.sizeOffPolygonEnd.v, 1 + elements.int.rotationPolygonEnd.v, elements.int.degreePolygonEnd.v, bulletSync[i].other.color)
                        end
                    end
                end
            end
        end
        if elements.checkbox.drawMyBullets.v then
            for i = 1, bulletSyncMy.maxLines do
                if bulletSyncMy[i].my.time >= oTime then
                    local result, wX, wY, wZ, wW, wH = convert3DCoordsToScreenEx(bulletSyncMy[i].my.o.x, bulletSyncMy[i].my.o.y, bulletSyncMy[i].my.o.z, true, true)
                    local resulti, pX, pY, pZ, pW, pH = convert3DCoordsToScreenEx(bulletSyncMy[i].my.t.x, bulletSyncMy[i].my.t.y, bulletSyncMy[i].my.t.z, true, true)
                    if result and resulti then
                        local xResolution = memory.getuint32(0x00C17044)
                        if wZ < 1 then
                            wX = xResolution - wX
                        end
                        if pZ < 1 then
                            pZ = xResolution - pZ
                        end
                        renderDrawLine(wX, wY, pX, pY, elements.int.sizeOffMyLine.v, bulletSyncMy[i].my.color)
                        if elements.checkbox.cbEndMy.v then
                            renderDrawPolygon(pX, pY-1, 3 + elements.int.sizeOffMyPolygonEnd.v, 3 + elements.int.sizeOffMyPolygonEnd.v, 1 + elements.int.rotationMyPolygonEnd.v, elements.int.degreeMyPolygonEnd.v, bulletSyncMy[i].my.color)
                        end
                    end
                end
            end
        end
    end
end

function imgui.OnDrawFrame()
    blue()
    if window.v then
        imgui.ShowCursor = true
        imgui.SetNextWindowPos(imgui.ImVec2(imgui.GetIO().DisplaySize.x / 2, imgui.GetIO().DisplaySize.y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(580, 796), imgui.Cond.FirstUseEver)
        imgui.Begin(u8"Family Capture Helper-Cheat | Version 0.0.1", window, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.Text("Fake Kill Settings:")
        imgui.Separator()     
        imgui.Separator()
        imgui.InputText(u8'ID Игрока', TextBID)
imgui.InputText(u8'ID Оружия', TextBWP)
if imgui.Button(u8'Фейковое убийство', imgui.ImVec2(250, 20)) then
sampSendDeathByPlayer(TextBID.v, TextBWP.v)
end     
        imgui.Text(u8"Настройки трейсера:")
        imgui.Separator()     
        imgui.Separator()     
        if imgui.CollapsingHeader(u8"Настройка своих пуль") then
            imgui.Separator()
            if imgui.Checkbox(u8"[Вкл/выкл] Отрисовку своих пуль", elements.checkbox.drawMyBullets) then
                HLcfg.config.drawMyBullets = elements.checkbox.drawMyBullets.v
                save()
            end
            imgui.PushItemWidth(175)

            if imgui.SliderInt("##bulletsMyTime1", elements.int.timeRenderMyBullets, 5, 40) then
                HLcfg.config.timeRenderMyBullets = elements.int.timeRenderMyBullets.v
                save()
            end imgui.SameLine() imgui.Text(u8"Время задержки трейсера")

            if imgui.SliderInt("##renderWidthLinesTwo1", elements.int.sizeOffMyLine, 1, 10) then
                HLcfg.config.sizeOffMyLine = elements.int.sizeOffMyLine.v
                save()
            end imgui.SameLine() imgui.Text(u8"Толщина линий")

            if imgui.SliderInt('##maxMyBullets1', elements.int.maxLineMyLimit, 10, 300) then
                bulletSyncMy.maxLines = elements.int.maxLineMyLimit.v
                bulletSyncMy = {lastId = 0, maxLines = elements.int.maxLineMyLimit.v}
                for i = 1, bulletSyncMy.maxLines do
                    bulletSyncMy[i] = { my = {time = 0, t = {x,y,z}, o = {x,y,z}, type = 0, color = 0}}
                end
                HLcfg.config.maxLineMyLimit = elements.int.maxLineMyLimit.v
                save()
            end imgui.SameLine() imgui.Text(u8"Максимальное количество линий")

            imgui.Separator()

            if imgui.Checkbox(u8"[Вкл/выкл] Окончания у линий##1", elements.checkbox.cbEndMy) then
                HLcfg.config.cbEndMy = elements.checkbox.cbEndMy.v
                save()
            end

            if imgui.SliderInt('##endNumber1s', elements.int.rotationMyPolygonEnd, 2, 10) then
                HLcfg.config.rotationMyPolygonEnd = elements.int.rotationMyPolygonEnd.v
                save()
            end imgui.SameLine() imgui.Text(u8"Количество углов на окончаниях")

            if imgui.SliderInt('##rotationOne1', elements.int.degreeMyPolygonEnd, 0, 360) then
                HLcfg.config.degreeMyPolygonEnd = elements.int.degreeMyPolygonEnd.v
                save()
            end imgui.SameLine() imgui.Text(u8"Градус поворота окончания")

            if imgui.SliderInt('##sizeTraicerEnd1', elements.int.sizeOffMyPolygonEnd, 1, 10) then
                HLcfg.config.sizeOffMyPolygonEnd = elements.int.sizeOffMyPolygonEnd.v
                save()
            end  imgui.SameLine() imgui.Text(u8"Размер окончания трейсера")

            imgui.Separator()

            imgui.PopItemWidth()
            imgui.Text(u8"Укажите цвет трейсера, если: ")
            imgui.PushItemWidth(325)
            if imgui.ColorEdit4("##dinamicObjectMy", dinamicObjectMy) then
                HLcfg.config.dinamicObjectMy = join_argb(dinamicObjectMy.v[1] * 255, dinamicObjectMy.v[2] * 255, dinamicObjectMy.v[3] * 255, dinamicObjectMy.v[4] * 255)
                save()
            end imgui.SameLine() imgui.Text(u8"Вы попали в динамический объект")
            if imgui.ColorEdit4("##staticObjectMy", staticObjectMy) then
                HLcfg.config.staticObjectMy = join_argb(staticObjectMy.v[1] * 255, staticObjectMy.v[2] * 255, staticObjectMy.v[3] * 255, staticObjectMy.v[4] * 255)
                save()
            end imgui.SameLine() imgui.Text(u8"Вы попали в статический объект")
            if imgui.ColorEdit4("##pedMy", pedPMy) then
                HLcfg.config.pedPMy = join_argb(pedPMy.v[1] * 255, pedPMy.v[2] * 255, pedPMy.v[3] * 255, pedPMy.v[4] * 255)
                save()
            end imgui.SameLine() imgui.Text(u8"Вы попали в игрока")
            if imgui.ColorEdit4("##carMy", carPMy) then
                HLcfg.config.carPMy = join_argb(carPMy.v[1] * 255, carPMy.v[2] * 255, carPMy.v[3] * 255, carPMy.v[4] * 255)
                save()
            end imgui.SameLine() imgui.Text(u8"Вы попали в машину")
            imgui.PopItemWidth()
            imgui.Separator()
        end
        if imgui.CollapsingHeader(u8"Настройка чужих пуль") then
            imgui.Separator()
            if imgui.Checkbox(u8"[Вкл/выкл] Отрисовку чужих пуль", elements.checkbox.drawBullets) then
                HLcfg.config.drawBullets = elements.checkbox.drawBullets.v
                save()
            end
            imgui.PushItemWidth(175)

            if imgui.SliderInt("##bulletsTime2", elements.int.timeRenderBullets, 5, 40) then
                HLcfg.config.timeRenderBullets = elements.int.timeRenderBullets.v
                save()
            end imgui.SameLine() imgui.Text(u8"Время задержки трейсера")

            if imgui.SliderInt("##renderWidthLines2", elements.int.sizeOffLine, 1, 10) then
                HLcfg.config.sizeOffLine = elements.int.sizeOffLine.v
                save()
            end imgui.SameLine() imgui.Text(u8"Толщина линий")

            if imgui.SliderInt('##maxMyBullets2', elements.int.maxLineLimit, 10, 300) then
                bulletSync.maxLines = elements.int.maxLineLimit.v
                bulletSync = {lastId = 0, maxLines = elements.int.maxLineLimit.v}
                for i = 1, bulletSync.maxLines do
                    bulletSync[i] = { other = {time = 0, t = {x,y,z}, o = {x,y,z}, type = 0, color = 0}}
                end
                HLcfg.config.maxLineLimit = elements.int.maxLineLimit.v
                save()
            end imgui.SameLine() imgui.Text(u8"Максимальное количество линий")

            imgui.Separator()

            if imgui.Checkbox(u8"[Вкл/выкл] Окончания у линий##2", elements.checkbox.cbEnd) then
                HLcfg.config.cbEnd = elements.checkbox.cbEnd.v
                save()
            end

            if imgui.SliderInt('##endNumber2', elements.int.rotationPolygonEnd, 2, 10) then
                HLcfg.config.rotationPolygonEnd = elements.int.rotationPolygonEnd.v
                save()
            end imgui.SameLine() imgui.Text(u8"Количество углов на окончаниях")

            if imgui.SliderInt('##rotationOne2', elements.int.degreePolygonEnd, 0, 360) then
                HLcfg.config.degreePolygonEnd = elements.int.degreePolygonEnd.v
                save()
            end imgui.SameLine() imgui.Text(u8"Градус поворота окончания")

            if imgui.SliderInt('##sizeTraicerEnd2', elements.int.sizeOffPolygonEnd, 1, 10) then
                HLcfg.config.sizeOffPolygonEnd = elements.int.sizeOffPolygonEnd.v
                save()
            end  imgui.SameLine() imgui.Text(u8"Размер окончания трейсера")

            imgui.PopItemWidth()

            imgui.Separator()

            if imgui.Checkbox(u8"[Вкл/выкл] ИД и никнейм игрока при выстреле", elements.checkbox.showPlayerInfo) then
                HLcfg.config.showPlayerInfo = elements.checkbox.showPlayerInfo.v
                save()
            end

            if imgui.Button(u8"Настроить информацию о стрелке", imgui.ImVec2(325, 0)) then
                imgui.OpenPopup(u8"Настройка информации о стрелке")
            end

            if imgui.BeginPopup(u8"Настройка информации о стрелке") then
                if imgui.Checkbox(u8"Показывать ИД", elements.checkbox.onlyId) then
                    HLcfg.config.onlyId = elements.checkbox.onlyId.v
                    save()
                end
                if imgui.Checkbox(u8"Показывать никнейм", elements.checkbox.onlyNick) then
                    HLcfg.config.onlyNick = elements.checkbox.onlyNick.v
                    save()
                end
                imgui.EndPopup()
            end

            imgui.PushItemWidth(325)

            if imgui.ColorEdit4("##infoNickId", colorPlayerI) then
                HLcfg.config.colorPlayerI = join_argb(colorPlayerI.v[1] * 255, colorPlayerI.v[2] * 255, colorPlayerI.v[3] * 255, colorPlayerI.v[4] * 255)
                save()
            end imgui.SameLine() imgui.Text(u8"Укажите цвет никнейма стрелка")

            imgui.PopItemWidth()

            imgui.Separator()
            imgui.Text(u8"Укажите цвет трейсера, если: ")
            imgui.PushItemWidth(325)
            if imgui.ColorEdit4("##dinamicObject", dinamicObject) then
                HLcfg.config.dinamicObject = join_argb(dinamicObject.v[1] * 255, dinamicObject.v[2] * 255, dinamicObject.v[3] * 255, dinamicObject.v[4] * 255)
                save()
            end imgui.SameLine() imgui.Text(u8"Игрок попал в динамический объект")
            if imgui.ColorEdit4("##staticObject", staticObject) then
                HLcfg.config.staticObject = join_argb(staticObject.v[1] * 255, staticObject.v[2] * 255, staticObject.v[3] * 255, staticObject.v[4] * 255)
                save()
            end imgui.SameLine() imgui.Text(u8"Игрок попал в статический объект")
            if imgui.ColorEdit4("##ped", pedP) then
                HLcfg.config.pedP = join_argb(pedP.v[1] * 255, pedP.v[2] * 255, pedP.v[3] * 255, pedP.v[4] * 255)
                save()
            end imgui.SameLine() imgui.Text(u8"Игрок попал в игрока")
            if imgui.ColorEdit4("##car", carP) then
                HLcfg.config.carP = join_argb(carP.v[1] * 255, carP.v[2] * 255, carP.v[3] * 255, carP.v[4] * 255)
                save()
            end imgui.SameLine() imgui.Text(u8"Игрок попал в машину")
            imgui.PopItemWidth()
            imgui.Separator()
        end
        imgui.Separator()
        imgui.Text("SA:MP Function")
        imgui.Checkbox("Click-Warp", clickwarp)
        imgui.SameLine()
        imgui.HelpMarker(u8"Телепортирует по метке используйте нажатие колёсика мыши.")
        imgui.Checkbox("Air-Brake", AirBrake)
        imgui.SameLine()
        imgui.HelpMarker(u8"rshift - запуск. lctrl - вниз. lshift - вверх.")
        imgui.Checkbox("NoBike", noBike)
        imgui.SameLine()
        imgui.HelpMarker(u8"Не даёт упасть в вело/мото")
        imgui.Checkbox("SpeedHack for Car", SpeedHack)
        imgui.SameLine()
        imgui.HelpMarker(u8"Спид-хак постепенный для транспорта.")
        imgui.Text(u8"Разработка..")
        imgui.End()
    end
end

--[[
                                        0 - статический объект
                                        2 - ped
                                        3 - car
                                        4 - динамический объект НАЕБАЛОВО СУКА
]]

function samp.onSendBulletSync(data)
    if elements.checkbox.drawMyBullets.v then
        if data.center.x ~= 0 then
            if data.center.y ~= 0 then
                if data.center.z ~= 0 then
                    bulletSyncMy.lastId = bulletSyncMy.lastId + 1
                    if bulletSyncMy.lastId < 1 or bulletSyncMy.lastId > bulletSyncMy.maxLines then
                        bulletSyncMy.lastId = 1
                    end
                    bulletSyncMy[bulletSyncMy.lastId].my.time = os.time() + elements.int.timeRenderMyBullets.v
                    bulletSyncMy[bulletSyncMy.lastId].my.o.x, bulletSyncMy[bulletSyncMy.lastId].my.o.y, bulletSyncMy[bulletSyncMy.lastId].my.o.z = data.origin.x, data.origin.y, data.origin.z
                    bulletSyncMy[bulletSyncMy.lastId].my.t.x, bulletSyncMy[bulletSyncMy.lastId].my.t.y, bulletSyncMy[bulletSyncMy.lastId].my.t.z = data.target.x, data.target.y, data.target.z
                    if data.targetType == 0 then
                        bulletSyncMy[bulletSyncMy.lastId].my.color = join_argb(255, staticObjectMy.v[1]*255, staticObjectMy.v[2]*255, staticObjectMy.v[3]*255)
                    elseif data.targetType == 1 then
                        bulletSyncMy[bulletSyncMy.lastId].my.color = join_argb(255, pedPMy.v[1]*255, pedPMy.v[2]*255, pedPMy.v[3]*255)
                    elseif data.targetType == 2 then
                        bulletSyncMy[bulletSyncMy.lastId].my.color = join_argb(255, carPMy.v[1]*255, carPMy.v[2]*255, carPMy.v[3]*255)
                    elseif data.targetType == 3 then
                        bulletSyncMy[bulletSyncMy.lastId].my.color = join_argb(255, dinamicObjectMy.v[1]*255, dinamicObjectMy.v[2]*255, dinamicObjectMy.v[3]*255)
                    end
                end
            end
        end
    end
end

function samp.onBulletSync(playerid, data)
    if elements.checkbox.drawBullets.v then
        if data.center.x ~= 0 then
            if data.center.y ~= 0 then
                if data.center.z ~= 0 then
                    bulletSync.lastId = bulletSync.lastId + 1
                    if bulletSync.lastId < 1 or bulletSync.lastId > bulletSync.maxLines then
                        bulletSync.lastId = 1
                    end
                    if elements.checkbox.showPlayerInfo.v then
                        bulletSync[bulletSync.lastId].other.id = playerid
                        bulletSync[bulletSync.lastId].other.colorText = join_argb(255, colorPlayerI.v[1]*255, colorPlayerI.v[2]*255, colorPlayerI.v[3]*255)
                    end
                    bulletSync[bulletSync.lastId].other.time = os.time() + elements.int.timeRenderBullets.v
                    bulletSync[bulletSync.lastId].other.o.x, bulletSync[bulletSync.lastId].other.o.y, bulletSync[bulletSync.lastId].other.o.z = data.origin.x, data.origin.y, data.origin.z
                    bulletSync[bulletSync.lastId].other.t.x, bulletSync[bulletSync.lastId].other.t.y, bulletSync[bulletSync.lastId].other.t.z = data.target.x, data.target.y, data.target.z
                    bulletSync[bulletSync.lastId].other.type = data.targetType
                    if data.targetType == 0 then
                        bulletSync[bulletSync.lastId].other.color = join_argb(255, staticObject.v[1]*255, staticObject.v[2]*255, staticObject.v[3]*255)
                    elseif data.targetType == 1 then
                        bulletSync[bulletSync.lastId].other.color = join_argb(255, pedP.v[1]*255, pedP.v[2]*255, pedP.v[3]*255)
                    elseif data.targetType == 2 then
                        bulletSync[bulletSync.lastId].other.color = join_argb(255, carP.v[1]*255, carP.v[2]*255, carP.v[3]*255)
                    elseif data.targetType == 3 then
                        bulletSync[bulletSync.lastId].other.color = join_argb(255, dinamicObject.v[1]*255, dinamicObject.v[2]*255, dinamicObject.v[3]*255)
                    end
                end
            end
        end
    end
end

function onScriptTerminate(script, quitGame)
    if script == thisScript() then thisScript():reload() end
end

function join_argb(a, r, g, b)
    local argb = b  -- b
    argb = bit.bor(argb, bit.lshift(g, 8))  -- g
    argb = bit.bor(argb, bit.lshift(r, 16)) -- r
    argb = bit.bor(argb, bit.lshift(a, 24)) -- a
    return argb
end

function save()
    inicfg.save(HLcfg, "traicer.ini")
end

function fps_correction()
    return representIntAsFloat(readMemory(0xB7CB5C, 4, false))
end

function createPointMarker(x, y, z)
    pointMarker = createUser3dMarker(x, y, z + 0.3, 4)
end
 
function removePointMarker()
    if pointMarker then
      removeUser3dMarker(pointMarker)
      pointMarker = nil
    end
end

function clearAnimka()
    animid = sampGetPlayerAnimationId(getMyId())
    if animid == 1168 then
        clearCharTasksImmediately(playerPed)
    end
end

function click_warp()
    lua_thread.create(function()
        while true do
        if cursorEnabled and not window.v and not changePosition then
          local mode = sampGetCursorMode()
          if mode == 0 then
            showCursor(true)
          end
          local sx, sy = getCursorPos()
          local sw, sh = getScreenResolution()
          if sx >= 0 and sy >= 0 and sx < sw and sy < sh then
            local posX, posY, posZ = convertScreenCoordsToWorld3D(sx, sy, 700.0)
            local camX, camY, camZ = getActiveCameraCoordinates()
            local result, colpoint = processLineOfSight(camX, camY, camZ, posX, posY, posZ,
            true, true, false, true, false, false, false)
            if result and colpoint.entity ~= 0 then
              local normal = colpoint.normal
              local pos = Vector3D(colpoint.pos[1], colpoint.pos[2], colpoint.pos[3]) - (Vector3D(normal[1], normal[2], normal[3]) * 0.1)
              local zOffset = 300
              if normal[3] >= 0.5 then zOffset = 1 end
              local result, colpoint2 = processLineOfSight(pos.x, pos.y, pos.z + zOffset, pos.x, pos.y, pos.z - 0.3,
                true, true, false, true, false, false, false)
              if result then
                pos = Vector3D(colpoint2.pos[1], colpoint2.pos[2], colpoint2.pos[3] + 1)

                local curX, curY, curZ  = getCharCoordinates(playerPed)
                local dist              = getDistanceBetweenCoords3d(curX, curY, curZ, pos.x, pos.y, pos.z)
                local hoffs             = renderGetFontDrawHeight(font)

                sy = sy - 2
                sx = sx - 2
                renderFontDrawText(font, string.format("{FFFFFF}%0.2fm", dist), sx, sy - hoffs, 0xEEEEEEEE)

                local tpIntoCar = nil
                if colpoint.entityType == 2 then
                  local car = getVehiclePointerHandle(colpoint.entity)
                  if doesVehicleExist(car) and (not isCharInAnyCar(playerPed) or storeCarCharIsInNoSave(playerPed) ~= car) then
                    displayVehicleName(sx, sy - hoffs * 2, getNameOfVehicleModel(getCarModel(car)))
                    local color = 0xFFFFFFFF
                    if isKeyDown(VK_RBUTTON) then
                      tpIntoCar = car
                      color = 0xFFFFFFFF
                    end
                    renderFontDrawText(font, "{00CC66}Зажмите ПКМ и нажмите ЛКМ для телепорта", sx, sy - hoffs * 3, color)
                  end
                end

                createPointMarker(pos.x, pos.y, pos.z)

                if isKeyDown(VK_LBUTTON) then
                  if tpIntoCar then
                    if not jumpIntoCar(tpIntoCar) then
                      teleportPlayer(pos.x, pos.y, pos.z)
                      local veh = storeCarCharIsInNoSave(playerPed)
                      local cordsVeh = {getCarCoordinates(veh)}
                      setCarCoordinates(veh, cordsVeh[1], cordsVeh[2], cordsVeh[3])
                    end
                  else
                    if isCharInAnyCar(playerPed) then
                      local norm = Vector3D(colpoint.normal[1], colpoint.normal[2], 0)
                      local norm2 = Vector3D(colpoint2.normal[1], colpoint2.normal[2], colpoint2.normal[3])
                      rotateCarAroundUpAxis(storeCarCharIsInNoSave(playerPed), norm2)
                      pos = pos - norm * 1.8
                      pos.z = pos.z - 1.1
                    end
                    teleportPlayer(pos.x, pos.y, pos.z)
                  end
                  removePointMarker()

                  while isKeyDown(VK_LBUTTON) do wait(0) end
                  showCursor(false)
                end
              end
            end
          end
        end
        wait(0)
        removePointMarker()
        end
    end)
end

function setCharCoordinatesDontResetAnim(char, x, y, z)
    if doesCharExist(char) then
      local ptr = getCharPointer(char)
      setEntityCoordinates(ptr, x, y, z)
    end
end
 
function setEntityCoordinates(entityPtr, x, y, z)
    if entityPtr ~= 0 then
      local matrixPtr = readMemory(entityPtr + 0x14, 4, false)
      if matrixPtr ~= 0 then
        local posPtr = matrixPtr + 0x30
        writeMemory(posPtr + 0, 4, representFloatAsInt(x), false) -- X
        writeMemory(posPtr + 4, 4, representFloatAsInt(y), false) -- Y
        writeMemory(posPtr + 8, 4, representFloatAsInt(z), false) -- Z
      end
    end
end
 
function showCursor(toggle)
    if toggle then
      sampSetCursorMode(CMODE_LOCKCAM)
    else
      sampToggleCursor(false)
    end
    cursorEnabled = toggle
end

function displayVehicleName(x, y, gxt)
    x, y = convertWindowScreenCoordsToGameScreenCoords(x, y)
    useRenderCommands(true)
    setTextWrapx(640.0)
    setTextProportional(true)
    setTextJustify(false)
    setTextScale(0.33, 0.8)
    setTextDropshadow(0, 0, 0, 0, 0)
    setTextColour(255, 255, 255, 230)
    setTextEdge(1, 0, 0, 0, 100)
    setTextFont(1)
    displayText(x, y, gxt)
end
 
function createPointMarker(x, y, z)
    pointMarker = createUser3dMarker(x, y, z + 0.3, 4)
end
 
function removePointMarker()
    if pointMarker then
      removeUser3dMarker(pointMarker)
      pointMarker = nil
    end
end

function getCarFreeSeat(car)
    if doesCharExist(getDriverOfCar(car)) then
      local maxPassengers = getMaximumNumberOfPassengers(car)
      for i = 0, maxPassengers do
        if isCarPassengerSeatFree(car, i) then
          return i + 1
        end
      end
      return nil -- no free seats
    else
      return 0 -- driver seat
    end
end
 
function jumpIntoCar(car)
    local seat = getCarFreeSeat(car)
    if not seat then return false end                         -- no free seats
    if seat == 0 then warpCharIntoCar(playerPed, car)         -- driver seat
    else warpCharIntoCarAsPassenger(playerPed, car, seat - 1) -- passenger seat
    end
    restoreCameraJumpcut()
    return true
end

function rotateCarAroundUpAxis(car, vec)
    local mat = Matrix3X3(getVehicleRotationMatrix(car))
    local rotAxis = Vector3D(mat.up:get())
    vec:normalize()
    rotAxis:normalize()
    local theta = math.acos(rotAxis:dotProduct(vec))
    if theta ~= 0 then
      rotAxis:crossProduct(vec)
      rotAxis:normalize()
      rotAxis:zeroNearZero()
      mat = mat:rotate(rotAxis, -theta)
    end
    setVehicleRotationMatrix(car, mat:get())
end
 
function readFloatArray(ptr, idx)
    return representIntAsFloat(readMemory(ptr + idx * 4, 4, false))
end
 
function writeFloatArray(ptr, idx, value)
    writeMemory(ptr + idx * 4, 4, representFloatAsInt(value), false)
end

function setVehicleRotationMatrix(car, rx, ry, rz, fx, fy, fz, ux, uy, uz)
    local entityPtr = getCarPointer(car)
    if entityPtr ~= 0 then
      local mat = readMemory(entityPtr + 0x14, 4, false)
      if mat ~= 0 then
        writeFloatArray(mat, 0, rx)
        writeFloatArray(mat, 1, ry)
        writeFloatArray(mat, 2, rz)
 
        writeFloatArray(mat, 4, fx)
        writeFloatArray(mat, 5, fy)
        writeFloatArray(mat, 6, fz)
 
        writeFloatArray(mat, 8, ux)
        writeFloatArray(mat, 9, uy)
        writeFloatArray(mat, 10, uz)
      end
    end
end

function imgui.HelpMarker(text)
    imgui.TextDisabled('(?)')
    if imgui.IsItemHovered() then
        imgui.BeginTooltip()
        imgui.PushTextWrapPos(450)
        imgui.TextUnformatted(text)
        imgui.PopTextWrapPos()
        imgui.EndTooltip()
    end
end

function getVehicleRotationMatrix(car)
    local entityPtr = getCarPointer(car)
    if entityPtr ~= 0 then
      local mat = readMemory(entityPtr + 0x14, 4, false)
      if mat ~= 0 then
        local rx, ry, rz, fx, fy, fz, ux, uy, uz
        rx = readFloatArray(mat, 0)
        ry = readFloatArray(mat, 1)
        rz = readFloatArray(mat, 2)
 
        fx = readFloatArray(mat, 4)
        fy = readFloatArray(mat, 5)
        fz = readFloatArray(mat, 6)
 
        ux = readFloatArray(mat, 8)
        uy = readFloatArray(mat, 9)
        uz = readFloatArray(mat, 10)
        return rx, ry, rz, fx, fy, fz, ux, uy, uz
      end
    end
end

function teleportPlayer(x, y, z)
    if isCharInAnyCar(playerPed) then
      setCharCoordinates(playerPed, x, y, z)
    end
    setCharCoordinatesDontResetAnim(playerPed, x, y, z)
end

function blue()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    style.Alpha = 1.00

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0

            colors[clr.FrameBg]                = ImVec4(0.48, 0.16, 0.16, 0.54)
            colors[clr.FrameBgHovered]         = ImVec4(0.98, 0.26, 0.26, 0.40)
            colors[clr.FrameBgActive]          = ImVec4(0.98, 0.26, 0.26, 0.67)
            colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
            colors[clr.TitleBgActive]          = ImVec4(0.48, 0.16, 0.16, 1.00)
            colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
            colors[clr.CheckMark]              = ImVec4(0.98, 0.26, 0.26, 1.00)
            colors[clr.SliderGrab]             = ImVec4(0.88, 0.26, 0.24, 1.00)
            colors[clr.SliderGrabActive]       = ImVec4(0.98, 0.26, 0.26, 1.00)
    colors[clr.Button]                = ImVec4(0.41, 0.19, 0.63, 0.44)
    colors[clr.ButtonHovered]         = ImVec4(0.41, 0.19, 0.63, 0.86)
    colors[clr.ButtonActive]          = ImVec4(0.64, 0.33, 0.94, 1.00)
            colors[clr.Header]                 = ImVec4(0.98, 0.26, 0.26, 0.31)
            colors[clr.HeaderHovered]          = ImVec4(0.98, 0.26, 0.26, 0.80)
            colors[clr.HeaderActive]           = ImVec4(0.98, 0.26, 0.26, 1.00)
            colors[clr.Separator]              = colors[clr.Border]
            colors[clr.SeparatorHovered]       = ImVec4(0.75, 0.10, 0.10, 0.78)
            colors[clr.SeparatorActive]        = ImVec4(0.75, 0.10, 0.10, 1.00)
            colors[clr.ResizeGrip]             = ImVec4(0.98, 0.26, 0.26, 0.25)
            colors[clr.ResizeGripHovered]      = ImVec4(0.98, 0.26, 0.26, 0.67)
            colors[clr.ResizeGripActive]       = ImVec4(0.98, 0.26, 0.26, 0.95)
            colors[clr.TextSelectedBg]         = ImVec4(0.98, 0.26, 0.26, 0.35)
            colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
            colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 1.00)
            colors[clr.WindowBg]               = ImVec4(0.06, 0.06, 0.06, 0.94)
            colors[clr.ChildWindowBg]          = ImVec4(1.00, 1.00, 1.00, 0.00)
            colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
            colors[clr.ComboBg]                = colors[clr.PopupBg]
            colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
            colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
            colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
            colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
            colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
            colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
            colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 1.00)
            colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 0.50)
            colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 1.00)
            colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 1.00)
            colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
            colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
            colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
            colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
            colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
end
л. Скорее всего неверно введен хендл машины
 

Kegwineye.

Участник
Автор темы
478
21
@chapo это к твоему скрипту звуки клавиш чо делать

GTA_ San Andreas 04.12.2021 17_33_47.png
 

chapo

tg/inst: @moujeek
Всефорумный модератор
9,230
12,645
[ML] (error) admin-tools.v0.01.lua: opcode '00A0' call caused an unhandled exception
stack traceback:
[C]: in function 'getCharCoordinates'
...p\GTA 140K BY DAPO SHOW\moonloader\admin-tools.v0.01.lua:66: in main chunk
у меня есть небольшая теория: возможно блять ты не можешь получить координаты персонажа пока он не заспавнен?!