Как сделать

cenor_yt

Новичок
Автор темы
13
0
Версия MoonLoader
.026-beta
Хочу чтоб можно было изменить кнопку для телепортации на пост через MimGui. Но до меня не доходит как это сделать

code:
script_name("TESTpost")
script_version("1.1")
require 'moonloader'

inicfg = require 'inicfg'

pref = '{0d5eff}[TPPost] {ffffff}'

local sampev = require("lib.samp.events")
local imgui = require 'mimgui'
local vkeys = require 'vkeys'
local rkeys = require 'rkeys'

local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new = imgui.new

local WinState = new.bool()


function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(0) end
    sampAddChatMessage(pref..'Успешно запустился!', -1)
    -- Команды
    sampRegisterChatCommand('tpmenu', function() WinState[1] = not WinState[1] end)
    sampRegisterChatCommand("mppay", mppay)

    -- Получение координат
    local ini = inicfg.load(nil, 'spost')
    if ini == nil then
        local mainIni = inicfg.load({
        coordianate = {
            X = 0,
            Y = 0,
            Z = 0,
            }
        }, 'spost')
        inicfg.save(mainIni, "spost.ini")
    end
    while true do wait(0)
        if isKeyDown(0x78) and not sampIsChatInputActive() then
            local mainIni = inicfg.load(nil, 'spost')
            if mainIni ~= nil then
                setCharCoordinates(PLAYER_PED, mainIni.coordianate.X, mainIni.coordianate.Y, mainIni.coordianate.Z)
                sampSendChat("/tpvw 0")
                wait(1500)
                sampSendChat("/tpint 0")
                sampAddChatMessage("Телепортировали вас на пост!", -1)
            end
        end
    end
end

-- сохранение поста
sampRegisterChatCommand("spost", function()
    local ini = inicfg.load(nil, 'spost')
    if ini ~= nil then
        local sx, sy, sz = getCharCoordinates(PLAYER_PED)
        inicfg.load(nil, 'spost')
        inicfg.save({
            coordianate = {
                X = sx,
                Y = sy,
                Z = sz,
            }
        }, 'spost')
        sampAddChatMessage(pref.."Сохрнились)", -1)
    end
end)
-- сохранение поста

function mppay(param)
    id, money = param:match("^(%d+)%s+(%d+)$")
    if id ~= nil and money ~= nil then
        id1 = tonumber(id); money1 = tonumber(money)
        colvo = 0
        lua_thread.create(function()
            local change
            repeat
                if (money1 - colvo) >= 100000 then
                    change = 100000
                else
                    change = money1 - colvo
                end
                sampSendChat("/pay "..id.." "..change)
                colvo = colvo + change
                wait(1100)
            until colvo >= money1

            sampAddChatMessage(pref.."Вы успешно передали {c2ff40}"..colvo.."{125c00}$", -1)
            colvo = 0
        end)
    else
        sampAddChatMessage(pref.."Используйте /mppay [ИД] [Сумма]", -1)
    end
end
    

-- MimGUI

imgui.OnFrame(function() return WinState[1] end, function(player)
    imgui.SetNextWindowPos(imgui.ImVec2(500,500), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(200, 100), imgui.Cond.Always)
    imgui.Begin('##Window', WinState, imgui.WindowFlags.NoResize)
    imgui.End()
end)
 
  • Грустно
Реакции: recxvery