Вопросы по Lua скриптингу

Общая тема для вопросов по разработке скриптов на языке программирования Lua, в частности под MoonLoader.
  • Задавая вопрос, убедитесь, что его нет в списке частых вопросов и что на него ещё не отвечали (воспользуйтесь поиском).
  • Поищите ответ в теме посвященной разработке Lua скриптов в MoonLoader
  • Отвечая, убедитесь, что ваш ответ корректен.
  • Старайтесь как можно точнее выразить мысль, а если проблема связана с кодом, то обязательно прикрепите его к сообщению, используя блок [code=lua]здесь мог бы быть ваш код[/code].
  • Если вопрос связан с MoonLoader-ом первым делом желательно поискать решение на wiki.

Частые вопросы

Как научиться писать скрипты? С чего начать?
Информация - Гайд - Всё о Lua скриптинге для MoonLoader(https://blast.hk/threads/22707/)
Как вывести текст на русском? Вместо русского текста у меня какие-то каракули.
Изменить кодировку файла скрипта на Windows-1251. В Atom: комбинация клавиш Ctrl+Shift+U, в Notepad++: меню Кодировки -> Кодировки -> Кириллица -> Windows-1251.
Как получить транспорт, в котором сидит игрок?
Lua:
local veh = storeCarCharIsInNoSave(PLAYER_PED)
Как получить свой id или id другого игрока?
Lua:
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED) -- получить свой ид
local _, id = sampGetPlayerIdByCharHandle(ped) -- получить ид другого игрока. ped - это хендл персонажа
Как проверить, что строка содержит какой-то текст?
Lua:
if string.find(str, 'текст', 1, true) then
-- строка str содержит "текст"
end
Как эмулировать нажатие игровой клавиши?
Lua:
local game_keys = require 'game.keys' -- где-нибудь в начале скрипта вне функции main

setGameKeyState(game_keys.player.FIREWEAPON, -1) -- будет сэмулировано нажатие клавиши атаки
Все иды клавиш находятся в файле moonloader/lib/game/keys.lua.
Подробнее о функции setGameKeyState здесь: lua - setgamekeystate | BlastHack — DEV_WIKI(https://www.blast.hk/wiki/lua:setgamekeystate)
Как получить id другого игрока, в которого целюсь я?
Lua:
local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE) -- получить хендл персонажа, в которого целится игрок
if valid and doesCharExist(ped) then -- если цель есть и персонаж существует
  local result, id = sampGetPlayerIdByCharHandle(ped) -- получить samp-ид игрока по хендлу персонажа
  if result then -- проверить, прошло ли получение ида успешно
    -- здесь любые действия с полученным идом игрока
  end
end
Как зарегистрировать команду чата SAMP?
Lua:
-- До бесконечного цикла/задержки
sampRegisterChatCommand("mycommand", function (param)
     -- param будет содержать весь текст введенный после команды, чтобы разделить его на аргументы используйте string.match()
    sampAddChatMessage("MyCMD", -1)
end)
Крашит игру при вызове sampSendChat. Как это исправить?
Это происходит из-за бага в SAMPFUNCS, когда производится попытка отправки пакета определенными функциями изнутри события исходящих RPC и пакетов. Исправления для этого бага нет, но есть способ не провоцировать его. Вызов sampSendChat изнутри обработчика исходящих RPC/пакетов нужно обернуть в скриптовый поток с нулевой задержкой:
Lua:
function onSendRpc(id)
  -- крашит:
  -- sampSendChat('Send RPC: ' .. id)

  -- норм:
  lua_thread.create(function()
    wait(0)
    sampSendChat('Send RPC: ' .. id)
  end)
end
 
Последнее редактирование:

McLore

Известный
559
279
можешь объяснить немного по подробнее?
1607546715200.png
 

Morse

Потрачен
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Как можно сделать что бы после нажатия кнопки Выдать панель очищалась только после того как все строки пройдут? Сейчас она очищается через время которое в задержку указываю (279 строка)

Lua:
script_name("Fast-Form")
script_author("Morse")

require "lib.moonloader"
require "lib.sampfuncs"
dlstatus = require('moonloader').download_status
local keys = require "vkeys"
local imgui = require "imgui"
local encoding = require "encoding"
local inicfg = require "inicfg"
local mainIni = inicfg.load(nil, directIni)
encoding.default = "CP1251"
u8 = encoding.UTF8

bFa, fa = pcall(require, "fAwesome5")
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
local fs80 = nil

local directIni = 'moonloader//config//Fast-Form.ini'

local mainIni = inicfg.load({
    config =
    {
        autoclean = false,
        zaderzkaform = "",
        fastopen = "[]"


    }
}, 'Fast-Form.ini')
if not doesFileExist('moonloader/config/Fast-Form.ini') then inicfg.save(mainIni, 'Fast-Form.ini') end

mForm = imgui.ImBool(false)
fOpen = imgui.ImBool(false)
clear = imgui.ImBool(mainIni.config.autoclean)
local alltext = imgui.ImBuffer(256)
local zaderzka = imgui.ImBuffer(tostring(mainIni.config.zaderzkaform), 256)

local rkeys = require 'rkeys'
imgui.HotKey = require('imgui_addons').HotKey

local tLastKeys = {}

local ActiveOpenMenu = {
    v = decodeJson(mainIni.config.fastopen)
}

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    if checkData() then log('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Файлы для работы скрипта {32CD32}загружены!') else while true do wait(0) end end
    if loadConfig() then log('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Настройки скрипта {32CD32}загружены!') end
    if loadCmd() then log('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Команды скрипта {32CD32}загружены!') end

    sampAddChatMessage("[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Запущен! Активация {32CD32}/sform", -1)

    OpenMenu = rkeys.registerHotKey(ActiveOpenMenu.v, 1, false,
    function()
        if not sampIsChatInputActive() and not sampIsDialogActive() and not mForm.v then
            mForm.v = false
            fOpen.v = true
        end
    end)

    while true do
        wait(0)

        imgui.Process = mForm.v or fOpen.v
       
    end
end

function imgui.ToggleButton(str_id, bool)
    local rBool = false

    if LastActiveTime == nil then
        LastActiveTime = {}
    end
    if LastActive == nil then
        LastActive = {}
    end

    local function ImSaturate(f)
        return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
    end
   
    local p = imgui.GetCursorScreenPos()
    local draw_list = imgui.GetWindowDrawList()

    local height = imgui.GetTextLineHeightWithSpacing()
    local width = height * 1.55
    local radius = height * 0.50
    local ANIM_SPEED = 0.15
    local butPos = imgui.GetCursorPos()

    if imgui.InvisibleButton(str_id, imgui.ImVec2(width, height)) then
        bool.v = not bool.v
        rBool = true
        LastActiveTime[tostring(str_id)] = os.clock()
        LastActive[tostring(str_id)] = true
    end

    imgui.SetCursorPos(imgui.ImVec2(butPos.x + width + 8, butPos.y + 2.5))
    imgui.Text( str_id:gsub('##.+', '') )

    local t = bool.v and 1.0 or 0.0

    if LastActive[tostring(str_id)] then
        local time = os.clock() - LastActiveTime[tostring(str_id)]
        if time <= ANIM_SPEED then
            local t_anim = ImSaturate(time / ANIM_SPEED)
            t = bool.v and t_anim or 1.0 - t_anim
        else
            LastActive[tostring(str_id)] = false
        end
    end

    local col_bg
    if bool.v then
        col_bg = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBgHovered])
    else
        col_bg = imgui.ImColor(100, 100, 100, 180):GetU32()
    end
   
    draw_list:AddRectFilled(imgui.ImVec2(p.x, p.y + (height / 6)), imgui.ImVec2(p.x + width - 1.0, p.y + (height - (height / 6))), col_bg, 5.0)
    draw_list:AddCircleFilled(imgui.ImVec2(p.x + radius + t * (width - radius * 2.0), p.y + radius), radius - 0.75, imgui.GetColorU32(bool.v and imgui.ImVec4(0.675, 1.000, 0.000, 1.000) or imgui.ImColor(150, 150, 150, 255):GetVec4()))
   
    return rBool
end

function imgui.Hint(text, delay, action)
    if imgui.IsItemHovered() then
        if go_hint == nil then go_hint = os.clock() + (delay and delay or 0.0) end
        local alpha = (os.clock() - go_hint) * 5 -- скорость появления
        if os.clock() >= go_hint then
            imgui.PushStyleVar(imgui.StyleVar.WindowPadding, imgui.ImVec2(10, 10))
            imgui.PushStyleVar(imgui.StyleVar.Alpha, (alpha <= 1.0 and alpha or 1.0))
            imgui.PushStyleColor(imgui.Col.PopupBg, imgui.ImVec4(0.11, 0.11, 0.11, 1.00))
            imgui.BeginTooltip()
            imgui.PushTextWrapPos(450)
            imgui.TextColored(imgui.GetStyle().Colors[imgui.Col.ButtonHovered], fa.ICON_FA_INFO_CIRCLE..u8' Подсказка:')
            imgui.TextUnformatted(text)
            if action ~= nil then
                imgui.TextColored(imgui.GetStyle().Colors[imgui.Col.TextDisabled], '\n'..fa.ICON_FA_SHARE..' '..action)
            end
            if not imgui.IsItemVisible() and imgui.GetStyle().Alpha == 1.0 then go_hint = nil end
            imgui.PopTextWrapPos()
            imgui.EndTooltip()
            imgui.PopStyleColor()
            imgui.PopStyleVar(2)
        end
    end
end

function imgui.InvisButton(text, size)
    imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0, 0, 0, 0))
    imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(0, 0, 0, 0))
    imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(0, 0, 0, 0))
    local button = imgui.Button(text, size)
    imgui.PopStyleColor(3)
    return button
end

function checkData()
    local bRes_Font = doesFileExist(getWorkingDirectory()..'\\Fast-Form\\fa-solid-900.ttf')
    local bFa = doesFileExist(getWorkingDirectory()..'\\lib\\fAwesome5.lua')
    if not bRes_Font or not bFa then
        sampAddChatMessage('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Отсутвуют некоторые файлы. {8A2BE2}Начало загрузки...', -1)
        createDirectory(getWorkingDirectory()..'\\Fast-Form')
        lua_thread.create(function()
            downloadFile('fa-solid-900', getWorkingDirectory()..'\\Fast-Form\\fa-solid-900.ttf', 'https://gitlab.com/uploads/-/system/personal_snippet/2014196/da3408954c85f58e0bc50cb069bfa600/fa-solid-900.ttf')
            downloadFile('fAwesome5', getWorkingDirectory()..'\\lib\\fAwesome5.lua', 'https://gitlab.com/uploads/-/system/personal_snippet/2014196/7ca8bba8732c24ed34ac27821d1c46dd/fAwesome5.lua')
            wait(50) sampAddChatMessage('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Все нужные для работы файлы загружены. {32CD32}Перезагружаюсь...', -1)
            wait(500) thisScript():reload()
        end)
        return false
    end
    return true
end

function downloadFile(name, path, link)
    if not doesFileExist(path) then
        downloadUrlToFile(link, path, function(id, status, p1, p2)
            if status == dlstatus.STATUS_ENDDOWNLOADDATA then
                log('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Файл «{8A2BE2}'..name..'{E6E6FA}»{32CD32}загружен!')
            end
        end)
        while not doesFileExist(path) do wait(0) end
    end
end

function loadConfig()
    if not doesFileExist('moonloader/config/Fast-Form.ini') then
        inicfg.save(mainIni, 'Fast-Form.ini')
        log('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Файл с настройками {FF0000}отсутсвует! {32CD32}Создан новый!')
    end
    return true
end

function loadCmd()
    sampRegisterChatCommand("sform", function() mForm.v = not mForm.v end)
    return true
end

function log(text)
    sampfuncsLog(text)
end

local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
function imgui.BeforeDrawFrame()
    if fa_font == nil then
        if not doesFileExist('moonloader\\Fast-Form\\fa-solid-900.ttf') then
            sampAddChatMessage('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Отсутсвует файл шрифта {8A2BE2}fa-solid-900.ttf {E6E6FA}в папке moonloader/Fast-Form', -1)
            sampAddChatMessage('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Запуск без него не возможен. Переустановите скрипт или обратитесь к разработчику. Скрипт отключён..', -1)
            thisScript():unload()
            return
        end
        local font_config = imgui.ImFontConfig()
        font_config.MergeMode = true
        fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/Fast-Form/fa-solid-900.ttf', 13.0, font_config, fa_glyph_ranges)
    end
    if fs80 == nil then fs80 = imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\trebucbd.ttf', 80.0, nil, imgui.GetIO().Fonts:GetGlyphRangesCyrillic()) end
end

function imgui.OnDrawFrame()
    if mForm.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(315, 130), imgui.Cond.FirstUseEver)
        imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
        imgui.Begin(fa.ICON_FA_CHECK_SQUARE .. " Fast-Form", mForm, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar)
        imgui.Text(u8"Очистка после выдачи")
        imgui.SameLine(200)
        if imgui.ToggleButton("##tb", clear)  then
            mainIni.config.autoclean = clear.v
            inicfg.save(mainIni, 'Fast-Form.ini')
        end
        imgui.SameLine(270)
        imgui.TextDisabled(fa.ICON_FA_INFO_CIRCLE)
        imgui.Hint(u8"После нажатия кнопки 'Выдать' все поле ввода очистится")
        imgui.Text(u8"Задержка между строками")
        imgui.SameLine(200)
        imgui.PushItemWidth(65)
        imgui.InputText("##inp1", zaderzka)
        imgui.SameLine(270)
        imgui.TextDisabled(fa.ICON_FA_INFO_CIRCLE)
        imgui.Hint(u8"Задержка между каждой строкой. Эта кнопка  " .. fa.ICON_FA_SAVE .. u8"  для сохранения задержки")
        imgui.SameLine()
        if imgui.InvisButton(fa.ICON_FA_SAVE .. '##ib', imgui.ImVec2(20, 20)) then
            mainIni.config.zaderzkaform = zaderzka.v
            inicfg.save(mainIni, 'Fast-Form.ini')
            sampAddChatMessage("[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Задержка сохранена и будет использована в последующих действиях!", -1)
        end
        imgui.Text(u8"Клавиша открытия меню")
        imgui.SameLine(200)
        if imgui.HotKey("##hk", ActiveOpenMenu, tLastKeys, 65) then
            rkeys.changeHotKey(OpenMenu, ActiveOpenMenu.v)
            sampAddChatMessage("[{FF4500}Fast-Form{FFFFFF}] Клавиша изменена! Старое значение: {8A2BE2}" .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {8A2BE2}" .. table.concat(rkeys.getKeysName(ActiveOpenMenu.v), " + "), -1)
            mainIni.config.fastopen = encodeJson(ActiveOpenMenu.v)
            inicfg.save(mainIni, 'Fast-Form.ini')
        end
        imgui.SameLine(270)
        imgui.TextDisabled(fa.ICON_FA_INFO_CIRCLE)
        imgui.Hint(u8"Клавиша на которую будет открыватся меню выдачи наказаний")
        if imgui.Button(fa.ICON_FA_FOLDER_OPEN .. u8" Открыть меню выдачи", imgui.ImVec2(300, 25)) then
            mForm.v = false
            fOpen.v = true
        end
        imgui.End()
    end
    if fOpen.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(470, 370), imgui.Cond.FirstUseEver)
        imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
        imgui.Begin(fa.ICON_FA_PAPER_PLANE .. u8" Выдача наказаний", fOpen, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar)
        imgui.InputTextMultiline('##inp', alltext, imgui.ImVec2(453, 305))
        if imgui.Button(fa.ICON_FA_GIFT .. u8" Выдать", imgui.ImVec2(453, 27)) then
            lua_thread.create(function()
                for line in alltext.v:gmatch('[^\r\n]+') do
                    sampSendChat(u8:decode(line))
                    wait(tonumber(zaderzka.v))
                    if clear.v then
                        alltext.v = ""
                    end
                end
            end)
        end
        imgui.End()
    end
end

function theme()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    local ImVec2 = imgui.ImVec2

    style.WindowPadding = imgui.ImVec2(8, 8)
    style.WindowRounding = 6
    style.ChildWindowRounding = 5
    style.FramePadding = imgui.ImVec2(5, 3)
    style.FrameRounding = 3.0
    style.ItemSpacing = imgui.ImVec2(5, 4)
    style.ItemInnerSpacing = imgui.ImVec2(4, 4)
    style.IndentSpacing = 21
    style.ScrollbarSize = 10.0
    style.ScrollbarRounding = 13
    style.GrabMinSize = 8
    style.GrabRounding = 1
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)

    colors[clr.Text]                   = ImVec4(0.95, 0.96, 0.98, 1.00);
    colors[clr.TextDisabled]           = ImVec4(0.29, 0.29, 0.29, 1.00);
    colors[clr.WindowBg]               = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.ChildWindowBg]          = ImVec4(0.12, 0.12, 0.12, 1.00);
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94);
    colors[clr.Border]                 = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.BorderShadow]           = ImVec4(1.00, 1.00, 1.00, 0.10);
    colors[clr.FrameBg]                = ImVec4(0.22, 0.22, 0.22, 1.00);
    colors[clr.FrameBgHovered]         = ImVec4(0.18, 0.18, 0.18, 1.00);
    colors[clr.FrameBgActive]          = ImVec4(0.09, 0.12, 0.14, 1.00);
    colors[clr.TitleBg]                = ImVec4(0.14, 0.14, 0.14, 0.81);
    colors[clr.TitleBgActive]          = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51);
    colors[clr.MenuBarBg]              = ImVec4(0.20, 0.20, 0.20, 1.00);
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.39);
    colors[clr.ScrollbarGrab]          = ImVec4(0.36, 0.36, 0.36, 1.00);
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.18, 0.22, 0.25, 1.00);
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.24, 0.24, 0.24, 1.00);
    colors[clr.ComboBg]                = ImVec4(0.24, 0.24, 0.24, 1.00);
    colors[clr.CheckMark]              = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.SliderGrab]             = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.SliderGrabActive]       = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.Button]                 = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.ButtonHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.ButtonActive]           = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.Header]                 = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.HeaderHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.HeaderActive]           = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.ResizeGrip]             = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.ResizeGripHovered]      = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.ResizeGripActive]       = ImVec4(1.00, 0.19, 0.19, 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.61, 0.61, 0.61, 1.00);
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00);
    colors[clr.PlotHistogram]          = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.18, 0.18, 1.00);
    colors[clr.TextSelectedBg]         = ImVec4(1.00, 0.32, 0.32, 1.00);
    colors[clr.ModalWindowDarkening]   = ImVec4(0.26, 0.26, 0.26, 0.60);
end
theme()
Почему выводит только команду, а остальное нет? Мне надо что бы в 1 строку все выводилось

Lua:
        imgui.Text(u8"Команда:")
        imgui.SameLine()
        imgui.PushItemWidth(50)
        imgui.InputText("##inp1", kommand)
        imgui.SameLine()
        imgui.Text(u8"Радиус:")
        imgui.SameLine()
        imgui.PushItemWidth(50)
        imgui.InputText("##inp2", radis)
        imgui.SameLine()
        imgui.Text(u8"Причина:")
        imgui.SameLine()
        imgui.PushItemWidth(50)
        imgui.InputText("##inp3", prichina)
        imgui.SameLine()
        imgui.Text("  ")
        imgui.SameLine()
        if imgui.Button(u8"Добавить",imgui.ImVec2(80, 20)) then
            alltext.v = kommand.v, radis.v, prichina.v
        end
 
Последнее редактирование:

McLore

Известный
559
279
Как можно сделать что бы после нажатия кнопки Выдать панель очищалась только после того как все строки пройдут? Сейчас она очищается через время которое в задержку указываю (279 строка)

Lua:
script_name("Fast-Form")
script_author("Morse")

require "lib.moonloader"
require "lib.sampfuncs"
dlstatus = require('moonloader').download_status
local keys = require "vkeys"
local imgui = require "imgui"
local encoding = require "encoding"
local inicfg = require "inicfg"
local mainIni = inicfg.load(nil, directIni)
encoding.default = "CP1251"
u8 = encoding.UTF8

bFa, fa = pcall(require, "fAwesome5")
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
local fs80 = nil

local directIni = 'moonloader//config//Fast-Form.ini'

local mainIni = inicfg.load({
    config =
    {
        autoclean = false,
        zaderzkaform = "",
        fastopen = "[]"


    }
}, 'Fast-Form.ini')
if not doesFileExist('moonloader/config/Fast-Form.ini') then inicfg.save(mainIni, 'Fast-Form.ini') end

mForm = imgui.ImBool(false)
fOpen = imgui.ImBool(false)
clear = imgui.ImBool(mainIni.config.autoclean)
local alltext = imgui.ImBuffer(256)
local zaderzka = imgui.ImBuffer(tostring(mainIni.config.zaderzkaform), 256)

local rkeys = require 'rkeys'
imgui.HotKey = require('imgui_addons').HotKey

local tLastKeys = {}

local ActiveOpenMenu = {
    v = decodeJson(mainIni.config.fastopen)
}

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    if checkData() then log('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Файлы для работы скрипта {32CD32}загружены!') else while true do wait(0) end end
    if loadConfig() then log('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Настройки скрипта {32CD32}загружены!') end
    if loadCmd() then log('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Команды скрипта {32CD32}загружены!') end

    sampAddChatMessage("[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Запущен! Активация {32CD32}/sform", -1)

    OpenMenu = rkeys.registerHotKey(ActiveOpenMenu.v, 1, false,
    function()
        if not sampIsChatInputActive() and not sampIsDialogActive() and not mForm.v then
            mForm.v = false
            fOpen.v = true
        end
    end)

    while true do
        wait(0)

        imgui.Process = mForm.v or fOpen.v
      
    end
end

function imgui.ToggleButton(str_id, bool)
    local rBool = false

    if LastActiveTime == nil then
        LastActiveTime = {}
    end
    if LastActive == nil then
        LastActive = {}
    end

    local function ImSaturate(f)
        return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
    end
  
    local p = imgui.GetCursorScreenPos()
    local draw_list = imgui.GetWindowDrawList()

    local height = imgui.GetTextLineHeightWithSpacing()
    local width = height * 1.55
    local radius = height * 0.50
    local ANIM_SPEED = 0.15
    local butPos = imgui.GetCursorPos()

    if imgui.InvisibleButton(str_id, imgui.ImVec2(width, height)) then
        bool.v = not bool.v
        rBool = true
        LastActiveTime[tostring(str_id)] = os.clock()
        LastActive[tostring(str_id)] = true
    end

    imgui.SetCursorPos(imgui.ImVec2(butPos.x + width + 8, butPos.y + 2.5))
    imgui.Text( str_id:gsub('##.+', '') )

    local t = bool.v and 1.0 or 0.0

    if LastActive[tostring(str_id)] then
        local time = os.clock() - LastActiveTime[tostring(str_id)]
        if time <= ANIM_SPEED then
            local t_anim = ImSaturate(time / ANIM_SPEED)
            t = bool.v and t_anim or 1.0 - t_anim
        else
            LastActive[tostring(str_id)] = false
        end
    end

    local col_bg
    if bool.v then
        col_bg = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBgHovered])
    else
        col_bg = imgui.ImColor(100, 100, 100, 180):GetU32()
    end
  
    draw_list:AddRectFilled(imgui.ImVec2(p.x, p.y + (height / 6)), imgui.ImVec2(p.x + width - 1.0, p.y + (height - (height / 6))), col_bg, 5.0)
    draw_list:AddCircleFilled(imgui.ImVec2(p.x + radius + t * (width - radius * 2.0), p.y + radius), radius - 0.75, imgui.GetColorU32(bool.v and imgui.ImVec4(0.675, 1.000, 0.000, 1.000) or imgui.ImColor(150, 150, 150, 255):GetVec4()))
  
    return rBool
end

function imgui.Hint(text, delay, action)
    if imgui.IsItemHovered() then
        if go_hint == nil then go_hint = os.clock() + (delay and delay or 0.0) end
        local alpha = (os.clock() - go_hint) * 5 -- скорость появления
        if os.clock() >= go_hint then
            imgui.PushStyleVar(imgui.StyleVar.WindowPadding, imgui.ImVec2(10, 10))
            imgui.PushStyleVar(imgui.StyleVar.Alpha, (alpha <= 1.0 and alpha or 1.0))
            imgui.PushStyleColor(imgui.Col.PopupBg, imgui.ImVec4(0.11, 0.11, 0.11, 1.00))
            imgui.BeginTooltip()
            imgui.PushTextWrapPos(450)
            imgui.TextColored(imgui.GetStyle().Colors[imgui.Col.ButtonHovered], fa.ICON_FA_INFO_CIRCLE..u8' Подсказка:')
            imgui.TextUnformatted(text)
            if action ~= nil then
                imgui.TextColored(imgui.GetStyle().Colors[imgui.Col.TextDisabled], '\n'..fa.ICON_FA_SHARE..' '..action)
            end
            if not imgui.IsItemVisible() and imgui.GetStyle().Alpha == 1.0 then go_hint = nil end
            imgui.PopTextWrapPos()
            imgui.EndTooltip()
            imgui.PopStyleColor()
            imgui.PopStyleVar(2)
        end
    end
end

function imgui.InvisButton(text, size)
    imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0, 0, 0, 0))
    imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(0, 0, 0, 0))
    imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(0, 0, 0, 0))
    local button = imgui.Button(text, size)
    imgui.PopStyleColor(3)
    return button
end

function checkData()
    local bRes_Font = doesFileExist(getWorkingDirectory()..'\\Fast-Form\\fa-solid-900.ttf')
    local bFa = doesFileExist(getWorkingDirectory()..'\\lib\\fAwesome5.lua')
    if not bRes_Font or not bFa then
        sampAddChatMessage('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Отсутвуют некоторые файлы. {8A2BE2}Начало загрузки...', -1)
        createDirectory(getWorkingDirectory()..'\\Fast-Form')
        lua_thread.create(function()
            downloadFile('fa-solid-900', getWorkingDirectory()..'\\Fast-Form\\fa-solid-900.ttf', 'https://gitlab.com/uploads/-/system/personal_snippet/2014196/da3408954c85f58e0bc50cb069bfa600/fa-solid-900.ttf')
            downloadFile('fAwesome5', getWorkingDirectory()..'\\lib\\fAwesome5.lua', 'https://gitlab.com/uploads/-/system/personal_snippet/2014196/7ca8bba8732c24ed34ac27821d1c46dd/fAwesome5.lua')
            wait(50) sampAddChatMessage('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Все нужные для работы файлы загружены. {32CD32}Перезагружаюсь...', -1)
            wait(500) thisScript():reload()
        end)
        return false
    end
    return true
end

function downloadFile(name, path, link)
    if not doesFileExist(path) then
        downloadUrlToFile(link, path, function(id, status, p1, p2)
            if status == dlstatus.STATUS_ENDDOWNLOADDATA then
                log('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Файл «{8A2BE2}'..name..'{E6E6FA}»{32CD32}загружен!')
            end
        end)
        while not doesFileExist(path) do wait(0) end
    end
end

function loadConfig()
    if not doesFileExist('moonloader/config/Fast-Form.ini') then
        inicfg.save(mainIni, 'Fast-Form.ini')
        log('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Файл с настройками {FF0000}отсутсвует! {32CD32}Создан новый!')
    end
    return true
end

function loadCmd()
    sampRegisterChatCommand("sform", function() mForm.v = not mForm.v end)
    return true
end

function log(text)
    sampfuncsLog(text)
end

local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
function imgui.BeforeDrawFrame()
    if fa_font == nil then
        if not doesFileExist('moonloader\\Fast-Form\\fa-solid-900.ttf') then
            sampAddChatMessage('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Отсутсвует файл шрифта {8A2BE2}fa-solid-900.ttf {E6E6FA}в папке moonloader/Fast-Form', -1)
            sampAddChatMessage('[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Запуск без него не возможен. Переустановите скрипт или обратитесь к разработчику. Скрипт отключён..', -1)
            thisScript():unload()
            return
        end
        local font_config = imgui.ImFontConfig()
        font_config.MergeMode = true
        fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/Fast-Form/fa-solid-900.ttf', 13.0, font_config, fa_glyph_ranges)
    end
    if fs80 == nil then fs80 = imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\trebucbd.ttf', 80.0, nil, imgui.GetIO().Fonts:GetGlyphRangesCyrillic()) end
end

function imgui.OnDrawFrame()
    if mForm.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(315, 130), imgui.Cond.FirstUseEver)
        imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
        imgui.Begin(fa.ICON_FA_CHECK_SQUARE .. " Fast-Form", mForm, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar)
        imgui.Text(u8"Очистка после выдачи")
        imgui.SameLine(200)
        if imgui.ToggleButton("##tb", clear)  then
            mainIni.config.autoclean = clear.v
            inicfg.save(mainIni, 'Fast-Form.ini')
        end
        imgui.SameLine(270)
        imgui.TextDisabled(fa.ICON_FA_INFO_CIRCLE)
        imgui.Hint(u8"После нажатия кнопки 'Выдать' все поле ввода очистится")
        imgui.Text(u8"Задержка между строками")
        imgui.SameLine(200)
        imgui.PushItemWidth(65)
        imgui.InputText("##inp1", zaderzka)
        imgui.SameLine(270)
        imgui.TextDisabled(fa.ICON_FA_INFO_CIRCLE)
        imgui.Hint(u8"Задержка между каждой строкой. Эта кнопка  " .. fa.ICON_FA_SAVE .. u8"  для сохранения задержки")
        imgui.SameLine()
        if imgui.InvisButton(fa.ICON_FA_SAVE .. '##ib', imgui.ImVec2(20, 20)) then
            mainIni.config.zaderzkaform = zaderzka.v
            inicfg.save(mainIni, 'Fast-Form.ini')
            sampAddChatMessage("[{FF4500}Fast-Form{FFFFFF}] {E6E6FA}Задержка сохранена и будет использована в последующих действиях!", -1)
        end
        imgui.Text(u8"Клавиша открытия меню")
        imgui.SameLine(200)
        if imgui.HotKey("##hk", ActiveOpenMenu, tLastKeys, 65) then
            rkeys.changeHotKey(OpenMenu, ActiveOpenMenu.v)
            sampAddChatMessage("[{FF4500}Fast-Form{FFFFFF}] Клавиша изменена! Старое значение: {8A2BE2}" .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {8A2BE2}" .. table.concat(rkeys.getKeysName(ActiveOpenMenu.v), " + "), -1)
            mainIni.config.fastopen = encodeJson(ActiveOpenMenu.v)
            inicfg.save(mainIni, 'Fast-Form.ini')
        end
        imgui.SameLine(270)
        imgui.TextDisabled(fa.ICON_FA_INFO_CIRCLE)
        imgui.Hint(u8"Клавиша на которую будет открыватся меню выдачи наказаний")
        if imgui.Button(fa.ICON_FA_FOLDER_OPEN .. u8" Открыть меню выдачи", imgui.ImVec2(300, 25)) then
            mForm.v = false
            fOpen.v = true
        end
        imgui.End()
    end
    if fOpen.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(470, 370), imgui.Cond.FirstUseEver)
        imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
        imgui.Begin(fa.ICON_FA_PAPER_PLANE .. u8" Выдача наказаний", fOpen, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar)
        imgui.InputTextMultiline('##inp', alltext, imgui.ImVec2(453, 305))
        if imgui.Button(fa.ICON_FA_GIFT .. u8" Выдать", imgui.ImVec2(453, 27)) then
            lua_thread.create(function()
                for line in alltext.v:gmatch('[^\r\n]+') do
                    sampSendChat(u8:decode(line))
                    wait(tonumber(zaderzka.v))
                    if clear.v then
                        alltext.v = ""
                    end
                end
            end)
        end
        imgui.End()
    end
end

function theme()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    local ImVec2 = imgui.ImVec2

    style.WindowPadding = imgui.ImVec2(8, 8)
    style.WindowRounding = 6
    style.ChildWindowRounding = 5
    style.FramePadding = imgui.ImVec2(5, 3)
    style.FrameRounding = 3.0
    style.ItemSpacing = imgui.ImVec2(5, 4)
    style.ItemInnerSpacing = imgui.ImVec2(4, 4)
    style.IndentSpacing = 21
    style.ScrollbarSize = 10.0
    style.ScrollbarRounding = 13
    style.GrabMinSize = 8
    style.GrabRounding = 1
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)

    colors[clr.Text]                   = ImVec4(0.95, 0.96, 0.98, 1.00);
    colors[clr.TextDisabled]           = ImVec4(0.29, 0.29, 0.29, 1.00);
    colors[clr.WindowBg]               = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.ChildWindowBg]          = ImVec4(0.12, 0.12, 0.12, 1.00);
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94);
    colors[clr.Border]                 = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.BorderShadow]           = ImVec4(1.00, 1.00, 1.00, 0.10);
    colors[clr.FrameBg]                = ImVec4(0.22, 0.22, 0.22, 1.00);
    colors[clr.FrameBgHovered]         = ImVec4(0.18, 0.18, 0.18, 1.00);
    colors[clr.FrameBgActive]          = ImVec4(0.09, 0.12, 0.14, 1.00);
    colors[clr.TitleBg]                = ImVec4(0.14, 0.14, 0.14, 0.81);
    colors[clr.TitleBgActive]          = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51);
    colors[clr.MenuBarBg]              = ImVec4(0.20, 0.20, 0.20, 1.00);
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.39);
    colors[clr.ScrollbarGrab]          = ImVec4(0.36, 0.36, 0.36, 1.00);
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.18, 0.22, 0.25, 1.00);
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.24, 0.24, 0.24, 1.00);
    colors[clr.ComboBg]                = ImVec4(0.24, 0.24, 0.24, 1.00);
    colors[clr.CheckMark]              = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.SliderGrab]             = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.SliderGrabActive]       = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.Button]                 = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.ButtonHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.ButtonActive]           = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.Header]                 = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.HeaderHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.HeaderActive]           = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.ResizeGrip]             = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.ResizeGripHovered]      = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.ResizeGripActive]       = ImVec4(1.00, 0.19, 0.19, 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.61, 0.61, 0.61, 1.00);
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00);
    colors[clr.PlotHistogram]          = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.18, 0.18, 1.00);
    colors[clr.TextSelectedBg]         = ImVec4(1.00, 0.32, 0.32, 1.00);
    colors[clr.ModalWindowDarkening]   = ImVec4(0.26, 0.26, 0.26, 0.60);
end
theme()
Почему выводит только команду, а остальное нет? Мне надо что бы в 1 строку все выводилось

Lua:
        imgui.Text(u8"Команда:")
        imgui.SameLine()
        imgui.PushItemWidth(50)
        imgui.InputText("##inp1", kommand)
        imgui.SameLine()
        imgui.Text(u8"Радиус:")
        imgui.SameLine()
        imgui.PushItemWidth(50)
        imgui.InputText("##inp2", radis)
        imgui.SameLine()
        imgui.Text(u8"Причина:")
        imgui.SameLine()
        imgui.PushItemWidth(50)
        imgui.InputText("##inp3", prichina)
        imgui.SameLine()
        imgui.Text("  ")
        imgui.SameLine()
        if imgui.Button(u8"Добавить",imgui.ImVec2(80, 20)) then
            alltext.v = kommand.v, radis.v, prichina.v
        end
Код:
if imgui.button("Выдать") then
    if buffer1.v ~= "" and buffer1.v ~= nil then
        -- выдаешь там наказания или что тебе нужно
        buffer1.v = "" -- очищаешь
    else
        sampAddChatMessage("Введите причину или закройте меню")
    end
end
 
  • Нравится
Реакции: Morse

Мурпху

Активный
211
39
help
Lua:
function imgui.OnDrawFrame()
    if GUI.windowState.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(329, 300), imgui.Cond.FirstUseEver)
        imgui.Begin('Fieryfast Software Release Version 1.0', nil, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove)
        imgui.SetCursorPos(imgui.ImVec2(5, 25))
        if imgui.Button('AimBot', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 1
        end
        imgui.SetCursorPos(imgui.ImVec2(57, 25))
        if imgui.Button('Visual', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 2
        end
        imgui.SetCursorPos(imgui.ImVec2(109, 25))
        if imgui.Button('Actor', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 3
        end
        imgui.SetCursorPos(imgui.ImVec2(161, 25))
        if imgui.Button('Vehicle', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 4
        end
        imgui.SetCursorPos(imgui.ImVec2(213, 25))
        if imgui.Button('Config', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 5
        end
        imgui.SetCursorPos(imgui.ImVec2(265, 25))
        if imgui.Button('Console', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 6
        end
            imgui.SetCursorPos(imgui.ImVec2(317,24))
            if imgui.Button('Settings', imgui.ImVec2(50,24)) then
                GUI.currentButtonID = 7
        end
        if GUI.currentButtonID == 1 then
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('Smooth', GUI.aimbot.Smooth, 1.0, 25.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('Radius', GUI.aimbot.Radius, 1.0, 300.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SafeZone', GUI.aimbot.Safe, 1.0, 300.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SuperSmooth', GUI.aimbot.SuperSmooth, 1.0, 25.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.Checkbox('Enable', GUI.aimbot.Enable)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('IsFire', GUI.aimbot.IsFire)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('VisibleCheck', GUI.aimbot.VisibleCheck)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('DynamicSmooth', GUI.aimbot.DynamicSmooth)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('CFilter', GUI.aimbot.CFilter)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('IgnoreRange', GUI.aimbot.IgnoreRange)
            imgui.SetCursorPos(imgui.ImVec2(150, 149))
            imgui.Checkbox('IgnoreStun', GUI.aimbot.IgnoreStun)
        end
        if GUI.currentButtonID == 2 then
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Line', GUI.visual.ESPLine)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Bones', GUI.visual.ESPBones)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Box', GUI.visual.ESPBox)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Info', GUI.visual.ESPInfo)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('Draw FOV', GUI.visual.DrawFOV)
        end
        if GUI.currentButtonID == 3 then
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoStun', GUI.actor.NoStun)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoFall', GUI.actor.NoFall)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoCamRestore', GUI.actor.NoCamRestore)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('InfiniteRun', GUI.actor.InfiniteRun)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('GodMode', GUI.actor.GodMode)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('AirBreak', GUI.actor.AirBreak)
        end
        if GUI.currentButtonID == 4 then
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SpeedSmooth', GUI.vehicle.SpeedSmooth, 1.0, 30.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.Checkbox('SpeedHack', GUI.vehicle.SpeedHack)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('DriveInWater', GUI.vehicle.Drive)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('FastExit', GUI.vehicle.FastExit)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('JumpBMX', GUI.vehicle.JumpBMX)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('BikeFall', GUI.vehicle.BikeFall)
        end
        if GUI.currentButtonID == 5 then
            imgui.SetCursorPosX(5)
            if imgui.Button('Load', imgui.ImVec2(310, 25)) then load_ini() end
            imgui.SetCursorPosX(5)
            if imgui.Button('Save', imgui.ImVec2(310, 25)) then save_ini() end
            imgui.SetCursorPosX(5)
            if imgui.Button('Reset', imgui.ImVec2(310, 25)) then reset_ini() end
              end
               if GUI.currentButtonID == 6 then
               imgui.SetCursorPosX(5)
               imgui.InputText('Input', input)
               imgui.SetCursorPosX(5)
                if imgui.Button('Send') then
                   if input.v == 'DEATH' or input.v == 'death' then
                    setCharHealth(PLAYER_PED, 0)
                end
                if input.v == 'RECON' or input.v == 'recon' then
                    local ip, port = sampGetCurrentServerAddress()
                    sampDisconnectWithReason(false)
                    sampConnectToServer(ip, port)
                end
                if input.v == 'RELOAD' or input.v == 'reload' then
                    sampToggleCursor(false)
                    showCursor(false)
                    thisScript():reload()
                end
                    if input.v == 'UPDATES' or input.v == 'updates' then
                        sampSendChat("/updates")
                end
                input.v = ''
            end
            imgui.Text('All comands:\n\nDEATH\nRECON\nRELOAD\nUPDATES(Very Soon...)')
        end
        if GUI.currentButtonID == 7 then
            imgui.Separator()
            if imgui.TreeNode(u8'Сменить тему') then
                if HLcfg.main.theme ~= 1 then apply_custom_style() end
                if imgui.Button(u8'Темная тема') then HLcfg.main.theme = 1; apply_custom_style() end
                GetTheme()
                if HLcfg.main.theme ~= 2 then lightBlue() end
                if imgui.Button(u8'Светло-синяя тема', imgui.SameLine()) then HLcfg.main.theme = 2; lightBlue() end
                GetTheme()
                if HLcfg.main.theme ~= 3 then redTheme() end
                if imgui.Button(u8'Красная тема', imgui.SameLine()) then HLcfg.main.theme = 3; redTheme() end
                GetTheme()
                imgui.TreePop()
            end
            imgui.End()
        end
    end
end
 

Next..

Известный
343
135
help
Lua:
function imgui.OnDrawFrame()
    if GUI.windowState.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(329, 300), imgui.Cond.FirstUseEver)
        imgui.Begin('Fieryfast Software Release Version 1.0', nil, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove)
        imgui.SetCursorPos(imgui.ImVec2(5, 25))
        if imgui.Button('AimBot', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 1
        end
        imgui.SetCursorPos(imgui.ImVec2(57, 25))
        if imgui.Button('Visual', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 2
        end
        imgui.SetCursorPos(imgui.ImVec2(109, 25))
        if imgui.Button('Actor', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 3
        end
        imgui.SetCursorPos(imgui.ImVec2(161, 25))
        if imgui.Button('Vehicle', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 4
        end
        imgui.SetCursorPos(imgui.ImVec2(213, 25))
        if imgui.Button('Config', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 5
        end
        imgui.SetCursorPos(imgui.ImVec2(265, 25))
        if imgui.Button('Console', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 6
        end
            imgui.SetCursorPos(imgui.ImVec2(317,24))
            if imgui.Button('Settings', imgui.ImVec2(50,24)) then
                GUI.currentButtonID = 7
        end
        if GUI.currentButtonID == 1 then
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('Smooth', GUI.aimbot.Smooth, 1.0, 25.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('Radius', GUI.aimbot.Radius, 1.0, 300.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SafeZone', GUI.aimbot.Safe, 1.0, 300.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SuperSmooth', GUI.aimbot.SuperSmooth, 1.0, 25.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.Checkbox('Enable', GUI.aimbot.Enable)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('IsFire', GUI.aimbot.IsFire)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('VisibleCheck', GUI.aimbot.VisibleCheck)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('DynamicSmooth', GUI.aimbot.DynamicSmooth)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('CFilter', GUI.aimbot.CFilter)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('IgnoreRange', GUI.aimbot.IgnoreRange)
            imgui.SetCursorPos(imgui.ImVec2(150, 149))
            imgui.Checkbox('IgnoreStun', GUI.aimbot.IgnoreStun)
        end
        if GUI.currentButtonID == 2 then
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Line', GUI.visual.ESPLine)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Bones', GUI.visual.ESPBones)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Box', GUI.visual.ESPBox)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Info', GUI.visual.ESPInfo)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('Draw FOV', GUI.visual.DrawFOV)
        end
        if GUI.currentButtonID == 3 then
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoStun', GUI.actor.NoStun)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoFall', GUI.actor.NoFall)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoCamRestore', GUI.actor.NoCamRestore)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('InfiniteRun', GUI.actor.InfiniteRun)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('GodMode', GUI.actor.GodMode)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('AirBreak', GUI.actor.AirBreak)
        end
        if GUI.currentButtonID == 4 then
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SpeedSmooth', GUI.vehicle.SpeedSmooth, 1.0, 30.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.Checkbox('SpeedHack', GUI.vehicle.SpeedHack)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('DriveInWater', GUI.vehicle.Drive)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('FastExit', GUI.vehicle.FastExit)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('JumpBMX', GUI.vehicle.JumpBMX)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('BikeFall', GUI.vehicle.BikeFall)
        end
        if GUI.currentButtonID == 5 then
            imgui.SetCursorPosX(5)
            if imgui.Button('Load', imgui.ImVec2(310, 25)) then load_ini() end
            imgui.SetCursorPosX(5)
            if imgui.Button('Save', imgui.ImVec2(310, 25)) then save_ini() end
            imgui.SetCursorPosX(5)
            if imgui.Button('Reset', imgui.ImVec2(310, 25)) then reset_ini() end
              end
               if GUI.currentButtonID == 6 then
               imgui.SetCursorPosX(5)
               imgui.InputText('Input', input)
               imgui.SetCursorPosX(5)
                if imgui.Button('Send') then
                   if input.v == 'DEATH' or input.v == 'death' then
                    setCharHealth(PLAYER_PED, 0)
                end
                if input.v == 'RECON' or input.v == 'recon' then
                    local ip, port = sampGetCurrentServerAddress()
                    sampDisconnectWithReason(false)
                    sampConnectToServer(ip, port)
                end
                if input.v == 'RELOAD' or input.v == 'reload' then
                    sampToggleCursor(false)
                    showCursor(false)
                    thisScript():reload()
                end
                    if input.v == 'UPDATES' or input.v == 'updates' then
                        sampSendChat("/updates")
                end
                input.v = ''
            end
            imgui.Text('All comands:\n\nDEATH\nRECON\nRELOAD\nUPDATES(Very Soon...)')
        end
        if GUI.currentButtonID == 7 then
            imgui.Separator()
            if imgui.TreeNode(u8'Сменить тему') then
                if HLcfg.main.theme ~= 1 then apply_custom_style() end
                if imgui.Button(u8'Темная тема') then HLcfg.main.theme = 1; apply_custom_style() end
                GetTheme()
                if HLcfg.main.theme ~= 2 then lightBlue() end
                if imgui.Button(u8'Светло-синяя тема', imgui.SameLine()) then HLcfg.main.theme = 2; lightBlue() end
                GetTheme()
                if HLcfg.main.theme ~= 3 then redTheme() end
                if imgui.Button(u8'Красная тема', imgui.SameLine()) then HLcfg.main.theme = 3; redTheme() end
                GetTheme()
                imgui.TreePop()
            end
            imgui.End()
        end
    end
end
?
 

Varik_Soft

Участник
72
3
Всем привет, у меня возникла такая проблема. Есть диалог в котором нужно достать текст, выглядит мой код так :

Lua:
if dialogId == 15 then
    for DialogLine in text:gmatch('[^\r\n]+') do
        name = DialogLine:match('{ffff00}(.+)(%d+)')
    end
    sampSendDialogResponse(dialogId, 1, 0, name)
    return false
end

В нем он ищет правильно текст, но обрезает последний символ, то есть к примеру если нужно найти текст "Test", он вписывает в переменную "Tes". Как можно решить данную проблему ?
 

Vettor

Новичок
6
2
Помогите сделать задержку 3 сек после запуска ракбота через defCallAdd

Код:
function onSetPosition(x, y, z)
if isCoordsInArea2d(x, y, 1150, -1765, 1155, -1775) then
runCommand('!route AutoLS')
elseif isCoordsInArea2d(x, y, 1760, -1890, 1770, -1900) then
runCommand('!route ZDLS')
elseif isCoordsInArea2d(x, y, 1755, -1107, 1761, -11011) then
runCommand('!route INTA')
end
end
 

Hatiko

Известный
Проверенный
1,471
612
Всем привет, у меня возникла такая проблема. Есть диалог в котором нужно достать текст, выглядит мой код так :

Lua:
if dialogId == 15 then
    for DialogLine in text:gmatch('[^\r\n]+') do
        name = DialogLine:match('{ffff00}(.+)(%d+)')
    end
    sampSendDialogResponse(dialogId, 1, 0, name)
    return false
end

В нем он ищет правильно текст, но обрезает последний символ, то есть к примеру если нужно найти текст "Test", он вписывает в переменную "Tes". Как можно решить данную проблему ?
Как скрипт определяет правильный ответ, у тебя есть какая-то таблица с ответами и вопросами. или как? Можешь прикрепить скрин диалога высвечивающегося. Много нюансов.