Про imgui

izicapt

Известный
Автор темы
363
113
Версия MoonLoader
.027.0-preview
Короч всем приветос.
Сейчас пытаюсь научиться юзать imgui
И в коде ниже,нашлась ошибка.

gavnocod:
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local window = imgui.ImBool(false)

function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('atp', function()
        window.v = not window.v
        imgui.Process = window.v
    end)
    while true do
        wait(0)
        if window.v == false then
            imgui.Process = false
        end
    end
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(350.0, 250.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(280.0, 70.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Teleport by ya', window)

        imgui.Text('Viberite teleport')

        if imgui.Button('Dom avtora') then
            setCharCoordinates(PLAYER_PED, -2724.52, 923.76, 67.32)
           printString("Gotova",2500)
        end
        if  imgui.Button("Bank SF") then
            setCharCoordinates(PLAYER_PED,-2140.55,253.17,38.93)
                        printString("Gotova",2500)
            end
                if imgui.Button("AS") then
                    setCharCoordinates(PLAYER_PED, -331.54,821.01,2999.52)
                    printString("Gotova",2500)
                    end
        if imgui.Button("FBR") then
                    setCharCoordinates(PLAYER_PED, 246.45,109.57,1003.22)
                    printString("Gotova",2500)
                end
            if imgui.Button("Voenka SF")  then
                setCharCoordinates(PLAYER_PED,334.78,1932.11,30.32)
                printString("Gotova",2500)
                end
            if imgui.Button("Voenka LV") then
                setCharCoordinates(PLAYER_PED, -1603.20, 84.66, 15.25)
                printString("Gotova",2500)
            end
            if imgui.Button("Avtobazar")then
                setCharCoordinates(PLAYER_PED, -2101.07,-757.82,65.51)
                printString("Gotova", 2500)
        imgui.End()
    end
end
Как я понял,ошибка возникает где то в 21 строке
 
Решение
Как я понял,ошибка возникает где то в 21 строке
Ошибка находится в функции

Lua:
local imgui = require 'imgui'

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local window = imgui.ImBool(false)
function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('atp', function() window.v = not window.v end)
    while true do wait(0)
        imgui.Process = window.v
    end
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(350.0, 250.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(70.0, 280.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Teleport by ya', window)...

qdIbp

Автор темы
Проверенный
1,435
1,175
Как я понял,ошибка возникает где то в 21 строке
Ошибка находится в функции

Lua:
local imgui = require 'imgui'

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local window = imgui.ImBool(false)
function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('atp', function() window.v = not window.v end)
    while true do wait(0)
        imgui.Process = window.v
    end
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(350.0, 250.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(70.0, 280.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Teleport by ya', window)
            imgui.Text('Viberite teleport')
            if imgui.Button('Dom avtora') then
                setCharCoordinates(PLAYER_PED, -2724.52, 923.76, 67.32)
                printString("Gotova",2500)
            end
            if imgui.Button("Bank SF") then
                setCharCoordinates(PLAYER_PED,-2140.55,253.17,38.93)
                printString("Gotova",2500)
            end
            if imgui.Button("AS") then
                setCharCoordinates(PLAYER_PED, -331.54,821.01,2999.52)
                printString("Gotova",2500)
            end
            if imgui.Button("FBR") then
                setCharCoordinates(PLAYER_PED, 246.45,109.57,1003.22)
                printString("Gotova",2500)
            end
            if imgui.Button("Voenka SF")  then
                setCharCoordinates(PLAYER_PED,334.78,1932.11,30.32)
                printString("Gotova",2500)
            end
            if imgui.Button("Voenka LV") then
                setCharCoordinates(PLAYER_PED, -1603.20, 84.66, 15.25)
                printString("Gotova",2500)
            end
            if imgui.Button("Avtobazar")then
                setCharCoordinates(PLAYER_PED, -2101.07,-757.82,65.51)
                printString("Gotova", 2500)
            end
        imgui.End()
    end
end

Ты забыл поставить end в конце
Lua:
if imgui.Button("Avtobazar")then

Сейчас добавил флаг для автоматической установки размера окна
Lua:
local imgui = require 'imgui'

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local window = imgui.ImBool(false)
function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('atp', function() window.v = not window.v end)
    while true do wait(0)
        imgui.Process = window.v
    end
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(350.0, 250.0), imgui.Cond.FirstUseEver)
        --imgui.SetNextWindowSize(imgui.ImVec2(70.0, 280.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Teleport by ya', window, imgui.WindowFlags.AlwaysAutoResize) -- название, переменная, флаг
            imgui.Text('Viberite teleport')
            if imgui.Button('Dom avtora') then
                setCharCoordinates(PLAYER_PED, -2724.52, 923.76, 67.32)
                printString("Gotova",2500)
            end
            if imgui.Button("Bank SF") then
                setCharCoordinates(PLAYER_PED,-2140.55,253.17,38.93)
                printString("Gotova",2500)
            end
            if imgui.Button("AS") then
                setCharCoordinates(PLAYER_PED, -331.54,821.01,2999.52)
                printString("Gotova",2500)
            end
            if imgui.Button("FBR") then
                setCharCoordinates(PLAYER_PED, 246.45,109.57,1003.22)
                printString("Gotova",2500)
            end
            if imgui.Button("Voenka SF")  then
                setCharCoordinates(PLAYER_PED,334.78,1932.11,30.32)
                printString("Gotova",2500)
            end
            if imgui.Button("Voenka LV") then
                setCharCoordinates(PLAYER_PED, -1603.20, 84.66, 15.25)
                printString("Gotova",2500)
            end
            if imgui.Button("Avtobazar")then
                setCharCoordinates(PLAYER_PED, -2101.07,-757.82,65.51)
                printString("Gotova", 2500)
            end
        imgui.End()
    end
end
 
Последнее редактирование:
  • Нравится
Реакции: izicapt