нет окна imgui

bruskin

Участник
Автор темы
149
12
Версия MoonLoader
Другое
Lua:
require('lib.moonloader')
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local sampev = require('lib.samp.events')

--imgui
local main_window_state = imgui.ImBool(false)

function imgui.OnDrawFrame()
    if main_window_state.v then
        local scrX, scrY = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(scrX / 2, scrY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5));
        imgui.SetNextWindowSize(imgui.ImVec2(600,400), imgui.Cond.FirstUseEver)
        imgui.Begin(u8'Информация', main_window_state)
        imgui.Text(u8'Ник: '..nick)   
        imgui.Text(u8'Организация: '..org)   
        imgui.Text(u8'Должность: '..rang) 
        imgui.End()
    end
end

function main()
    while not isSampAvailable() do wait(0) end
        sampAddChatMessage('{663300}[Defens Helper] {FFFFFF}Скрипт успешно запущен', -1)
        sampAddChatMessage('{663300}[Defens Helper] {FFFFFF}Автор: Mark Bruskin | Версия: 1.0.0', -1)
        sampRegisterChatCommand('probiv', probiv)
        sampRegisterChatCommand('fixdefhelp', fixprobiv)
        sampRegisterChatCommand('info', function() main_window_state.v = not main_window_state.v end)
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        nick = sampGetPlayerNickname(id)
    while true do
        wait(0)
        if isKeyJustPressed(0x48) and not sampIsCursorActive() then
            sampSendChat('/opengate')
        end
    end
end

function probiv()
    lua_thread.create(function()
        setVirtualKeyDown(116, true)
        wait(5000)
        setVirtualKeyDown(116, false)
        sampSendChat('/id '..nick)
        sampAddChatMessage('Если пишет 0 id - введ /fixdefhelp', -1)
        wait(200)
        sampSendChat('/stats')
        sampSendChat('/stats')
        wait(3000)
        setVirtualKeyDown(27, true)
        wait(1)
        setVirtualKeyDown(27, false)
        wait(200)
        sampSendChat('/time')
        setVirtualKeyDown(9, true)
        wait(2000)
        setVirtualKeyDown(9, false)
        wait(2000)
        setVirtualKeyDown(27, true)
        wait(1)
        setVirtualKeyDown(27, false)
    end)
end

function fixprobiv()
    sampAddChatMessage('Успешно', -1)
    thisScript():reload()
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    for line in text:gmatch("[^\n]+") do -- разбиваем чтобы искать по строкам
        if line:find('Организация: %{......%}%[(.+)%]') then -- Поиск текста в строке. |  Пример строки Деньги в банке: [$21]
            org = line:match('Организация: %{......%}%[(.+)%]') -- запишет в переменную money цифру 21
            --sampAddChatMessage(org, -1) -- выведет в чат значение переменной money
        end
    end
    for line in text:gsub("{%x+}", ""):gmatch("[^\n]+") do
        if line:find("^Должность: .*$") then
            rang = line:match("^Должность: (.*%(%d+%))$")
            --sampAddChatMessage("Rang:" .. tostring(rang), -1)
        end
    end
end
В чем ошибка? Пишу /info, а окно не появляется, чет упустил мб?
 

хромиус)

спокойно, это всего лишь слива
Друг
4,960
3,232
Lua:
require('lib.moonloader')
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local sampev = require('lib.samp.events')

--imgui
local main_window_state = imgui.ImBool(false)

function imgui.OnDrawFrame()
    if main_window_state.v then
        local scrX, scrY = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(scrX / 2, scrY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5));
        imgui.SetNextWindowSize(imgui.ImVec2(600,400), imgui.Cond.FirstUseEver)
        imgui.Begin(u8'Информация', main_window_state)
        imgui.Text(u8'Ник: '..nick)  
        imgui.Text(u8'Организация: '..org)  
        imgui.Text(u8'Должность: '..rang)
        imgui.End()
    end
end

function main()
    while not isSampAvailable() do wait(0) end
        sampAddChatMessage('{663300}[Defens Helper] {FFFFFF}Скрипт успешно запущен', -1)
        sampAddChatMessage('{663300}[Defens Helper] {FFFFFF}Автор: Mark Bruskin | Версия: 1.0.0', -1)
        sampRegisterChatCommand('probiv', probiv)
        sampRegisterChatCommand('fixdefhelp', fixprobiv)
        sampRegisterChatCommand('info', function() main_window_state.v = not main_window_state.v end)
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        nick = sampGetPlayerNickname(id)
    while true do
        wait(0)
        if isKeyJustPressed(0x48) and not sampIsCursorActive() then
            sampSendChat('/opengate')
        end
    end
end

function probiv()
    lua_thread.create(function()
        setVirtualKeyDown(116, true)
        wait(5000)
        setVirtualKeyDown(116, false)
        sampSendChat('/id '..nick)
        sampAddChatMessage('Если пишет 0 id - введ /fixdefhelp', -1)
        wait(200)
        sampSendChat('/stats')
        sampSendChat('/stats')
        wait(3000)
        setVirtualKeyDown(27, true)
        wait(1)
        setVirtualKeyDown(27, false)
        wait(200)
        sampSendChat('/time')
        setVirtualKeyDown(9, true)
        wait(2000)
        setVirtualKeyDown(9, false)
        wait(2000)
        setVirtualKeyDown(27, true)
        wait(1)
        setVirtualKeyDown(27, false)
    end)
end

function fixprobiv()
    sampAddChatMessage('Успешно', -1)
    thisScript():reload()
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    for line in text:gmatch("[^\n]+") do -- разбиваем чтобы искать по строкам
        if line:find('Организация: %{......%}%[(.+)%]') then -- Поиск текста в строке. |  Пример строки Деньги в банке: [$21]
            org = line:match('Организация: %{......%}%[(.+)%]') -- запишет в переменную money цифру 21
            --sampAddChatMessage(org, -1) -- выведет в чат значение переменной money
        end
    end
    for line in text:gsub("{%x+}", ""):gmatch("[^\n]+") do
        if line:find("^Должность: .*$") then
            rang = line:match("^Должность: (.*%(%d+%))$")
            --sampAddChatMessage("Rang:" .. tostring(rang), -1)
        end
    end
end
В чем ошибка? Пишу /info, а окно не появляется, чет упустил мб?
покажи что в мейне
 

хромиус)

спокойно, это всего лишь слива
Друг
4,960
3,232
я весь код скрипта скинул
а,ну так ты даже окно не вызываешь ,там вроде а цикле надо imgui.Process что-то там
лучше переходи на мимгуи сразу без лишней ебатории
 
  • Нравится
Реакции: MLycoris и bruskin

bruskin

Участник
Автор темы
149
12
Lua:
require('lib.moonloader')
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local sampev = require('lib.samp.events')

--imgui
local main_window_state = imgui.ImBool(false)

function imgui.OnDrawFrame()
    if main_window_state.v then
        local scrX, scrY = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(scrX / 2, scrY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5));
        imgui.SetNextWindowSize(imgui.ImVec2(600,400), imgui.Cond.FirstUseEver)
        imgui.Begin(u8'Информация', main_window_state)
        imgui.Text(u8'Ник: '..nick)  
        imgui.Text(u8'Организация: '..org)  
        imgui.Text(u8'Должность: '..rang)
        imgui.End()
    end
end

function main()
    while not isSampAvailable() do wait(0) end
        sampAddChatMessage('{663300}[Defens Helper] {FFFFFF}Скрипт успешно запущен', -1)
        sampAddChatMessage('{663300}[Defens Helper] {FFFFFF}Автор: Mark Bruskin | Версия: 1.0.0', -1)
        sampRegisterChatCommand('probiv', probiv)
        sampRegisterChatCommand('fixdefhelp', fixprobiv)
        sampRegisterChatCommand('info', function() main_window_state.v = not main_window_state.v end)
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        nick = sampGetPlayerNickname(id)
    while true do
        wait(0)
        if isKeyJustPressed(0x48) and not sampIsCursorActive() then
            sampSendChat('/opengate')
        end
        imgui.Process = main_window_state.v
    end
end

function probiv()
    lua_thread.create(function()
        setVirtualKeyDown(116, true)
        wait(5000)
        setVirtualKeyDown(116, false)
        sampSendChat('/id '..nick)
        sampAddChatMessage('Если пишет 0 id - введ /fixdefhelp', -1)
        wait(200)
        sampSendChat('/stats')
        sampSendChat('/stats')
        wait(3000)
        setVirtualKeyDown(27, true)
        wait(1)
        setVirtualKeyDown(27, false)
        wait(200)
        sampSendChat('/time')
        setVirtualKeyDown(9, true)
        wait(2000)
        setVirtualKeyDown(9, false)
        wait(2000)
        setVirtualKeyDown(27, true)
        wait(1)
        setVirtualKeyDown(27, false)
    end)
end

function fixprobiv()
    sampAddChatMessage('Успешно', -1)
    thisScript():reload()
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    for line in text:gmatch("[^\n]+") do -- разбиваем чтобы искать по строкам
        if line:find('Организация: %{......%}%[(.+)%]') then -- Поиск текста в строке. |  Пример строки Деньги в банке: [$21]
            org = line:match('Организация: %{......%}%[(.+)%]') -- запишет в переменную money цифру 21
            --sampAddChatMessage(org, -1) -- выведет в чат значение переменной money
        end
    end
    for line in text:gsub("{%x+}", ""):gmatch("[^\n]+") do
        if line:find("^Должность: .*$") then
            rang = line:match("^Должность: (.*%(%d+%))$")
            --sampAddChatMessage("Rang:" .. tostring(rang), -1)
        end
    end
end
добавил imgui.Process, актуально