на второе открытие окна Imgui курсор зависает по середине

Cypher

Активный
Автор темы
224
55
Версия MoonLoader
.026-beta
Когда открываю окно имгуи впервые за сессию то всё работает нормально могу управлять курсором и камера не двигается (я про камеру которая третье лицо)
А когда запускаю имгуи второй раз то управляю курсором как будто в игре - а на имгуи похуй, нужно открывать чат чтобы курсор начал двигатся по окну имгуи

А и ещё почему то в имгуи инпут тексте по дефолту у меня высвечивается
1669122093322.png
знак вопросика, пологаю что то связанное с кодировкой но хз как исправить
1:
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local window = imgui.ImBool(false)


require 'lib.moonloader'
local sampev = require 'samp.events'
act = false
avto = false
zvyk = false
tovar = "аксы, ларцы, скины"
local tovarik = imgui.ImBuffer(1024)
thread = lua_thread.create_suspended(func)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("skyp", skyp)
    sampRegisterChatCommand('skyper', skyper)
    sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Загружен", -1)
    while true do
        wait(0)
        imgui.Process = window.v
        if window.v == true then
         imgui.ShowCursor = true
        else
         imgui.ShowCursor = false
        moneys = getPlayerMoney(PLAYER_HANDLE)
        money = math.ceil(moneys / 1000000) * 1000000
        if tovarik.v == "" then
         tovarik.v = tovar
        end
        if act == true then
        sampSendChat("/s Скупаю ".. tovarik.v .. " дорого Бюджет: ".. money)
        wait(8000)
        end
        end
      end
    end

local checked_test = imgui.ImBool(false)
local checked_test1 = imgui.ImBool(false)
local checked_test2 = imgui.ImBool(false)
local checked_radio = imgui.ImInt(1)

function imgui.OnDrawFrame()
   if window.v then
       imgui.SetNextWindowPos(imgui.ImVec2(800.0, 400.0), imgui.Cond.FirstUseEver)
       imgui.SetNextWindowSize(imgui.ImVec2(300.0, 360.0), imgui.Cond.FirstUseEver)
       imgui.Begin('Skyp.lua', window)
       if imgui.Checkbox(u8'Автопринятие трейда', checked_test) then
         avto = not avto
       end
       if imgui.Checkbox(u8'Звуковое оповещение при трейде', checked_test1) then
         zvyk = not zvyk
       end
       if imgui.Checkbox(u8'Автоскуп', checked_test2) then
         act = not act
       end
       if checked_test2.v then
         imgui.PushItemWidth(150)
         imgui.InputText(u8'Что скупаем?',tovarik)
       end
       imgui.End()
       end
      end



local SoundFile = getWorkingDirectory()..'\\resource\\TradeSound.mp3' -- файл со звуком
assert(doesFileExist(SoundFile), 'Файл "'..SoundFile..'" не найден!') -- крашим скрипт если файла нет
local Audio = loadAudioStream(SoundFile) -- загружаем звук




function sampev.onShowDialog(id, style, title, button1, button2, text)
   if zvyk == true then
      setAudioStreamState(Audio, 1) -- воспроизводим звук
      setAudioStreamVolume(Audio, 25)
   end
   if id == 8252 and avto == true then
      sampSendDialogResponse(id, 1, -1, nil)
      return false
   else
      sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Вы можете включить автопринятие трейда! {00FBFF}/skyper",-1)
   end
end
  
function apply_custom_style()
   imgui.SwitchContext()
   local style = imgui.GetStyle()
   local colors = style.Colors
   local clr = imgui.Col
   local ImVec4 = imgui.ImVec4
 
   style.WindowPadding = imgui.ImVec2(15, 15)
   style.WindowRounding = 1.5
   style.FramePadding = imgui.ImVec2(5, 5)
   style.FrameRounding = 4.0
   style.ItemSpacing = imgui.ImVec2(12, 8)
   style.ItemInnerSpacing = imgui.ImVec2(8, 6)
   style.IndentSpacing = 25.0
   style.ScrollbarSize = 15.0
   style.ScrollbarRounding = 9.0
   style.GrabMinSize = 5.0
   style.GrabRounding = 3.0
 
   colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
   colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
   colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
   colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
   colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
   colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
   colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
   colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
   colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
   colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
   colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
 end
 apply_custom_style()

   function skyper()
      window.v = not window.v
      imgui.Process = window.v
      end
 
Решение
А пон
Проблема в wait после отправки смс
Lua:
require ('lib.moonloader')
local sampev = require('samp.events')

local imgui = require('imgui')
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8

act,avto,zvyk = false,false,false
tovar = "аксы, ларцы, скины"
local timer = -1

local SoundFile = getWorkingDirectory()..'\\resource\\TradeSound.mp3' -- файл со звуком
assert(doesFileExist(SoundFile), 'Файл "'..SoundFile..'" не найден!') -- крашим скрипт если файла нет
local Audio = loadAudioStream(SoundFile) -- загружаем звук

local window = imgui.ImBool(false)
local checked_test = imgui.ImBool(false)
local checked_test1 = imgui.ImBool(false)
local checked_test2 = imgui.ImBool(false)...

qdIbp

Автор темы
Проверенный
1,386
1,141
Так?

Lua:
require ('lib.moonloader')
local sampev = require('samp.events')

local imgui = require('imgui')
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8

act,avto,zvyk = false,false,false
tovar = "аксы, ларцы, скины"

local SoundFile = getWorkingDirectory()..'\\resource\\TradeSound.mp3' -- файл со звуком
assert(doesFileExist(SoundFile), 'Файл "'..SoundFile..'" не найден!') -- крашим скрипт если файла нет
local Audio = loadAudioStream(SoundFile) -- загружаем звук

local window = imgui.ImBool(false)
local checked_test = imgui.ImBool(false)
local checked_test1 = imgui.ImBool(false)
local checked_test2 = imgui.ImBool(false)
local checked_radio = imgui.ImInt(1)
local tovarik = imgui.ImBuffer(1024)
thread = lua_thread.create_suspended(func)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("skyp", skyp)
    sampRegisterChatCommand('skyper', function() window.v = not window.v end)
    sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Загружен", -1)
    while true do wait(0)
        imgui.Process = window.v
        imgui.ShowCursor = window.v
        
        if not window.v then
            moneys = getPlayerMoney(PLAYER_HANDLE)
            money = math.ceil(moneys / 1000000) * 1000000
            if tovarik.v == "" then
                tovarik = imgui.ImBuffer(u8(tovar),1024)    
            end
            if act then
                sampSendChat("/s Скупаю ".. tovarik.v .. " дорого Бюджет: ".. money)
                wait(8000)
            end
        end
    end
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(800.0, 400.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(300.0, 360.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Skyp.lua', window)
            if imgui.Checkbox(u8'Автопринятие трейда', checked_test) then
                avto = not avto
            end
            if imgui.Checkbox(u8'Звуковое оповещение при трейде', checked_test1) then
                zvyk = not zvyk
            end
            if imgui.Checkbox(u8'Автоскуп', checked_test2) then
                act = not act
            end
            if checked_test2.v then
                imgui.PushItemWidth(150)
                imgui.InputText(u8'Что скупаем?',tovarik)
            end
        imgui.End()
    end
end

function sampev.onShowDialog(id, style, title, button1, button2, text)
    if zvyk then
        setAudioStreamState(Audio, 1) -- воспроизводим звук
        setAudioStreamVolume(Audio, 25)
    end
    if id == 8252 and avto then
        sampSendDialogResponse(id, 1, -1, nil)
        return false
    else
        sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Вы можете включить автопринятие трейда! {00FBFF}/skyper",-1)
    end
end
  
function apply_custom_style()
   imgui.SwitchContext()
   local style = imgui.GetStyle()
   local colors = style.Colors
   local clr = imgui.Col
   local ImVec4 = imgui.ImVec4
 
   style.WindowPadding = imgui.ImVec2(15, 15)
   style.WindowRounding = 1.5
   style.FramePadding = imgui.ImVec2(5, 5)
   style.FrameRounding = 4.0
   style.ItemSpacing = imgui.ImVec2(12, 8)
   style.ItemInnerSpacing = imgui.ImVec2(8, 6)
   style.IndentSpacing = 25.0
   style.ScrollbarSize = 15.0
   style.ScrollbarRounding = 9.0
   style.GrabMinSize = 5.0
   style.GrabRounding = 3.0
 
   colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
   colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
   colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
   colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
   colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
   colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
   colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
   colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
   colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
   colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
   colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
 end
 apply_custom_style()

Но если в imgui ты хочешь принимать значение чекбоксов то делать лучше так
Lua:
function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(800.0, 400.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(300.0, 360.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Skyp.lua', window)
            if imgui.Checkbox(u8'Автопринятие трейда', checked_test) then
                avto = checked_test.v
            end
            if imgui.Checkbox(u8'Звуковое оповещение при трейде', checked_test1) then
                zvyk = checked_test1.v
            end
            if imgui.Checkbox(u8'Автоскуп', checked_test2) then
                act = checked_test2.v
            end
            if checked_test2.v then
                imgui.PushItemWidth(150)
                imgui.InputText(u8'Что скупаем?',tovarik)
            end
        imgui.End()
    end
end
 

Cypher

Активный
Автор темы
224
55
Так?

Lua:
require ('lib.moonloader')
local sampev = require('samp.events')

local imgui = require('imgui')
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8

act,avto,zvyk = false,false,false
tovar = "аксы, ларцы, скины"

local SoundFile = getWorkingDirectory()..'\\resource\\TradeSound.mp3' -- файл со звуком
assert(doesFileExist(SoundFile), 'Файл "'..SoundFile..'" не найден!') -- крашим скрипт если файла нет
local Audio = loadAudioStream(SoundFile) -- загружаем звук

local window = imgui.ImBool(false)
local checked_test = imgui.ImBool(false)
local checked_test1 = imgui.ImBool(false)
local checked_test2 = imgui.ImBool(false)
local checked_radio = imgui.ImInt(1)
local tovarik = imgui.ImBuffer(1024)
thread = lua_thread.create_suspended(func)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("skyp", skyp)
    sampRegisterChatCommand('skyper', function() window.v = not window.v end)
    sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Загружен", -1)
    while true do wait(0)
        imgui.Process = window.v
        imgui.ShowCursor = window.v
       
        if not window.v then
            moneys = getPlayerMoney(PLAYER_HANDLE)
            money = math.ceil(moneys / 1000000) * 1000000
            if tovarik.v == "" then
                tovarik = imgui.ImBuffer(u8(tovar),1024)   
            end
            if act then
                sampSendChat("/s Скупаю ".. tovarik.v .. " дорого Бюджет: ".. money)
                wait(8000)
            end
        end
    end
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(800.0, 400.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(300.0, 360.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Skyp.lua', window)
            if imgui.Checkbox(u8'Автопринятие трейда', checked_test) then
                avto = not avto
            end
            if imgui.Checkbox(u8'Звуковое оповещение при трейде', checked_test1) then
                zvyk = not zvyk
            end
            if imgui.Checkbox(u8'Автоскуп', checked_test2) then
                act = not act
            end
            if checked_test2.v then
                imgui.PushItemWidth(150)
                imgui.InputText(u8'Что скупаем?',tovarik)
            end
        imgui.End()
    end
end

function sampev.onShowDialog(id, style, title, button1, button2, text)
    if zvyk then
        setAudioStreamState(Audio, 1) -- воспроизводим звук
        setAudioStreamVolume(Audio, 25)
    end
    if id == 8252 and avto then
        sampSendDialogResponse(id, 1, -1, nil)
        return false
    else
        sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Вы можете включить автопринятие трейда! {00FBFF}/skyper",-1)
    end
end
 
function apply_custom_style()
   imgui.SwitchContext()
   local style = imgui.GetStyle()
   local colors = style.Colors
   local clr = imgui.Col
   local ImVec4 = imgui.ImVec4
 
   style.WindowPadding = imgui.ImVec2(15, 15)
   style.WindowRounding = 1.5
   style.FramePadding = imgui.ImVec2(5, 5)
   style.FrameRounding = 4.0
   style.ItemSpacing = imgui.ImVec2(12, 8)
   style.ItemInnerSpacing = imgui.ImVec2(8, 6)
   style.IndentSpacing = 25.0
   style.ScrollbarSize = 15.0
   style.ScrollbarRounding = 9.0
   style.GrabMinSize = 5.0
   style.GrabRounding = 3.0
 
   colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
   colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
   colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
   colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
   colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
   colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
   colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
   colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
   colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
   colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
   colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
 end
 apply_custom_style()

Но если в imgui ты хочешь принимать значение чекбоксов то делать лучше так
Lua:
function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(800.0, 400.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(300.0, 360.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Skyp.lua', window)
            if imgui.Checkbox(u8'Автопринятие трейда', checked_test) then
                avto = checked_test.v
            end
            if imgui.Checkbox(u8'Звуковое оповещение при трейде', checked_test1) then
                zvyk = checked_test1.v
            end
            if imgui.Checkbox(u8'Автоскуп', checked_test2) then
                act = checked_test2.v
            end
            if checked_test2.v then
                imgui.PushItemWidth(150)
                imgui.InputText(u8'Что скупаем?',tovarik)
            end
        imgui.End()
    end
end
Cмотри, мне не нужен полностью переписанный код, мне просто нужно узнать почему на второе открытие имгуи окна курсор застряет по середине пока я на Ф6 не тыкну
 

Cypher

Активный
Автор темы
224
55
Как понять втором окне, если у тя одно окно?
На второе открытие окна ане во втором окне
/skyp открыл окно 1 раз, всё ок курсор как обычно
закрыл окно
Потом ещё раз открыл окно /skyp и курсор зависает по середине и двигает камеру персонажа, при этом будучи центрированым

Я ещё заметил такую особенность что если инпутекста имгуи не видно или курсор на него не наведен тогда ниче не зависает

А нет, курсор может быть даже не наведен в середину где инпуттекст имгуи и всё равно будет центрирован
 

qdIbp

Автор темы
Проверенный
1,386
1,141
Lua:
require ('lib.moonloader')
local sampev = require('samp.events')

local imgui = require('imgui')
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8

act,avto,zvyk = false,false,false
tovar = "аксы, ларцы, скины"

local SoundFile = getWorkingDirectory()..'\\resource\\TradeSound.mp3' -- файл со звуком
assert(doesFileExist(SoundFile), 'Файл "'..SoundFile..'" не найден!') -- крашим скрипт если файла нет
local Audio = loadAudioStream(SoundFile) -- загружаем звук

local wind = imgui.ImBool(false)
local window = imgui.ImBool(false)
local checked_test = imgui.ImBool(false)
local checked_test1 = imgui.ImBool(false)
local checked_test2 = imgui.ImBool(false)
local checked_radio = imgui.ImInt(1)
local tovarik = imgui.ImBuffer(1024)
thread = lua_thread.create_suspended(func)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("skyp", function() wind.v = not wind.v end)
    sampRegisterChatCommand('skyper', function() window.v = not window.v end)
    sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Загружен", -1)
    while true do wait(0)
        imgui.Process = window.v or wind.v
        imgui.ShowCursor = window.v or wind.v
       
        if not window.v then
            moneys = getPlayerMoney(PLAYER_HANDLE)
            money = math.ceil(moneys / 1000000) * 1000000
            if tovarik.v == "" then
                tovarik = imgui.ImBuffer(u8(tovar),1024)  
            end
            if act then
                sampSendChat("/s Скупаю ".. tovarik.v .. " дорого Бюджет: ".. money)
                wait(8000)
            end
        end
    end
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(800.0, 400.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(300.0, 360.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Skyp.lua', window)
            if imgui.Checkbox(u8'Автопринятие трейда', checked_test) then
                avto = not avto
            end
            if imgui.Checkbox(u8'Звуковое оповещение при трейде', checked_test1) then
                zvyk = not zvyk
            end
            if imgui.Checkbox(u8'Автоскуп', checked_test2) then
                act = not act
            end
            if checked_test2.v then
                imgui.PushItemWidth(150)
                imgui.InputText(u8'Что скупаем?',tovarik)
            end
        imgui.End()
    end
    if wind.v then
        imgui.Begin('Skyp2.lua', wind)
            imgui.Text('da')
        imgui.End()
    end
end

function sampev.onShowDialog(id, style, title, button1, button2, text)
    if zvyk then
        setAudioStreamState(Audio, 1) -- воспроизводим звук
        setAudioStreamVolume(Audio, 25)
    end
    if id == 8252 and avto then
        sampSendDialogResponse(id, 1, -1, nil)
        return false
    else
        sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Вы можете включить автопринятие трейда! {00FBFF}/skyper",-1)
    end
end
 
function apply_custom_style()
   imgui.SwitchContext()
   local style = imgui.GetStyle()
   local colors = style.Colors
   local clr = imgui.Col
   local ImVec4 = imgui.ImVec4
 
   style.WindowPadding = imgui.ImVec2(15, 15)
   style.WindowRounding = 1.5
   style.FramePadding = imgui.ImVec2(5, 5)
   style.FrameRounding = 4.0
   style.ItemSpacing = imgui.ImVec2(12, 8)
   style.ItemInnerSpacing = imgui.ImVec2(8, 6)
   style.IndentSpacing = 25.0
   style.ScrollbarSize = 15.0
   style.ScrollbarRounding = 9.0
   style.GrabMinSize = 5.0
   style.GrabRounding = 3.0
 
   colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
   colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
   colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
   colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
   colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
   colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
   colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
   colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
   colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
   colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
   colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
 end
 apply_custom_style()
 

Cypher

Активный
Автор темы
224
55
Lua:
require ('lib.moonloader')
local sampev = require('samp.events')

local imgui = require('imgui')
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8

act,avto,zvyk = false,false,false
tovar = "аксы, ларцы, скины"

local SoundFile = getWorkingDirectory()..'\\resource\\TradeSound.mp3' -- файл со звуком
assert(doesFileExist(SoundFile), 'Файл "'..SoundFile..'" не найден!') -- крашим скрипт если файла нет
local Audio = loadAudioStream(SoundFile) -- загружаем звук

local wind = imgui.ImBool(false)
local window = imgui.ImBool(false)
local checked_test = imgui.ImBool(false)
local checked_test1 = imgui.ImBool(false)
local checked_test2 = imgui.ImBool(false)
local checked_radio = imgui.ImInt(1)
local tovarik = imgui.ImBuffer(1024)
thread = lua_thread.create_suspended(func)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("skyp", function() wind.v = not wind.v end)
    sampRegisterChatCommand('skyper', function() window.v = not window.v end)
    sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Загружен", -1)
    while true do wait(0)
        imgui.Process = window.v or wind.v
        imgui.ShowCursor = window.v or wind.v
       
        if not window.v then
            moneys = getPlayerMoney(PLAYER_HANDLE)
            money = math.ceil(moneys / 1000000) * 1000000
            if tovarik.v == "" then
                tovarik = imgui.ImBuffer(u8(tovar),1024)  
            end
            if act then
                sampSendChat("/s Скупаю ".. tovarik.v .. " дорого Бюджет: ".. money)
                wait(8000)
            end
        end
    end
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(800.0, 400.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(300.0, 360.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Skyp.lua', window)
            if imgui.Checkbox(u8'Автопринятие трейда', checked_test) then
                avto = not avto
            end
            if imgui.Checkbox(u8'Звуковое оповещение при трейде', checked_test1) then
                zvyk = not zvyk
            end
            if imgui.Checkbox(u8'Автоскуп', checked_test2) then
                act = not act
            end
            if checked_test2.v then
                imgui.PushItemWidth(150)
                imgui.InputText(u8'Что скупаем?',tovarik)
            end
        imgui.End()
    end
    if wind.v then
        imgui.Begin('Skyp2.lua', wind)
            imgui.Text('da')
        imgui.End()
    end
end



function sampev.onShowDialog(id, style, title, button1, button2, text)
    if zvyk then
        setAudioStreamState(Audio, 1) -- воспроизводим звук
        setAudioStreamVolume(Audio, 25)
    end
    if id == 8252 and avto then
        sampSendDialogResponse(id, 1, -1, nil)
        return false
    else
        sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Вы можете включить автопринятие трейда! {00FBFF}/skyper",-1)
    end
end
 
function apply_custom_style()
   imgui.SwitchContext()
   local style = imgui.GetStyle()
   local colors = style.Colors
   local clr = imgui.Col
   local ImVec4 = imgui.ImVec4
 
   style.WindowPadding = imgui.ImVec2(15, 15)
   style.WindowRounding = 1.5
   style.FramePadding = imgui.ImVec2(5, 5)
   style.FrameRounding = 4.0
   style.ItemSpacing = imgui.ImVec2(12, 8)
   style.ItemInnerSpacing = imgui.ImVec2(8, 6)
   style.IndentSpacing = 25.0
   style.ScrollbarSize = 15.0
   style.ScrollbarRounding = 9.0
   style.GrabMinSize = 5.0
   style.GrabRounding = 3.0
 
   colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
   colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
   colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
   colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
   colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
   colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
   colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
   colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
   colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
   colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
   colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
 end
 apply_custom_style()
Cмотри, мне не нужен полностью переписанный код, мне просто нужно узнать почему на второе открытие имгуи окна курсор застряет по середине пока я на Ф6 не тыкну
 
  • Вау
Реакции: qdIbp

qdIbp

Автор темы
Проверенный
1,386
1,141
а все пон пон, я дятел прост
Так?

Lua:
require ('lib.moonloader')
local sampev = require('samp.events')

local imgui = require('imgui')
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8

act,avto,zvyk = false,false,false
tovar = "аксы, ларцы, скины"

local SoundFile = getWorkingDirectory()..'\\resource\\TradeSound.mp3' -- файл со звуком
assert(doesFileExist(SoundFile), 'Файл "'..SoundFile..'" не найден!') -- крашим скрипт если файла нет
local Audio = loadAudioStream(SoundFile) -- загружаем звук

local window = imgui.ImBool(false)
local checked_test = imgui.ImBool(false)
local checked_test1 = imgui.ImBool(false)
local checked_test2 = imgui.ImBool(false)
local checked_radio = imgui.ImInt(1)
local tovarik = imgui.ImBuffer(1024)
thread = lua_thread.create_suspended(func)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("skyp", skyp)
    sampRegisterChatCommand('skyper', function() window.v = not window.v end)
    sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Загружен", -1)
    while true do wait(0)
        imgui.Process = window.v
        imgui.ShowCursor = window.v
       
        if not window.v then
            moneys = getPlayerMoney(PLAYER_HANDLE)
            money = math.ceil(moneys / 1000000) * 1000000
            if tovarik.v == "" then
                tovarik = imgui.ImBuffer(u8(tovar),1024)   
            end
            if act then
                sampSendChat("/s Скупаю ".. tovarik.v .. " дорого Бюджет: ".. money)
                wait(8000)
            end
        end
    end
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(800.0, 400.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(300.0, 360.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Skyp.lua', window)
            if imgui.Checkbox(u8'Автопринятие трейда', checked_test) then
                avto = not avto
            end
            if imgui.Checkbox(u8'Звуковое оповещение при трейде', checked_test1) then
                zvyk = not zvyk
            end
            if imgui.Checkbox(u8'Автоскуп', checked_test2) then
                act = not act
            end
            if checked_test2.v then
                imgui.PushItemWidth(150)
                imgui.InputText(u8'Что скупаем?',tovarik)
            end
        imgui.End()
    end
end

function sampev.onShowDialog(id, style, title, button1, button2, text)
    if zvyk then
        setAudioStreamState(Audio, 1) -- воспроизводим звук
        setAudioStreamVolume(Audio, 25)
    end
    if id == 8252 and avto then
        sampSendDialogResponse(id, 1, -1, nil)
        return false
    else
        sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Вы можете включить автопринятие трейда! {00FBFF}/skyper",-1)
    end
end
 
function apply_custom_style()
   imgui.SwitchContext()
   local style = imgui.GetStyle()
   local colors = style.Colors
   local clr = imgui.Col
   local ImVec4 = imgui.ImVec4
 
   style.WindowPadding = imgui.ImVec2(15, 15)
   style.WindowRounding = 1.5
   style.FramePadding = imgui.ImVec2(5, 5)
   style.FrameRounding = 4.0
   style.ItemSpacing = imgui.ImVec2(12, 8)
   style.ItemInnerSpacing = imgui.ImVec2(8, 6)
   style.IndentSpacing = 25.0
   style.ScrollbarSize = 15.0
   style.ScrollbarRounding = 9.0
   style.GrabMinSize = 5.0
   style.GrabRounding = 3.0
 
   colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
   colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
   colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
   colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
   colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
   colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
   colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
   colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
   colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
   colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
   colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
 end
 apply_custom_style()

Но если в imgui ты хочешь принимать значение чекбоксов то делать лучше так
Lua:
function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(800.0, 400.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(300.0, 360.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Skyp.lua', window)
            if imgui.Checkbox(u8'Автопринятие трейда', checked_test) then
                avto = checked_test.v
            end
            if imgui.Checkbox(u8'Звуковое оповещение при трейде', checked_test1) then
                zvyk = checked_test1.v
            end
            if imgui.Checkbox(u8'Автоскуп', checked_test2) then
                act = checked_test2.v
            end
            if checked_test2.v then
                imgui.PushItemWidth(150)
                imgui.InputText(u8'Что скупаем?',tovarik)
            end
        imgui.End()
    end
end
т.к. ты с imgui намудрил
Тут уже нету такой проблемы

По крайней мере как ты описал проблему я не вывел

Когда открываю окно имгуи впервые за сессию то всё работает нормально могу управлять курсором и камера не двигается (я про камеру которая третье лицо)
А когда запускаю имгуи второй раз то управляю курсором как будто в игре - а на имгуи похуй, нужно открывать чат чтобы курсор начал двигатся по окну имгуи

А и ещё почему то в имгуи инпут тексте по дефолту у меня высвечивается Посмотреть вложение 178858знак вопросика, пологаю что то связанное с кодировкой но хз как исправить
1:
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local window = imgui.ImBool(false)


require 'lib.moonloader'
local sampev = require 'samp.events'
act = false
avto = false
zvyk = false
tovar = "аксы, ларцы, скины"
local tovarik = imgui.ImBuffer(1024)
thread = lua_thread.create_suspended(func)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("skyp", skyp)
    sampRegisterChatCommand('skyper', skyper)
    sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Загружен", -1)
    while true do
        wait(0)
        imgui.Process = window.v
        if window.v == true then
         imgui.ShowCursor = true
        else
         imgui.ShowCursor = false
        moneys = getPlayerMoney(PLAYER_HANDLE)
        money = math.ceil(moneys / 1000000) * 1000000
        if tovarik.v == "" then
         tovarik.v = tovar
        end
        if act == true then
        sampSendChat("/s Скупаю ".. tovarik.v .. " дорого Бюджет: ".. money)
        wait(8000)
        end
        end
      end
    end

local checked_test = imgui.ImBool(false)
local checked_test1 = imgui.ImBool(false)
local checked_test2 = imgui.ImBool(false)
local checked_radio = imgui.ImInt(1)

function imgui.OnDrawFrame()
   if window.v then
       imgui.SetNextWindowPos(imgui.ImVec2(800.0, 400.0), imgui.Cond.FirstUseEver)
       imgui.SetNextWindowSize(imgui.ImVec2(300.0, 360.0), imgui.Cond.FirstUseEver)
       imgui.Begin('Skyp.lua', window)
       if imgui.Checkbox(u8'Автопринятие трейда', checked_test) then
         avto = not avto
       end
       if imgui.Checkbox(u8'Звуковое оповещение при трейде', checked_test1) then
         zvyk = not zvyk
       end
       if imgui.Checkbox(u8'Автоскуп', checked_test2) then
         act = not act
       end
       if checked_test2.v then
         imgui.PushItemWidth(150)
         imgui.InputText(u8'Что скупаем?',tovarik)
       end
       imgui.End()
       end
      end



local SoundFile = getWorkingDirectory()..'\\resource\\TradeSound.mp3' -- файл со звуком
assert(doesFileExist(SoundFile), 'Файл "'..SoundFile..'" не найден!') -- крашим скрипт если файла нет
local Audio = loadAudioStream(SoundFile) -- загружаем звук




function sampev.onShowDialog(id, style, title, button1, button2, text)
   if zvyk == true then
      setAudioStreamState(Audio, 1) -- воспроизводим звук
      setAudioStreamVolume(Audio, 25)
   end
   if id == 8252 and avto == true then
      sampSendDialogResponse(id, 1, -1, nil)
      return false
   else
      sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Вы можете включить автопринятие трейда! {00FBFF}/skyper",-1)
   end
end
 
function apply_custom_style()
   imgui.SwitchContext()
   local style = imgui.GetStyle()
   local colors = style.Colors
   local clr = imgui.Col
   local ImVec4 = imgui.ImVec4
 
   style.WindowPadding = imgui.ImVec2(15, 15)
   style.WindowRounding = 1.5
   style.FramePadding = imgui.ImVec2(5, 5)
   style.FrameRounding = 4.0
   style.ItemSpacing = imgui.ImVec2(12, 8)
   style.ItemInnerSpacing = imgui.ImVec2(8, 6)
   style.IndentSpacing = 25.0
   style.ScrollbarSize = 15.0
   style.ScrollbarRounding = 9.0
   style.GrabMinSize = 5.0
   style.GrabRounding = 3.0
 
   colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
   colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
   colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
   colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
   colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
   colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
   colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
   colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
   colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
   colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
   colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
 end
 apply_custom_style()

   function skyper()
      window.v = not window.v
      imgui.Process = window.v
      end
хотя не даже тут нету такой проблемы :\

Походу я ультромегатуп стал :(
 

Cypher

Активный
Автор темы
224
55
а все пон пон, я дятел прост

т.к. ты с imgui намудрил
Тут уже нету такой проблемы

По крайней мере как ты описал проблему я не вывел
Короче - на второе открытие имгуи окна просто пропадает курсор и я двигаю камерой перса
Это вкратце проблема
 

Cypher

Активный
Автор темы
224
55
Ты что нибудь еще делаешь по мимо открытия окна, потому что у меня с твоим кодом нету таких проблем, я всю клаву затеребил но не добился такого же результата

на 0:29 последствия того что у меня убирание курсора в мейне где задержка на каждое выполнение по 8секунд, так что курсор там проверяется каждые 8 сек, хз как исправить
 
  • Вау
Реакции: qdIbp

qdIbp

Автор темы
Проверенный
1,386
1,141
А пон
Проблема в wait после отправки смс
Lua:
require ('lib.moonloader')
local sampev = require('samp.events')

local imgui = require('imgui')
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8

act,avto,zvyk = false,false,false
tovar = "аксы, ларцы, скины"
local timer = -1

local SoundFile = getWorkingDirectory()..'\\resource\\TradeSound.mp3' -- файл со звуком
assert(doesFileExist(SoundFile), 'Файл "'..SoundFile..'" не найден!') -- крашим скрипт если файла нет
local Audio = loadAudioStream(SoundFile) -- загружаем звук

local window = imgui.ImBool(false)
local checked_test = imgui.ImBool(false)
local checked_test1 = imgui.ImBool(false)
local checked_test2 = imgui.ImBool(false)
local checked_radio = imgui.ImInt(1)
local tovarik = imgui.ImBuffer(1024)
thread = lua_thread.create_suspended(func)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("skyp", skyp)
    sampRegisterChatCommand('skyper', function() window.v = not window.v end)
    sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Загружен", -1)
    while true do wait(0)
        imgui.Process = window.v
        imgui.ShowCursor = window.v
     
        if not window.v then
            moneys = getPlayerMoney(PLAYER_HANDLE)
            money = math.ceil(moneys / 1000000) * 1000000
        end
        if tovarik.v == "" then
            tovarik = imgui.ImBuffer(u8(tovar),1024)
        end
        if act then
            if timer < os.time() then
                sampSendChat("/c /s Скупаю ".. u8:decode(tovarik.v) .. " дорого Бюджет: ".. money)
                timer = os.time() + 8 -- 8 cek
            end
        end
    end
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(800.0, 400.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(300.0, 360.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Skyp.lua', window)
            if imgui.Checkbox(u8'Автопринятие трейда', checked_test) then
                avto = not avto
            end
            if imgui.Checkbox(u8'Звуковое оповещение при трейде', checked_test1) then
                zvyk = not zvyk
            end
            if imgui.Checkbox(u8'Автоскуп', checked_test2) then
                act = not act
            end
            if checked_test2.v then
                imgui.PushItemWidth(150)
                imgui.InputText(u8'Что скупаем?',tovarik)
            end
        imgui.End()
    end
end

function sampev.onShowDialog(id, style, title, button1, button2, text)
    if zvyk then
        setAudioStreamState(Audio, 1) -- воспроизводим звук
        setAudioStreamVolume(Audio, 25)
    end
    if id == 8252 and avto then
        sampSendDialogResponse(id, 1, -1, nil)
        return false
    else
        sampAddChatMessage("{00FBFF}[Skyp.lua]:{FFFFFF} Вы можете включить автопринятие трейда! {00FBFF}/skyper",-1)
    end
end
 
function apply_custom_style()
   imgui.SwitchContext()
   local style = imgui.GetStyle()
   local colors = style.Colors
   local clr = imgui.Col
   local ImVec4 = imgui.ImVec4
 
   style.WindowPadding = imgui.ImVec2(15, 15)
   style.WindowRounding = 1.5
   style.FramePadding = imgui.ImVec2(5, 5)
   style.FrameRounding = 4.0
   style.ItemSpacing = imgui.ImVec2(12, 8)
   style.ItemInnerSpacing = imgui.ImVec2(8, 6)
   style.IndentSpacing = 25.0
   style.ScrollbarSize = 15.0
   style.ScrollbarRounding = 9.0
   style.GrabMinSize = 5.0
   style.GrabRounding = 3.0
 
   colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
   colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
   colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
   colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
   colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
   colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
   colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
   colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
   colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
   colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
   colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
   colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
   colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
   colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
   colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
   colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
   colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
   colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
   colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
 end
 apply_custom_style()