Help ImGui

skillpz

Новичок
Автор темы
13
5
Версия MoonLoader
.026-beta
I found this code here on the forum, I would like to know how to show the result in ImGui instead of "print" as it is in the code.

Lua:
local sampev = require 'lib.samp.events'
local imgui = require 'imgui'
local encoding = require 'encoding'
local wantedlist = imgui.ImBool(false)
encoding.default = 'CP1251'
u8 = encoding.UTF8

function main()
    while not isSampAvailable() do wait(50) end
    while not data do wait(0) end
    sust = {}
    lua_thread.create(function() while true do wait(0) takewd = true sampSendChat('/wanted') wait(120000) end end)
    while true do wait(0)
        for _, h in pairs(getAllChars()) do
            _ , id = sampGetPlayerIdByCharHandle(h)
            _ , m = sampGetPlayerIdByCharHandle(PLAYER_PED)
            if id ~= -1 and id ~= m and doesCharExist(h) and sampIsPlayerConnected(id) then
                local x, y, z = getCharCoordinates(h)
                local mx, my, mz = getCharCoordinates(PLAYER_PED)
                local dist = getDistanceBetweenCoords3d(mx, my, mz, x, y, z)
                local color = string.format("%06X", ARGBtoRGB(sampGetPlayerColor(id)))
                for _, l in pairs(sust) do
                    local nicksu, idsu = l:match('.+%{FFFFFF%} (%a+_%a+)%[(%d+)%].+')
                    local sulvl = l:match('.+Ур. Розыска:{ff0000} (%d+)')
                    if tonumber(id) == tonumber(idsu) then
                        print('k')
                        RESULT IN IMGUI????????????????
                    end
                end
            end
        end
    end
end

function sampev.onServerMessage(color, text)
    if text:find('%{0088ff%}Привет, %{FFFFFF%}.+Сегодня %{ffcc66%}%S+ г.') then data = true end
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if takewd ~= true and dialogId == 11436 then
        sust = {}
        for w in string.gmatch(text, "[^\r\n]+") do
            table.insert(sust, w)
        end
    elseif takewd and dialogId == 11436 then
        sust = {}
        for w in string.gmatch(text, "[^\r\n]+") do
            table.insert(sust, w)
        end
        takewd = false
        return false
    end
end

function ARGBtoRGB(color)
    local a = bit.band(bit.rshift(color, 24), 0xFF)
    local r = bit.band(bit.rshift(color, 16), 0xFF)
    local g = bit.band(bit.rshift(color, 8), 0xFF)
    local b = bit.band(color, 0xFF)
    local rgb = b
    rgb = bit.bor(rgb, bit.lshift(g, 8))
    rgb = bit.bor(rgb, bit.lshift(r, 16))
    return rgb
end

function sampev.onPlaySound()
    if takewd then return false end
end

@#Northn
 

skillpz

Новичок
Автор темы
13
5
You can't do such action. You must use all imgui functions inside of their frame

Would you help me out of this? I tried all the ways, but without success, it always resulted in a null variable.
I marked you because the code was yours, if you saved something from that code I would be very grateful.
 

#Northn

Pears Project — уже запущен!
Всефорумный модератор
2,652
2,535
Lua:
function main()
    while not isSampAvailable() do wait(50) end
    while not data do wait(0) end
    sust = {}
    lua_thread.create(function() while true do wait(0) takewd = true sampSendChat('/wanted') wait(120000) end end)
    while true do wait(0)
        for _, h in ipairs(getAllChars()) do
            local res , id = sampGetPlayerIdByCharHandle(h)
            if res and id ~= -1 and sampIsPlayerConnected(id) and not sampIsPlayerNpc(id) then
                local x, y, z = getCharCoordinates(h)
                local mx, my, mz = getCharCoordinates(PLAYER_PED)
                local dist = getDistanceBetweenCoords3d(mx, my, mz, x, y, z)
                local color = string.format("%06X", ARGBtoRGB(sampGetPlayerColor(id)))
                for _, l in pairs(sust) do
                    local nicksu, idsu = l:match('.+%{FFFFFF%} (%a+_%a+)%[(%d+)%].+')
                    local sulvl = l:match('.+Ур. Розыска:{ff0000} (%d+)')
                    if tonumber(id) == tonumber(idsu) then
                        table.insert(sust, {nicksu, idsu, sulvl})
                    end
                end
            end
        end
    end
end

-- in imgui
for _, h in ipairs(sust) do
    imgui.Text(h[1]..' | '..h[2]..' | '..h[3])
end
 

skillpz

Новичок
Автор темы
13
5
Lua:
function main()
    while not isSampAvailable() do wait(50) end
    while not data do wait(0) end
    sust = {}
    lua_thread.create(function() while true do wait(0) takewd = true sampSendChat('/wanted') wait(120000) end end)
    while true do wait(0)
        for _, h in ipairs(getAllChars()) do
            local res , id = sampGetPlayerIdByCharHandle(h)
            if res and id ~= -1 and sampIsPlayerConnected(id) and not sampIsPlayerNpc(id) then
                local x, y, z = getCharCoordinates(h)
                local mx, my, mz = getCharCoordinates(PLAYER_PED)
                local dist = getDistanceBetweenCoords3d(mx, my, mz, x, y, z)
                local color = string.format("%06X", ARGBtoRGB(sampGetPlayerColor(id)))
                for _, l in pairs(sust) do
                    local nicksu, idsu = l:match('.+%{FFFFFF%} (%a+_%a+)%[(%d+)%].+')
                    local sulvl = l:match('.+Ур. Розыска:{ff0000} (%d+)')
                    if tonumber(id) == tonumber(idsu) then
                        table.insert(sust, {nicksu, idsu, sulvl})
                    end
                end
            end
        end
    end
end

-- in imgui
for _, h in ipairs(sust) do
    imgui.Text(h[1]..' | '..h[2]..' | '..h[3])
end

thank you very much, is there any other way to show the result on the screen other than by ImGui? in an easier way.