Вывод чата хелперов в окно imgui

ReoGenT

Участник
Автор темы
90
6
Версия MoonLoader
.026-beta
Сделал вот такой скрипт:
Lua:
local t1 = 0

function samp.onServerMessage(color, text)
    if text:find("%[HC%] .+") then
        t1 = text:match('%[HC%] (.+)')
    end
end

function imgui.OnDrawFrame()
    if chathelpers.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 1.3, sh / 4.2))
        imgui.SetNextWindowSize(imgui.ImVec2(300, 400))
        imgui.Begin(u8'Чат хелперов', _, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar)
        imgui.TextColoredRGB(t1)
        imgui.End()
    end
end

Но в окно выводится только 1 последняя написанная строка в чате из чата хелперов, а мне нужно чтобы выводился весь чат хелперов (Типо как консоль), помимо одного сообщения помогите
 
Решение
Lua:
local t1 = {}

function samp.onServerMessage(color, text)
    if text:find("%[HC%] .+") then
        table.insert(t1, text:match('%[HC%] (.+)'))
    end
end

function imgui.OnDrawFrame()
    if chathelpers.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 1.3, sh / 4.2))
        imgui.SetNextWindowSize(imgui.ImVec2(300, 400))
        imgui.Begin(u8'Чат хелперов', _, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar)
        imgui.TextColoredRGB(table.concat(t1, '\n'))
        imgui.End()
    end
end

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,770
11,213
Lua:
local t1 = {}

function samp.onServerMessage(color, text)
    if text:find("%[HC%] .+") then
        table.insert(t1, text:match('%[HC%] (.+)'))
    end
end

function imgui.OnDrawFrame()
    if chathelpers.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 1.3, sh / 4.2))
        imgui.SetNextWindowSize(imgui.ImVec2(300, 400))
        imgui.Begin(u8'Чат хелперов', _, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar)
        imgui.TextColoredRGB(table.concat(t1, '\n'))
        imgui.End()
    end
end
 

VRush

https://t.me/vrushscript
Проверенный
2,341
1,089
Код:
-- в имгуи
  for i = 1, #chats do
      imgui.TextColoredRGB(chats[i])
  end

Код:
-- в onServerMessage
chats[#chats+ 1] = t1

Lua:
local t1 = {}

function samp.onServerMessage(color, text)
    if text:find("%[HC%] .+") then
        table.insert(t1, text:match('%[HC%] (.+)'))
    end
end

function imgui.OnDrawFrame()
    if chathelpers.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 1.3, sh / 4.2))
        imgui.SetNextWindowSize(imgui.ImVec2(300, 400))
        imgui.Begin(u8'Чат хелперов', _, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar)
        imgui.TextColoredRGB(table.concat(t1, '\n'))
        imgui.End()
    end
end
ну или так, незнаю как лучше будет
 

ReoGenT

Участник
Автор темы
90
6
Lua:
local t1 = {}

function samp.onServerMessage(color, text)
    if text:find("%[HC%] .+") then
        table.insert(t1, text:match('%[HC%] (.+)'))
    end
end

function imgui.OnDrawFrame()
    if chathelpers.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 1.3, sh / 4.2))
        imgui.SetNextWindowSize(imgui.ImVec2(300, 400))
        imgui.Begin(u8'Чат хелперов', _, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar)
        imgui.TextColoredRGB(table.concat(t1, '\n'))
        imgui.End()
    end
end
еще вопрос - Как через imput ввести в чат хелперов
 

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,770
11,213