[Lua] Я новичок в Lua и ImGui. Подскажите, как улучшить функции (читы) в моём коде?

Haru Urara

Участник
Автор темы
33
17
Версия MoonLoader
.026-beta
Вот мой код
Код на португальском, потому что я бразилец


😐
Lua:
script_name("Menu do bode")
script_author("bode dus behhhh")
require "lib.moonloader"
local imgui = require "imgui"
local key = require "vkeys"
local raknet = require 'samp.raknet'
local sampev = require 'lib.samp.events'
local events = require 'samp.events.core'
local utils = require 'samp.events.utils'
local handler = require 'samp.events.handlers'
require 'samp.events.extra_types'

-- FontAwesome setup corrigido
local fa = require 'faIcons'
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
local fa_font = nil

local bs = raknetNewBitStream()
local armakill = imgui.ImInt(31)
local idkill = imgui.ImInt(-1)
menu = imgui.ImBool(false)

-- Função corrigida para carregar fonte
function imgui.BeforeDrawFrame()
    if fa_font == nil then
        local font_config = imgui.ImFontConfig()
        font_config.MergeMode = true
       
        -- Tenta carregar a fonte, se falhar usa fonte padrão
        local font_path = 'moonloader/resource/fonts/fontawesome-webfont.ttf'
        if doesFileExist(font_path) then
            fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF(font_path, 14.0, font_config, fa_glyph_ranges)
        else
            fa_font = imgui.GetIO().Fonts:GetFont(0) -- Fonte padrão
        end
    end
end

function imgui.TextColoredRGB(text, render_text)
    local max_float = imgui.GetWindowWidth()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local ImVec4 = imgui.ImVec4

    local explode_argb = function(argb)
        local a = bit.band(bit.rshift(argb, 24), 0xFF)
        local r = bit.band(bit.rshift(argb, 16), 0xFF)
        local g = bit.band(bit.rshift(argb, 8), 0xFF)
        local b = bit.band(argb, 0xFF)
        return a, r, g, b
    end

    local getcolor = function(color)
        if color:sub(1, 6):upper() == 'SSSSSS' then
            local r, g, b = colors[1].x, colors[1].y, colors[1].z
            local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
            return ImVec4(r, g, b, a / 255)
        end
        local color = type(color) == 'string' and tonumber(color, 16) or color
        if type(color) ~= 'number' then return end
        local r, g, b, a = explode_argb(color)
        return imgui.ImColor(r, g, b, a):GetVec4()
    end

    local render_text = function(text_)
        for w in text_:gmatch('[^\r\n]+') do
            local text, colors_, m = {}, {}, 1
            w = w:gsub('{(......)}', '{%1FF}')
            while w:find('{........}') do
                local n, k = w:find('{........}')
                local color = getcolor(w:sub(n + 1, k - 1))
                if color then
                    text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
                    colors_[#colors_ + 1] = color
                    m = n
                end
                w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
            end

            local length = imgui.CalcTextSize(w)
            if render_text == 2 then
                imgui.NewLine()
                imgui.SameLine(max_float / 2 - ( length.x / 2 ))
            elseif render_text == 3 then
                imgui.NewLine()
                imgui.SameLine(max_float - length.x - 5 )
            end
            if text[0] then
                for i = 0, #text do
                    imgui.TextColored(colors_[i] or colors[1], text[i])
                    imgui.SameLine(nil, 0)
                end
                imgui.NewLine()
            else imgui.Text(w) end
        end
    end

    render_text(text)
end

-- Variáveis do menu
local test = imgui.ImInt(50)
local test2 = imgui.ImInt(25)
local tab = 1
local custom_x = imgui.ImFloat(0.0)
local custom_y = imgui.ImFloat(0.0)
local custom_z = imgui.ImFloat(0.0)
local muni = imgui.ImInt(200)
local arma = imgui.ImInt(31)
local tx = imgui.ImFloat(0.0)
local ty = imgui.ImFloat(0.0)
local tz = imgui.ImFloat(0.0)
local vida = imgui.ImInt(50)
local colete = imgui.ImInt(100)
local muni2 = imgui.ImInt(1000)
local idskin = imgui.ImInt(0)
local velplayer = imgui.ImFloat(0.0)
local texto = imgui.ImBuffer(256)
local telarid = imgui.ImInt(0)
local checked_test = imgui.ImBool(false)
local checked2 = imgui.ImBool(false)
local checked = imgui.ImBool(false)
local godmode_thread = nil
local images = {
    two = imgui.CreateTextureFromFile("moonloader/image/cat.jpg")
}
local recon = imgui.ImFloat(0)
local portaservidor = imgui.ImInt(7777)
input = imgui.ImBuffer(256)
local encoding = require 'encoding'
local rkeys = require 'rkeys'
imgui.ToggleButton = require('imgui_addons').ToggleButton

-- Toggle buttons
local toggle_status = imgui.ImBool(false)
local toggle_status_2 = imgui.ImBool(false)
local toggle_status_3 = imgui.ImBool(false)
local toggle_status_4 = imgui.ImBool(false)
local toggle_status_5 = imgui.ImBool(false)
local toggle_status_6 = imgui.ImBool(false)
local toggle_status_7 = imgui.ImBool(false)
local toggle_status_8 = imgui.ImBool(false)
local toggle_status_9 = imgui.ImBool(false)
local toggle_status_10 = imgui.ImBool(false)
local toggle_status_11 = imgui.ImBool(false)
local toggle_status_12 = imgui.ImBool(false)

imgui.HotKey = require('imgui_addons').HotKey
imgui.Spinner = require('imgui_addons').Spinner
imgui.BufferingBar = require('imgui_addons').BufferingBar

encoding.default = 'CP1251'
u8 = encoding.UTF8

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("addons",cmd_addons)
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)

    imgui.Process = false
    while true do
        wait(0)
        if wasKeyPressed(key.VK_J) then
            menu.v = not menu.v
        end
        imgui.Process = menu.v
    end
end

function cmd_addons(arg)
    menu.v = not menu.v
    imgui.Process = menu.v
end

function godmode()
    godmode_thread = lua_thread.create(function()
        while checked.v do
            wait(0)
           
            -- Verifica se ainda está ativo
            if checked.v then
                setCharHealth(PLAYER_PED, 200) -- Vida máxima
                addArmourToChar(PLAYER_PED, 100) -- Colete máximo
            end
        end
    end)
end

function gm()
    while true do wait(0) end
end

function imgui.OnDrawFrame()
    if menu.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(700.0, 500.0), imgui.Cond.FirstUseEver)
       
        -- Título corrigido - usando ícone de forma segura
        local window_title = "Menu do Bode"
        if fa_font and fa.ICON_PENCIL then
            window_title = fa.ICON_PENCIL .. ' Aprendendo imgui'
        end
       
        imgui.Begin(window_title, menu, imgui.WindowFlags.NoCollapse)

        imgui.Separator()
        imgui.BeginChild("tabs",imgui.ImVec2(150,0), true)
       
        if imgui.Button(fa.ICON_USER.."   Player",imgui.ImVec2(115, 43)) then
            tab = 1
        end
       
        if imgui.Button(fa.ICON_FIRE.."   Weapons",imgui.ImVec2(115, 43)) then
            tab = 2
        end

        if imgui.Button(fa.ICON_SERVER.."   Servidor",imgui.ImVec2(115, 43)) then
            tab = 3
        end
        if imgui.Button(fa.ICON_HEART.."   Vida",imgui.ImVec2(115, 43)) then
            tab = 4
        end
        if imgui.Button(fa.ICON_CAR.."   Car",imgui.ImVec2(115, 43)) then
            tab = 5
        end
        imgui.EndChild()
        imgui.SameLine()

        imgui.BeginChild("content", imgui.ImVec2(0,0), true)
       
        if tab == 1 then
            imgui.Text(fa.ICON_MAP_MARKER.." Teleport functions")
            imgui.Separator()
              --imgui.Image(images.two, imgui.ImVec2(100, 100))

            imgui.Text(fa.ICON_GLOBE.." Coordenadas")

            imgui.InputFloat("X", custom_x, -1000, 1000)
            imgui.InputFloat("Y",custom_y, -1000, 1000)
            imgui.InputFloat("Z", custom_z, -1000, 1000)
            if imgui.Button("Teleportar") then
                setCharCoordinates(PLAYER_PED, custom_x.v, custom_y.v, custom_z.v)
                sampAddChatMessage("Teleportado para: "..custom_x.v..", "..custom_y.v..", "..custom_z.v.." !", 0x00FF00)
            end
           
            local x,y,z = getCharCoordinates(PLAYER_PED)
            imgui.Text("Suas coordendas no momento sao: X:"..math.floor(x).." | Y: " ..math.floor(y).." | Z: "..math.floor(z))
            imgui.Separator()
           
            imgui.ToggleButton(fa.ICON_BLIND.." Impedir que o servidor limpe sua animacao",toggle_status)
            imgui.ToggleButton(fa.ICON_BAN.." Bloquear teleport do server",toggle_status_2)
            imgui.ToggleButton(fa.ICON_BAN..' Impedir kick', toggle_status_3)
            imgui.ToggleButton(fa.ICON_MOBILE.." Fake Mobile",toggle_status_4)
            imgui.ToggleButton(fa.ICON_SIGN_IN.." Impedir login",toggle_status_5)
            imgui.ToggleButton(fa.ICON_COMMENTING.." Bloquar dialog",toggle_status_6)
            imgui.ToggleButton(fa.ICON_BOLT.." Corrida infinita",toggle_status_10)

        elseif tab == 2 then
            imgui.Text("Weapons")
            imgui.SliderInt("ID da arma",arma,0,60)
            imgui.SliderInt("Quantidade de municao",muni,0,1000)
           
            if imgui.Button("Puxar a arma") then
                giveWeaponToChar(PLAYER_PED,arma.v,muni.v)
                sampAddChatMessage("A arma id: "..arma.v.." com "..muni.v.."!!!", 0x00FF00)
            end
            imgui.SameLine()
           
            if imgui.Button("Remover arma") then
                sampForceWeaponsSync()
                removeWeaponFromChar(PLAYER_PED,arma.v)
                sampAddChatMessage("Arma id: "..arma.v.." removida!!!", 0xFF0000)
            end
           
            imgui.SliderInt("Puxar municao para sua arma",muni2,0,1000)
           
            if imgui.Button("Puxar municao") then
                local weaponID = getCurrentCharWeapon(PLAYER_PED)
              setCharAmmo(PLAYER_PED,weaponID,muni2.v)

            end
         
            imgui.ToggleButton("Impedir que o server remova sua arma",toggle_status_11)
           
            imgui.Separator()
            imgui.ToggleButton("Puxar arma v2",toggle_status_8)


        elseif tab == 3 then
            local nomeserver = sampGetCurrentServerName()
            local ipserver, port = sampGetCurrentServerAddress()
            imgui.Text("Informacoes do servidor")
            imgui.Separator()
            imgui.Text("Nome do servidor: "..nomeserver.." !")
            imgui.Separator()
            imgui.Text("Ip do servidor : "..ipserver.." | Porta: "..port.." !")
                if imgui.Button("Reconectar em : ".. ipserver .. " " .. port) then
                    sampDisconnectWithReason(false)
                    sampConnectToServer(tostring(ipserver), port)
                end
            --[[   imgui.InputFloat("IP do servidor",recon,100000000000000000000)
                    imgui.InputInt("Porta do servidor",portaservidor,999999)
                        imgui.InputText("Seu nome",input)

                        if imgui.Button("Reconectar") then
                            sampSetLocalPlayerName(input)
                            sampDisconnectWithReason(false)
                    sampConnectToServer(tostring(recon), portaservidor)
                end
                ]]


           
            -- Imagem comentada para evitar crash se não existir
            -- local img = imgui.CreateTextureFromFile(getGameDirectory() .. "\\moonloader\\image\\cat.jpg")
            -- imgui.Image(img, imgui.ImVec2(500, 347))
           
            local meuId = select(2, sampGetPlayerIdByCharHandle(PLAYER_PED))
            local meuNome = sampGetPlayerNickname(meuId)
           
            imgui.Text("Seu id e: "..meuId)
            imgui.Text("Seu nome atual e: "..meuNome)

        elseif tab == 4 then
            imgui.Text("Funcoes de vida")
            imgui.Separator()
            imgui.SliderInt("Define sua vida",vida,0,100)
           
            if imgui.Button("Setar vida") then
                setCharHealth(PLAYER_PED,vida.v)
                sampAddChatMessage("Voce setou "..vida.v.." de hp na sua vida!",0x00FF00)
            end
            imgui.SameLine()
           
            if imgui.Button("Suicide") then
                setCharHealth(PLAYER_PED,0)
                sampAddChatMessage("Voce se suicidou!",0xFF0000)
            end
           
            imgui.SliderInt("Defina seu colete",colete,0,100)
            if imgui.Button("Setar colete") then
                addArmourToChar(PLAYER_PED,colete.v)
                sampAddChatMessage("Voce setou "..colete.v.." de hp em seu colete !",0x00FF00)
            end
           
            imgui.Checkbox("God mode", checked)
           
            -- Controle do God Mode Thread
            if checked.v and godmode_thread == nil then
                -- Ativou God Mode
                sampAddChatMessage("God Mode ATIVADO!", 0x00FF00)
                godmode()
               
            elseif not checked.v and godmode_thread ~= nil then
                -- Desativou God Mode
                sampAddChatMessage("God Mode DESATIVADO!", 0xFF0000)
                godmode_thread:terminate()
                godmode_thread = nil
            end
           
        elseif tab == 5 then
            if imgui.Button("Explodir seu carro") then
                if isCharInAnyCar(PLAYER_PED) then
                    local carhandle = storeCarCharIsInNoSave(PLAYER_PED)
                    local idcar = getCarModel(carhandle)
                    sampForceVehicleSync(carhandle)
                    explodeCar(carhandle)
                end
            end
            imgui.ToggleButton("Nao cair da moto",toggle_status_12)

        end
       
        imgui.EndChild()
        imgui.End()
    end
end

-- Event handlers corrigidos
function sampev.onClearActorAnimation(actorId)
    if toggle_status.v then
        return false
    end
    return true
end
function sampev.onApplyActorAnimationactorId(animLib ,animName ,frameDelta ,loop ,lockX ,lockY,freeze,time)
    if toggle_status.v then
        return false
    end
    return true
end

function sampev.onSetPlayerPos(position)
    if toggle_status_2.v then
        sampAddChatMessage(string.format('Servidor tentou mudar sua posicao %0.2f %0.2f %0.2f', position.x, position.y, position.z), 0xFF3C82A0)
        return false
    end
end

function sampev.onConnectionBanned()
    if toggle_status_3.v then
        return false
    end
    return true
end

function sampev.onConnectionClosed()
    if toggle_status_3.v then
        return false
    end
    return true
end

function sampev.onSendClientJoin(version, mod, nickname, challengeResponse, joinAuthKey, clientVer, challengeResponse2)
    if toggle_status_4.v then
        return false
    end
    return true
end

function sampev.onAuthenticationRequest(key)
    if toggle_status_5.v then
        return false
    end
    return true
end

function sampev.onShowMenu(menuId)
    if toggle_status_6.v then
        return false
    end
    return true
end

function sampev.onSendDialogResponse(dialogId,button,listboxId,input)
    if toggle_status_6.v then
        return false
    end
    return true
end

function sampev.onShowDialog(dialogId,style,title,button1,button2,text)
    if toggle_status_6.v then
        return false
    end
    return true
end

function sampev.onSetPlayerHealth(health)
   local health = getCharHealth(PLAYER_PED)
    if checked.v and health <= 99 then
        return false
    end
    return true
end

function sampev.onPlayerDeath(playerId)
    if checked2.v and playerId == select(2,sampGetPlayerIdByCharHandle(PLAYER_PED)) then
        return false
    end
end

function sampev.onResetPlayerWeapons()
    if toggle_status_8.v then
        return false
    end
    return true
end
function corridainfinita()
    if toggle_status_10.v then
        setPlayerNeverGetsTired (PLAYER_HANDLE,true)
    else
        setPlayerNeverGetsTired(PLAYER_HANDLE,false)
    end
end
function onSetWeaponAmmo(weaponId,ammo)
    if toggle_status_8.v then
        local ammo = getAmmoInCharWeapon(PLAYER_PED, ammo)
        if ammo <= 600 then
        return false
    end
    return true
end
end
function sampev.onResetPlayerWeapons()
    if toggle_status_11.v then
        return false
    end
    return true
end
function sampev.onDestroyWeaponPickup(id)
    if toggle_status_11.v then
        return false
    end
    return true
end
function sampev.onPlayerExitVehicle(playerId,vehicleId)
    if toggle_status_12 then
        local meuId = select(2, sampGetPlayerIdByCharHandle(PLAYER_PED))
        local playerId = sampGetPlayerNickname(meuId)
        local vehicleId = getCarModel(carhandle)
        return false
    end
    return true
end


-- Estilo do menu
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4

style.WindowRounding = 5.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 = 15.0
style.ScrollbarRounding = 9
style.GrabMinSize = 5.0
style.GrabRounding = 1.0

colors[clr.WindowBg] = imgui.ImVec4(0.10, 0.10, 0.10, 0.95)
colors[clr.ChildWindowBg] = imgui.ImVec4(0.10, 0.10, 0.10, 1.00)
colors[clr.TitleBg] = imgui.ImVec4(0.20, 0.05, 0.05, 1.00)
colors[clr.TitleBgActive] = imgui.ImVec4(0.30, 0.05, 0.05, 1.00)
colors[clr.Button] = imgui.ImVec4(0.50, 0.10, 0.10, 1.00)
colors[clr.ButtonHovered] = imgui.ImVec4(0.70, 0.20, 0.20, 1.00)
colors[clr.ButtonActive] = imgui.ImVec4(0.90, 0.30, 0.30, 1.00)
colors[clr.Text] = imgui.ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.FrameBg] = imgui.ImVec4(0.20, 0.05, 0.05, 1.00)
colors[clr.FrameBgHovered] = imgui.ImVec4(0.30, 0.10, 0.10, 1.00)
colors[clr.FrameBgActive] = imgui.ImVec4(0.40, 0.15, 0.15, 1.00)
colors[clr.Header] = imgui.ImVec4(0.50, 0.10, 0.10, 1.00)
colors[clr.HeaderHovered] = imgui.ImVec4(0.70, 0.20, 0.20, 1.00)
colors[clr.HeaderActive] = imgui.ImVec4(0.90, 0.30, 0.30, 1.00)
colors[clr.CheckMark] = imgui.ImVec4(0.90, 0.30, 0.30, 1.00)
colors[clr.SliderGrab] = imgui.ImVec4(0.70, 0.20, 0.20, 1.00)
colors[clr.SliderGrabActive] = imgui.ImVec4(0.90, 0.30, 0.30, 1.00)

Изображение меню :

sa-mp-006.png
 

Haru Urara

Участник
Автор темы
33
17
Что ты хочешь улучшить? Добавить новые читы?
Я хочу улучшить читы и добавить больше полезных функций.

Вот мой код
Код на португальском, потому что я бразилец


😐
Lua:
script_name("Menu do bode")
script_author("bode dus behhhh")
require "lib.moonloader"
local imgui = require "imgui"
local key = require "vkeys"
local raknet = require 'samp.raknet'
local sampev = require 'lib.samp.events'
local events = require 'samp.events.core'
local utils = require 'samp.events.utils'
local handler = require 'samp.events.handlers'
require 'samp.events.extra_types'

-- FontAwesome setup corrigido
local fa = require 'faIcons'
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
local fa_font = nil

local bs = raknetNewBitStream()
local armakill = imgui.ImInt(31)
local idkill = imgui.ImInt(-1)
menu = imgui.ImBool(false)

-- Função corrigida para carregar fonte
function imgui.BeforeDrawFrame()
    if fa_font == nil then
        local font_config = imgui.ImFontConfig()
        font_config.MergeMode = true
      
        -- Tenta carregar a fonte, se falhar usa fonte padrão
        local font_path = 'moonloader/resource/fonts/fontawesome-webfont.ttf'
        if doesFileExist(font_path) then
            fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF(font_path, 14.0, font_config, fa_glyph_ranges)
        else
            fa_font = imgui.GetIO().Fonts:GetFont(0) -- Fonte padrão
        end
    end
end

function imgui.TextColoredRGB(text, render_text)
    local max_float = imgui.GetWindowWidth()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local ImVec4 = imgui.ImVec4

    local explode_argb = function(argb)
        local a = bit.band(bit.rshift(argb, 24), 0xFF)
        local r = bit.band(bit.rshift(argb, 16), 0xFF)
        local g = bit.band(bit.rshift(argb, 8), 0xFF)
        local b = bit.band(argb, 0xFF)
        return a, r, g, b
    end

    local getcolor = function(color)
        if color:sub(1, 6):upper() == 'SSSSSS' then
            local r, g, b = colors[1].x, colors[1].y, colors[1].z
            local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
            return ImVec4(r, g, b, a / 255)
        end
        local color = type(color) == 'string' and tonumber(color, 16) or color
        if type(color) ~= 'number' then return end
        local r, g, b, a = explode_argb(color)
        return imgui.ImColor(r, g, b, a):GetVec4()
    end

    local render_text = function(text_)
        for w in text_:gmatch('[^\r\n]+') do
            local text, colors_, m = {}, {}, 1
            w = w:gsub('{(......)}', '{%1FF}')
            while w:find('{........}') do
                local n, k = w:find('{........}')
                local color = getcolor(w:sub(n + 1, k - 1))
                if color then
                    text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
                    colors_[#colors_ + 1] = color
                    m = n
                end
                w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
            end

            local length = imgui.CalcTextSize(w)
            if render_text == 2 then
                imgui.NewLine()
                imgui.SameLine(max_float / 2 - ( length.x / 2 ))
            elseif render_text == 3 then
                imgui.NewLine()
                imgui.SameLine(max_float - length.x - 5 )
            end
            if text[0] then
                for i = 0, #text do
                    imgui.TextColored(colors_[i] or colors[1], text[i])
                    imgui.SameLine(nil, 0)
                end
                imgui.NewLine()
            else imgui.Text(w) end
        end
    end

    render_text(text)
end

-- Variáveis do menu
local test = imgui.ImInt(50)
local test2 = imgui.ImInt(25)
local tab = 1
local custom_x = imgui.ImFloat(0.0)
local custom_y = imgui.ImFloat(0.0)
local custom_z = imgui.ImFloat(0.0)
local muni = imgui.ImInt(200)
local arma = imgui.ImInt(31)
local tx = imgui.ImFloat(0.0)
local ty = imgui.ImFloat(0.0)
local tz = imgui.ImFloat(0.0)
local vida = imgui.ImInt(50)
local colete = imgui.ImInt(100)
local muni2 = imgui.ImInt(1000)
local idskin = imgui.ImInt(0)
local velplayer = imgui.ImFloat(0.0)
local texto = imgui.ImBuffer(256)
local telarid = imgui.ImInt(0)
local checked_test = imgui.ImBool(false)
local checked2 = imgui.ImBool(false)
local checked = imgui.ImBool(false)
local godmode_thread = nil
local images = {
    two = imgui.CreateTextureFromFile("moonloader/image/cat.jpg")
}
local recon = imgui.ImFloat(0)
local portaservidor = imgui.ImInt(7777)
input = imgui.ImBuffer(256)
local encoding = require 'encoding'
local rkeys = require 'rkeys'
imgui.ToggleButton = require('imgui_addons').ToggleButton

-- Toggle buttons
local toggle_status = imgui.ImBool(false)
local toggle_status_2 = imgui.ImBool(false)
local toggle_status_3 = imgui.ImBool(false)
local toggle_status_4 = imgui.ImBool(false)
local toggle_status_5 = imgui.ImBool(false)
local toggle_status_6 = imgui.ImBool(false)
local toggle_status_7 = imgui.ImBool(false)
local toggle_status_8 = imgui.ImBool(false)
local toggle_status_9 = imgui.ImBool(false)
local toggle_status_10 = imgui.ImBool(false)
local toggle_status_11 = imgui.ImBool(false)
local toggle_status_12 = imgui.ImBool(false)

imgui.HotKey = require('imgui_addons').HotKey
imgui.Spinner = require('imgui_addons').Spinner
imgui.BufferingBar = require('imgui_addons').BufferingBar

encoding.default = 'CP1251'
u8 = encoding.UTF8

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("addons",cmd_addons)
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)

    imgui.Process = false
    while true do
        wait(0)
        if wasKeyPressed(key.VK_J) then
            menu.v = not menu.v
        end
        imgui.Process = menu.v
    end
end

function cmd_addons(arg)
    menu.v = not menu.v
    imgui.Process = menu.v
end

function godmode()
    godmode_thread = lua_thread.create(function()
        while checked.v do
            wait(0)
          
            -- Verifica se ainda está ativo
            if checked.v then
                setCharHealth(PLAYER_PED, 200) -- Vida máxima
                addArmourToChar(PLAYER_PED, 100) -- Colete máximo
            end
        end
    end)
end

function gm()
    while true do wait(0) end
end

function imgui.OnDrawFrame()
    if menu.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(700.0, 500.0), imgui.Cond.FirstUseEver)
      
        -- Título corrigido - usando ícone de forma segura
        local window_title = "Menu do Bode"
        if fa_font and fa.ICON_PENCIL then
            window_title = fa.ICON_PENCIL .. ' Aprendendo imgui'
        end
      
        imgui.Begin(window_title, menu, imgui.WindowFlags.NoCollapse)

        imgui.Separator()
        imgui.BeginChild("tabs",imgui.ImVec2(150,0), true)
      
        if imgui.Button(fa.ICON_USER.."   Player",imgui.ImVec2(115, 43)) then
            tab = 1
        end
      
        if imgui.Button(fa.ICON_FIRE.."   Weapons",imgui.ImVec2(115, 43)) then
            tab = 2
        end

        if imgui.Button(fa.ICON_SERVER.."   Servidor",imgui.ImVec2(115, 43)) then
            tab = 3
        end
        if imgui.Button(fa.ICON_HEART.."   Vida",imgui.ImVec2(115, 43)) then
            tab = 4
        end
        if imgui.Button(fa.ICON_CAR.."   Car",imgui.ImVec2(115, 43)) then
            tab = 5
        end
        imgui.EndChild()
        imgui.SameLine()

        imgui.BeginChild("content", imgui.ImVec2(0,0), true)
      
        if tab == 1 then
            imgui.Text(fa.ICON_MAP_MARKER.." Teleport functions")
            imgui.Separator()
              --imgui.Image(images.two, imgui.ImVec2(100, 100))

            imgui.Text(fa.ICON_GLOBE.." Coordenadas")

            imgui.InputFloat("X", custom_x, -1000, 1000)
            imgui.InputFloat("Y",custom_y, -1000, 1000)
            imgui.InputFloat("Z", custom_z, -1000, 1000)
            if imgui.Button("Teleportar") then
                setCharCoordinates(PLAYER_PED, custom_x.v, custom_y.v, custom_z.v)
                sampAddChatMessage("Teleportado para: "..custom_x.v..", "..custom_y.v..", "..custom_z.v.." !", 0x00FF00)
            end
          
            local x,y,z = getCharCoordinates(PLAYER_PED)
            imgui.Text("Suas coordendas no momento sao: X:"..math.floor(x).." | Y: " ..math.floor(y).." | Z: "..math.floor(z))
            imgui.Separator()
          
            imgui.ToggleButton(fa.ICON_BLIND.." Impedir que o servidor limpe sua animacao",toggle_status)
            imgui.ToggleButton(fa.ICON_BAN.." Bloquear teleport do server",toggle_status_2)
            imgui.ToggleButton(fa.ICON_BAN..' Impedir kick', toggle_status_3)
            imgui.ToggleButton(fa.ICON_MOBILE.." Fake Mobile",toggle_status_4)
            imgui.ToggleButton(fa.ICON_SIGN_IN.." Impedir login",toggle_status_5)
            imgui.ToggleButton(fa.ICON_COMMENTING.." Bloquar dialog",toggle_status_6)
            imgui.ToggleButton(fa.ICON_BOLT.." Corrida infinita",toggle_status_10)

        elseif tab == 2 then
            imgui.Text("Weapons")
            imgui.SliderInt("ID da arma",arma,0,60)
            imgui.SliderInt("Quantidade de municao",muni,0,1000)
          
            if imgui.Button("Puxar a arma") then
                giveWeaponToChar(PLAYER_PED,arma.v,muni.v)
                sampAddChatMessage("A arma id: "..arma.v.." com "..muni.v.."!!!", 0x00FF00)
            end
            imgui.SameLine()
          
            if imgui.Button("Remover arma") then
                sampForceWeaponsSync()
                removeWeaponFromChar(PLAYER_PED,arma.v)
                sampAddChatMessage("Arma id: "..arma.v.." removida!!!", 0xFF0000)
            end
          
            imgui.SliderInt("Puxar municao para sua arma",muni2,0,1000)
          
            if imgui.Button("Puxar municao") then
                local weaponID = getCurrentCharWeapon(PLAYER_PED)
              setCharAmmo(PLAYER_PED,weaponID,muni2.v)

            end
        
            imgui.ToggleButton("Impedir que o server remova sua arma",toggle_status_11)
          
            imgui.Separator()
            imgui.ToggleButton("Puxar arma v2",toggle_status_8)


        elseif tab == 3 then
            local nomeserver = sampGetCurrentServerName()
            local ipserver, port = sampGetCurrentServerAddress()
            imgui.Text("Informacoes do servidor")
            imgui.Separator()
            imgui.Text("Nome do servidor: "..nomeserver.." !")
            imgui.Separator()
            imgui.Text("Ip do servidor : "..ipserver.." | Porta: "..port.." !")
                if imgui.Button("Reconectar em : ".. ipserver .. " " .. port) then
                    sampDisconnectWithReason(false)
                    sampConnectToServer(tostring(ipserver), port)
                end
            --[[   imgui.InputFloat("IP do servidor",recon,100000000000000000000)
                    imgui.InputInt("Porta do servidor",portaservidor,999999)
                        imgui.InputText("Seu nome",input)

                        if imgui.Button("Reconectar") then
                            sampSetLocalPlayerName(input)
                            sampDisconnectWithReason(false)
                    sampConnectToServer(tostring(recon), portaservidor)
                end
                ]]


          
            -- Imagem comentada para evitar crash se não existir
            -- local img = imgui.CreateTextureFromFile(getGameDirectory() .. "\\moonloader\\image\\cat.jpg")
            -- imgui.Image(img, imgui.ImVec2(500, 347))
          
            local meuId = select(2, sampGetPlayerIdByCharHandle(PLAYER_PED))
            local meuNome = sampGetPlayerNickname(meuId)
          
            imgui.Text("Seu id e: "..meuId)
            imgui.Text("Seu nome atual e: "..meuNome)

        elseif tab == 4 then
            imgui.Text("Funcoes de vida")
            imgui.Separator()
            imgui.SliderInt("Define sua vida",vida,0,100)
          
            if imgui.Button("Setar vida") then
                setCharHealth(PLAYER_PED,vida.v)
                sampAddChatMessage("Voce setou "..vida.v.." de hp na sua vida!",0x00FF00)
            end
            imgui.SameLine()
          
            if imgui.Button("Suicide") then
                setCharHealth(PLAYER_PED,0)
                sampAddChatMessage("Voce se suicidou!",0xFF0000)
            end
          
            imgui.SliderInt("Defina seu colete",colete,0,100)
            if imgui.Button("Setar colete") then
                addArmourToChar(PLAYER_PED,colete.v)
                sampAddChatMessage("Voce setou "..colete.v.." de hp em seu colete !",0x00FF00)
            end
          
            imgui.Checkbox("God mode", checked)
          
            -- Controle do God Mode Thread
            if checked.v and godmode_thread == nil then
                -- Ativou God Mode
                sampAddChatMessage("God Mode ATIVADO!", 0x00FF00)
                godmode()
              
            elseif not checked.v and godmode_thread ~= nil then
                -- Desativou God Mode
                sampAddChatMessage("God Mode DESATIVADO!", 0xFF0000)
                godmode_thread:terminate()
                godmode_thread = nil
            end
          
        elseif tab == 5 then
            if imgui.Button("Explodir seu carro") then
                if isCharInAnyCar(PLAYER_PED) then
                    local carhandle = storeCarCharIsInNoSave(PLAYER_PED)
                    local idcar = getCarModel(carhandle)
                    sampForceVehicleSync(carhandle)
                    explodeCar(carhandle)
                end
            end
            imgui.ToggleButton("Nao cair da moto",toggle_status_12)

        end
      
        imgui.EndChild()
        imgui.End()
    end
end

-- Event handlers corrigidos
function sampev.onClearActorAnimation(actorId)
    if toggle_status.v then
        return false
    end
    return true
end
function sampev.onApplyActorAnimationactorId(animLib ,animName ,frameDelta ,loop ,lockX ,lockY,freeze,time)
    if toggle_status.v then
        return false
    end
    return true
end

function sampev.onSetPlayerPos(position)
    if toggle_status_2.v then
        sampAddChatMessage(string.format('Servidor tentou mudar sua posicao %0.2f %0.2f %0.2f', position.x, position.y, position.z), 0xFF3C82A0)
        return false
    end
end

function sampev.onConnectionBanned()
    if toggle_status_3.v then
        return false
    end
    return true
end

function sampev.onConnectionClosed()
    if toggle_status_3.v then
        return false
    end
    return true
end

function sampev.onSendClientJoin(version, mod, nickname, challengeResponse, joinAuthKey, clientVer, challengeResponse2)
    if toggle_status_4.v then
        return false
    end
    return true
end

function sampev.onAuthenticationRequest(key)
    if toggle_status_5.v then
        return false
    end
    return true
end

function sampev.onShowMenu(menuId)
    if toggle_status_6.v then
        return false
    end
    return true
end

function sampev.onSendDialogResponse(dialogId,button,listboxId,input)
    if toggle_status_6.v then
        return false
    end
    return true
end

function sampev.onShowDialog(dialogId,style,title,button1,button2,text)
    if toggle_status_6.v then
        return false
    end
    return true
end

function sampev.onSetPlayerHealth(health)
   local health = getCharHealth(PLAYER_PED)
    if checked.v and health <= 99 then
        return false
    end
    return true
end

function sampev.onPlayerDeath(playerId)
    if checked2.v and playerId == select(2,sampGetPlayerIdByCharHandle(PLAYER_PED)) then
        return false
    end
end

function sampev.onResetPlayerWeapons()
    if toggle_status_8.v then
        return false
    end
    return true
end
function corridainfinita()
    if toggle_status_10.v then
        setPlayerNeverGetsTired (PLAYER_HANDLE,true)
    else
        setPlayerNeverGetsTired(PLAYER_HANDLE,false)
    end
end
function onSetWeaponAmmo(weaponId,ammo)
    if toggle_status_8.v then
        local ammo = getAmmoInCharWeapon(PLAYER_PED, ammo)
        if ammo <= 600 then
        return false
    end
    return true
end
end
function sampev.onResetPlayerWeapons()
    if toggle_status_11.v then
        return false
    end
    return true
end
function sampev.onDestroyWeaponPickup(id)
    if toggle_status_11.v then
        return false
    end
    return true
end
function sampev.onPlayerExitVehicle(playerId,vehicleId)
    if toggle_status_12 then
        local meuId = select(2, sampGetPlayerIdByCharHandle(PLAYER_PED))
        local playerId = sampGetPlayerNickname(meuId)
        local vehicleId = getCarModel(carhandle)
        return false
    end
    return true
end


-- Estilo do menu
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4

style.WindowRounding = 5.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 = 15.0
style.ScrollbarRounding = 9
style.GrabMinSize = 5.0
style.GrabRounding = 1.0

colors[clr.WindowBg] = imgui.ImVec4(0.10, 0.10, 0.10, 0.95)
colors[clr.ChildWindowBg] = imgui.ImVec4(0.10, 0.10, 0.10, 1.00)
colors[clr.TitleBg] = imgui.ImVec4(0.20, 0.05, 0.05, 1.00)
colors[clr.TitleBgActive] = imgui.ImVec4(0.30, 0.05, 0.05, 1.00)
colors[clr.Button] = imgui.ImVec4(0.50, 0.10, 0.10, 1.00)
colors[clr.ButtonHovered] = imgui.ImVec4(0.70, 0.20, 0.20, 1.00)
colors[clr.ButtonActive] = imgui.ImVec4(0.90, 0.30, 0.30, 1.00)
colors[clr.Text] = imgui.ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.FrameBg] = imgui.ImVec4(0.20, 0.05, 0.05, 1.00)
colors[clr.FrameBgHovered] = imgui.ImVec4(0.30, 0.10, 0.10, 1.00)
colors[clr.FrameBgActive] = imgui.ImVec4(0.40, 0.15, 0.15, 1.00)
colors[clr.Header] = imgui.ImVec4(0.50, 0.10, 0.10, 1.00)
colors[clr.HeaderHovered] = imgui.ImVec4(0.70, 0.20, 0.20, 1.00)
colors[clr.HeaderActive] = imgui.ImVec4(0.90, 0.30, 0.30, 1.00)
colors[clr.CheckMark] = imgui.ImVec4(0.90, 0.30, 0.30, 1.00)
colors[clr.SliderGrab] = imgui.ImVec4(0.70, 0.20, 0.20, 1.00)
colors[clr.SliderGrabActive] = imgui.ImVec4(0.90, 0.30, 0.30, 1.00)

Изображение меню :

Посмотреть вложение 277102
Up
 
Последнее редактирование: