Отключение imgui окон при выходе из рекона.

Mico

Активный
Автор темы
252
50
Версия MoonLoader
.026-beta
Когда я захожу в рекон у меня появляются окна. Мне нужно, чтобы они пропадали когда я выхожу.

+Кто знает, как сделать, чтобы на клавишу допустим R, появлялся курсор.
 

thebestsupreme

Участник
170
13
Надо чутка подправить
Если что пиши фиксану


CODE:
require "lib.moonloader"
local samp = require 'lib.samp.events'
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local ReconWindow = imgui.ImBool(false)

local ToScreen = convertGameScreenCoordsToWindowScreenCoords

local spec_id = -1

local rInfo = {
    state = false,
    id = -1,
}

function main()
    while not  isSampAvailable() do wait(100) end
   
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    name = sampGetPlayerNickname(id)

    while true do
        wait(0)
       
        imgui.Process = ReconWindow.v
        if not ReconWindow.v then
            imgui.Process = false
        end  
    end
end

function imgui.OnDrawFrame()

if ReconWindow.v then

    if isKeyJustPressed(VK_RBUTTON) and not sampIsChatInputActive() and not sampIsDialogActive() then
        imgui.ShowCursor = not imgui.ShowCursor
    end

    local isPed ,pPed = sampGetCharHandleBySampPlayerId(spec_id)
   
    if isPed then  
        spec_nick = sampGetPlayerNickname(spec_id)
        spec_score = sampGetPlayerScore(spec_id)
        spec_ping = sampGetPlayerPing(spec_id)
        spec_hp = sampGetPlayerHealth(spec_id)
        spec_armor = sampGetPlayerArmor(spec_id)
        spec_skin = getCharModel(pPed)
    end

    local ex, ey = getScreenResolution()
    imgui.SetNextWindowPos(imgui.ImVec2(400, 500), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowSize(imgui.ImVec2(0, 0), imgui.Cond.FirstUseEver)
    imgui.Begin("", _, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove + imgui.WindowFlags.NoTitleBar)
   
    if imgui.Button(u8'<- BACK', imgui.ImVec2(100,0)) then
        lua_thread.create(function()
            wait(1200)
            sampSendChat('/re '..spec_id-1)
        end)
    end
   
    imgui.SameLine()
   
    if imgui.Button(u8'REOFF', imgui.ImVec2(150,0)) then
        lua_thread.create(function()
        wait(1200)
            sampSendChat("/reoff")
        end)
    end
   
    imgui.SameLine()
   
    if imgui.Button(u8'UPDATE', imgui.ImVec2(150,0)) then
        lua_thread.create(function()
            wait(1200)
            ampSendChat("/re "..spec_id)
        end)
    end
   
    imgui.SameLine()
   
    if imgui.Button(u8'NEXT ->', imgui.ImVec2(100,0)) then
        lua_thread.create(function()
            wait(1200)
            sampSendChat('/re '..spec_id+1)
        end)
    end
   
    imgui.Separator()
   
    imgui.End()
   
    local ex, ey = getScreenResolution()
    imgui.SetNextWindowPos(imgui.ImVec2(20, 400), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowSize(imgui.ImVec2(0, 0), imgui.Cond.FirstUseEver)
    imgui.Begin(u8'Меню наказаний', nil, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove + imgui.WindowFlags.NoCollapse)
    if imgui.Button(u8'JAIL', imgui.ImVec2(100,0)) then
        imgui.OpenPopup(u8"JAIL")
    end
    if imgui.BeginPopupModal(u8"JAIL", _, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove) then
        if imgui.Button(u8'Закрыть', bsize) then
            imgui.CloseCurrentPopup()
        end
        imgui.EndPopup()
    end
    imgui.End()
   
    local ex, ey = getScreenResolution()
    imgui.SetNextWindowPos(imgui.ImVec2(980, 400), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowSize(imgui.ImVec2(0, 0), imgui.Cond.FirstUseEver)
    imgui.Begin(u8'Статистика на '.. spec_nick ..'['.. spec_id ..']', nil, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove + imgui.WindowFlags.NoCollapse)
   
        imgui.BeginChild("ReconPlayer", imgui.ImVec2(350, 250), true)
       
            if isPed and doesCharExist(pPed) then
       
                imgui.Columns(2, "Recon", true)

                imgui.Text(u8'Имя : '.. spec_nick)
               
                imgui.NextColumn()
               
                imgui.Text(u8'Уровень : '.. spec_score)
               
                imgui.NextColumn()
                imgui.Separator()
               
                imgui.Text(u8'Пинг : '.. spec_ping)
               
                imgui.NextColumn()
               
                imgui.Text(u8'Здоровье : '.. spec_hp)
               
                imgui.NextColumn()
                imgui.Separator()
               
                imgui.Text(u8'Броня : '.. spec_armor)
               
                imgui.NextColumn()
               
                imgui.Text(u8'Скин : '.. spec_skin)
               
                imgui.NextColumn()
                imgui.Separator()
               
                imgui.Columns(1)
           
            else
           
                imgui.CenterText(u8'Вы следите за ботом!\nВозможно это баг нажмите на UPDATE')
           
            end
   
        imgui.EndChild()
   
    end
    imgui.End()
   
end

function imgui.CenterText(text)
    local width = imgui.GetWindowWidth()
    local calc = imgui.CalcTextSize(text)
    imgui.SetCursorPosX( width / 2 - calc.x / 2 )
    imgui.Text(text)
end

function samp.onSendCommand(param)
    if param:find('reoff') then
        ReconWindow.v = false
    end
    if param:match('re (%d+)') then
        spec_id = param:match('re (%d+)')
    end
end

function samp.onTogglePlayerSpectating(state)
    if spec_id ~= -1 then
        ReconWindow.v = state
    end
   
end

function samp.onShowTextDraw(id, data)
    if rInfo.id ~= -1 then
        lua_thread.create(function()
            while true do
                wait(0)
                if data.text:find('.*') then
                    sampTextdrawDelete(id)
                end
            end
        end)
    end
end

function samp.onShowMenu()
    if ReconWindow.v then
        return false
    end
end

function samp.onHideMenu()
    if ReconWindow.v then
        return false
    end
end

function getNick(id)
    nick = sampGetPlayerNickname(id)
    return nick
end

function blue()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    style.Alpha = 1.00

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0

    colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.TitleBg]                = ImVec4(0.16, 0.29, 0.48, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.29, 0.48, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.52, 0.88, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.Button]                 = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
    colors[clr.Header]                 = ImVec4(0.26, 0.59, 0.98, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.26, 0.59, 0.98, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.26, 0.59, 0.98, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.59, 0.98, 0.95)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.WindowBg]               = ImVec4(0.06, 0.06, 0.06, 0.94)
    colors[clr.ChildWindowBg]          = ImVec4(1.00, 1.00, 1.00, 0.00)
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 1.00)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 0.50)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
    colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
end
blue()

Если хочешь сказать спасибо то, с тебя лайк
 
  • Нравится
Реакции: SatooIM