Пытаюсь сделать простой сбив, но он не работает

dexxx.

Новичок
Автор темы
2
1
Версия MoonLoader
Другое
Начал учить луа, пытаюсь сделать простой сбив для начала, но он не работает
 

Вложения

  • !test.lua
    7.6 KB · Просмотры: 1

qdIbp

Автор темы
Проверенный
1,436
1,176
Lua:
local imgui = require('mimgui')
local ffi = require('ffi')

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

local new = imgui.new
local WinState = new.bool()

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)

local Menu = {
    [1] = 'Aimbot',
    [2] = 'Visual',
    [3] = 'Misc',
    [4] = 'Config',
    [5] = 'FaQ'
}

imgui.OnFrame(function() return WinState[0] end, 
    function(player)
        local pos, size = imgui.ImVec2(530, 530), imgui.ImVec2(getScreenResolution())
        imgui.SetNextWindowSize(pos, imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2( size.x / 2, size.y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin('Test', WinState, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize)
        
            for MenuId, NameMenu in ipairs(Menu) do
                imgui.SetCursorPos(imgui.ImVec2(5 + (105 * (MenuId - 1)), 25))
                if ( imgui.Button(NameMenu, imgui.ImVec2(100, 50)) ) then
                    imgui.currentButtonID = MenuId
                end
            end
            
            if (imgui.currentButtonID == 5) then
                imgui.SetCursorPos(imgui.ImVec2(170,100))
                imgui.Text('https://t.me/KPECTOHOCETC')
                if (imgui.IsItemClicked()) then
                    setClipboardText("https://t.me/KPECTOHOCETC")
                end
                imgui.SetCursorPos(imgui.ImVec2(215,120))
                imgui.Text('Click for copy!')
                imgui.SetCursorPos(imgui.ImVec2(130, 500))
                imgui.Text('The script is at an early stage of development!')
            end
        imgui.End()
    end
)

addEventHandler('onWindowMessage', function(msg, wparam, lparam)
    if (msg == 0x100 and isSampAvailable()) then        
        if (wparam == 0x2D) then 
            WinState[0] = not(WinState[0])
        elseif (wparam == 0x52) then
            clearCharTasksImmediately(playerPed)
            lockPlayerControl(false)
            freezeCharPosition(PLAYER_PED, false)
        end
    end
end)

require('lib.samp.events').onTogglePlayerControllable = function(...)
    return false
end

imgui.OnInitialize(function()
    theme()
end)

function theme()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    
    style.WindowPadding = imgui.ImVec2(8, 8)
    style.WindowRounding = 8.0
    style.ChildRounding = 8.0
    style.FramePadding = imgui.ImVec2(4, 4)
    style.FrameRounding = 8.0
    style.ItemSpacing = imgui.ImVec2(4, 4)
    style.ItemInnerSpacing = imgui.ImVec2(6, 6)
    style.IndentSpacing = 20.0
    style.ScrollbarSize = 10.0
    style.ScrollbarRounding = 12.0
    style.GrabMinSize = 10.0
    style.GrabRounding = 8.0
    style.TabRounding = 8.0
    style.PopupRounding = 8
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
    style.WindowBorderSize = 0
    style.ChildBorderSize = 0
    style.PopupBorderSize = 0

    style.Colors[imgui.Col.Text]                   = imgui.ImVec4(0.90, 0.90, 0.80, 1.00)
    style.Colors[imgui.Col.TextDisabled]           = imgui.ImVec4(0.60, 0.50, 0.50, 1.00)
    style.Colors[imgui.Col.WindowBg]               = imgui.ImVec4(0.10, 0.10, 0.10, 1.00)
        style.Colors[imgui.Col.ChildBg]                = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
        style.Colors[imgui.Col.PopupBg]                = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
        style.Colors[imgui.Col.Border]                 = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.BorderShadow]           = imgui.ImVec4(0.00, 0.00, 0.00, 0.00)
        style.Colors[imgui.Col.FrameBg]                = imgui.ImVec4(0.20, 0.20, 0.20, 1.00)
        style.Colors[imgui.Col.FrameBgHovered]         = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.FrameBgActive]          = imgui.ImVec4(0.25, 0.25, 0.25, 1.00)
        style.Colors[imgui.Col.TitleBg]                = imgui.ImVec4(0.15, 0.15, 0.15, 1.00)
        style.Colors[imgui.Col.TitleBgCollapsed]       = imgui.ImVec4(0.10, 0.10, 0.10, 1.00)
        style.Colors[imgui.Col.TitleBgActive]          = imgui.ImVec4(0.20, 0.20, 0.20, 1.00)
        style.Colors[imgui.Col.MenuBarBg]              = imgui.ImVec4(0.15, 0.15, 0.15, 1.00)
        style.Colors[imgui.Col.ScrollbarBg]            = imgui.ImVec4(0.10, 0.10, 0.10, 1.00)
        style.Colors[imgui.Col.ScrollbarGrab]          = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.ScrollbarGrabHovered]   = imgui.ImVec4(0.40, 0.40, 0.40, 1.00)
        style.Colors[imgui.Col.ScrollbarGrabActive]    = imgui.ImVec4(0.50, 0.50, 0.50, 1.00)
        style.Colors[imgui.Col.CheckMark]              = imgui.ImVec4(0.66, 0.66, 0.66, 1.00)
        style.Colors[imgui.Col.SliderGrab]             = imgui.ImVec4(0.66, 0.66, 0.66, 1.00)
        style.Colors[imgui.Col.SliderGrabActive]       = imgui.ImVec4(0.70, 0.70, 0.73, 1.00)
        style.Colors[imgui.Col.Button]                 = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.ButtonHovered]          = imgui.ImVec4(0.40, 0.40, 0.40, 1.00)
        style.Colors[imgui.Col.ButtonActive]           = imgui.ImVec4(0.50, 0.50, 0.50, 1.00)
        style.Colors[imgui.Col.Header]                 = imgui.ImVec4(0.20, 0.20, 0.20, 1.00)
        style.Colors[imgui.Col.HeaderHovered]          = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.HeaderActive]           = imgui.ImVec4(0.25, 0.25, 0.25, 1.00)
        style.Colors[imgui.Col.Separator]              = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.SeparatorHovered]       = imgui.ImVec4(0.40, 0.40, 0.40, 1.00)
        style.Colors[imgui.Col.SeparatorActive]        = imgui.ImVec4(0.50, 0.50, 0.50, 1.00)
        style.Colors[imgui.Col.ResizeGrip]             = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.ResizeGripHovered]      = imgui.ImVec4(0.40, 0.40, 0.40, 1.00)
        style.Colors[imgui.Col.ResizeGripActive]       = imgui.ImVec4(0.50, 0.50, 0.50, 1.00)
        style.Colors[imgui.Col.PlotLines]              = imgui.ImVec4(0.70, 0.70, 0.73, 1.00)
        style.Colors[imgui.Col.PlotLinesHovered]       = imgui.ImVec4(0.95, 0.95, 0.70, 1.00)
        style.Colors[imgui.Col.PlotHistogram]          = imgui.ImVec4(0.70, 0.70, 0.73, 1.00)
        style.Colors[imgui.Col.PlotHistogramHovered]   = imgui.ImVec4(0.95, 0.95, 0.70, 1.00)
        style.Colors[imgui.Col.TextSelectedBg]         = imgui.ImVec4(0.25, 0.25, 0.15, 1.00)
        style.Colors[imgui.Col.ModalWindowDimBg]       = imgui.ImVec4(0.10, 0.10, 0.10, 0.80)
    style.Colors[imgui.Col.Tab]                    = imgui.ImVec4(0.20, 0.20, 0.20, 1.00)
    style.Colors[imgui.Col.TabHovered]             = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
    style.Colors[imgui.Col.TabActive]              = imgui.ImVec4(0.25, 0.25, 0.25, 1.00)
end
 

dexxx.

Новичок
Автор темы
2
1
Lua:
local imgui = require('mimgui')
local ffi = require('ffi')

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

local new = imgui.new
local WinState = new.bool()

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)

local Menu = {
    [1] = 'Aimbot',
    [2] = 'Visual',
    [3] = 'Misc',
    [4] = 'Config',
    [5] = 'FaQ'
}

imgui.OnFrame(function() return WinState[0] end,
    function(player)
        local pos, size = imgui.ImVec2(530, 530), imgui.ImVec2(getScreenResolution())
        imgui.SetNextWindowSize(pos, imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2( size.x / 2, size.y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin('Test', WinState, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize)
      
            for MenuId, NameMenu in ipairs(Menu) do
                imgui.SetCursorPos(imgui.ImVec2(5 + (105 * (MenuId - 1)), 25))
                if ( imgui.Button(NameMenu, imgui.ImVec2(100, 50)) ) then
                    imgui.currentButtonID = MenuId
                end
            end
          
            if (imgui.currentButtonID == 5) then
                imgui.SetCursorPos(imgui.ImVec2(170,100))
                imgui.Text('https://t.me/KPECTOHOCETC')
                if (imgui.IsItemClicked()) then
                    setClipboardText("https://t.me/KPECTOHOCETC")
                end
                imgui.SetCursorPos(imgui.ImVec2(215,120))
                imgui.Text('Click for copy!')
                imgui.SetCursorPos(imgui.ImVec2(130, 500))
                imgui.Text('The script is at an early stage of development!')
            end
        imgui.End()
    end
)

addEventHandler('onWindowMessage', function(msg, wparam, lparam)
    if (msg == 0x100 and isSampAvailable()) then      
        if (wparam == 0x2D) then
            WinState[0] = not(WinState[0])
        elseif (wparam == 0x52) then
            clearCharTasksImmediately(playerPed)
            lockPlayerControl(false)
            freezeCharPosition(PLAYER_PED, false)
        end
    end
end)

require('lib.samp.events').onTogglePlayerControllable = function(...)
    return false
end

imgui.OnInitialize(function()
    theme()
end)

function theme()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
  
    style.WindowPadding = imgui.ImVec2(8, 8)
    style.WindowRounding = 8.0
    style.ChildRounding = 8.0
    style.FramePadding = imgui.ImVec2(4, 4)
    style.FrameRounding = 8.0
    style.ItemSpacing = imgui.ImVec2(4, 4)
    style.ItemInnerSpacing = imgui.ImVec2(6, 6)
    style.IndentSpacing = 20.0
    style.ScrollbarSize = 10.0
    style.ScrollbarRounding = 12.0
    style.GrabMinSize = 10.0
    style.GrabRounding = 8.0
    style.TabRounding = 8.0
    style.PopupRounding = 8
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
    style.WindowBorderSize = 0
    style.ChildBorderSize = 0
    style.PopupBorderSize = 0

    style.Colors[imgui.Col.Text]                   = imgui.ImVec4(0.90, 0.90, 0.80, 1.00)
    style.Colors[imgui.Col.TextDisabled]           = imgui.ImVec4(0.60, 0.50, 0.50, 1.00)
    style.Colors[imgui.Col.WindowBg]               = imgui.ImVec4(0.10, 0.10, 0.10, 1.00)
        style.Colors[imgui.Col.ChildBg]                = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
        style.Colors[imgui.Col.PopupBg]                = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
        style.Colors[imgui.Col.Border]                 = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.BorderShadow]           = imgui.ImVec4(0.00, 0.00, 0.00, 0.00)
        style.Colors[imgui.Col.FrameBg]                = imgui.ImVec4(0.20, 0.20, 0.20, 1.00)
        style.Colors[imgui.Col.FrameBgHovered]         = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.FrameBgActive]          = imgui.ImVec4(0.25, 0.25, 0.25, 1.00)
        style.Colors[imgui.Col.TitleBg]                = imgui.ImVec4(0.15, 0.15, 0.15, 1.00)
        style.Colors[imgui.Col.TitleBgCollapsed]       = imgui.ImVec4(0.10, 0.10, 0.10, 1.00)
        style.Colors[imgui.Col.TitleBgActive]          = imgui.ImVec4(0.20, 0.20, 0.20, 1.00)
        style.Colors[imgui.Col.MenuBarBg]              = imgui.ImVec4(0.15, 0.15, 0.15, 1.00)
        style.Colors[imgui.Col.ScrollbarBg]            = imgui.ImVec4(0.10, 0.10, 0.10, 1.00)
        style.Colors[imgui.Col.ScrollbarGrab]          = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.ScrollbarGrabHovered]   = imgui.ImVec4(0.40, 0.40, 0.40, 1.00)
        style.Colors[imgui.Col.ScrollbarGrabActive]    = imgui.ImVec4(0.50, 0.50, 0.50, 1.00)
        style.Colors[imgui.Col.CheckMark]              = imgui.ImVec4(0.66, 0.66, 0.66, 1.00)
        style.Colors[imgui.Col.SliderGrab]             = imgui.ImVec4(0.66, 0.66, 0.66, 1.00)
        style.Colors[imgui.Col.SliderGrabActive]       = imgui.ImVec4(0.70, 0.70, 0.73, 1.00)
        style.Colors[imgui.Col.Button]                 = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.ButtonHovered]          = imgui.ImVec4(0.40, 0.40, 0.40, 1.00)
        style.Colors[imgui.Col.ButtonActive]           = imgui.ImVec4(0.50, 0.50, 0.50, 1.00)
        style.Colors[imgui.Col.Header]                 = imgui.ImVec4(0.20, 0.20, 0.20, 1.00)
        style.Colors[imgui.Col.HeaderHovered]          = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.HeaderActive]           = imgui.ImVec4(0.25, 0.25, 0.25, 1.00)
        style.Colors[imgui.Col.Separator]              = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.SeparatorHovered]       = imgui.ImVec4(0.40, 0.40, 0.40, 1.00)
        style.Colors[imgui.Col.SeparatorActive]        = imgui.ImVec4(0.50, 0.50, 0.50, 1.00)
        style.Colors[imgui.Col.ResizeGrip]             = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
        style.Colors[imgui.Col.ResizeGripHovered]      = imgui.ImVec4(0.40, 0.40, 0.40, 1.00)
        style.Colors[imgui.Col.ResizeGripActive]       = imgui.ImVec4(0.50, 0.50, 0.50, 1.00)
        style.Colors[imgui.Col.PlotLines]              = imgui.ImVec4(0.70, 0.70, 0.73, 1.00)
        style.Colors[imgui.Col.PlotLinesHovered]       = imgui.ImVec4(0.95, 0.95, 0.70, 1.00)
        style.Colors[imgui.Col.PlotHistogram]          = imgui.ImVec4(0.70, 0.70, 0.73, 1.00)
        style.Colors[imgui.Col.PlotHistogramHovered]   = imgui.ImVec4(0.95, 0.95, 0.70, 1.00)
        style.Colors[imgui.Col.TextSelectedBg]         = imgui.ImVec4(0.25, 0.25, 0.15, 1.00)
        style.Colors[imgui.Col.ModalWindowDimBg]       = imgui.ImVec4(0.10, 0.10, 0.10, 0.80)
    style.Colors[imgui.Col.Tab]                    = imgui.ImVec4(0.20, 0.20, 0.20, 1.00)
    style.Colors[imgui.Col.TabHovered]             = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
    style.Colors[imgui.Col.TabActive]              = imgui.ImVec4(0.25, 0.25, 0.25, 1.00)
end
Спасибо большое, но я просто по гайдам от чапо учусь и как мне теперь разбираться с этим :D и можешь объяснить, что делает эта строчка?
addEventHandler('onWindowMessage', function(msg, wparam, lparam)
 
Последнее редактирование:
  • Вау
Реакции: qdIbp

qdIbp

Автор темы
Проверенный
1,436
1,176
Спасибо большое, но я просто по гайдам от чапо учусь и как мне теперь разбираться с этим :D и можешь объяснить, что делает эта строчка?
addEventHandler('onWindowMessage', function(msg, wparam, lparam)
А простыми словами, это событие предназначена для обработки сообщений, в твоём случае нажатий кнопок на клавиатуре, id клавиш можешь найти тут

id клавиш можешь найти тут
Но тут id клавиш записаны в десятичной системе счисления, а в коде я сразу перевел в шестнадцатеричную 😅
 
  • Нравится
Реакции: dexxx.