Вопросы по 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
 
Последнее редактирование:

kizn

О КУ)))
Всефорумный модератор
2,405
2,057
Люди, помогите ) Сохраняю buffer в конфиг. Захожу в игру, начинаю писать buffer, а экран пропадает

Code:
script_name('CMI Helper')
script_author('Wilman')

require "lib.moonloader"

local tag = '[ CMI ] Namalsk - '
local imgui = require 'imgui'
local label = 0
local keys = require  'vkeys'
local inicfg = require 'inicfg'
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local white_color = "{FFFFFF}"
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

-- Main's --

local main_menu = imgui.ImBool(false)
local main_two = imgui.ImBool(false)
local main_three = imgui.ImBool(false)
local main_four = imgui.ImBool(false)
local main_five = imgui.ImBool(false)
local main_six = imgui.ImBool(false)
local main_seven = imgui.ImBool(false)
local main_eight = imgui.ImBool(false)
local main_nine = imgui.ImBool(false)
local main_ten = imgui.ImBool(false)



-- Main's --

local inicfg = require 'inicfg'
local cfg = inicfg.load({
    Settings = {
        input = ""
    }
}, 'config')

local text_buffer = imgui.ImBuffer(u8(cfg.Settings.input), 10000)



local sw, sh = getScreenResolution()

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

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

    colors[clr.FrameBg]                = ImVec4(0.16, 0.48, 0.42, 100)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 100)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.48, 0.42, 100)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 100)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.88, 0.77, 100)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.Button]                 = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.98, 0.82, 100)
    colors[clr.Header]                 = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.10, 0.75, 0.63, 100)
    colors[clr.SeparatorActive]        = ImVec4(0.10, 0.75, 0.63, 100)
    colors[clr.ResizeGrip]             = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 100)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.81, 0.35, 100)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 100)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 100)
    colors[clr.WindowBg]               = ImVec4(0.06, 0.06, 0.06, 100)
    colors[clr.ChildWindowBg]          = ImVec4(1.00, 1.00, 1.00, 100)
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 100)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 100)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 100)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 100)
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 100)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 100)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 100)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 100)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 100)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 100)
    colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 100)
    colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 100)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 100)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 100)
end

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

        sampRegisterChatCommand("nh", function ()
            main_menu.v = not main_menu.v
            imgui.Process = main_menu.v
            imgui.ShowCursor = main_menu.v
        end)

        imgui.Process = false

        sampAddChatMessage(tag .. "{FFFFFF}А{5A90CE}ктивирован!", main_color)

        while true do
            wait(0)

            imgui.Process = main_menu.v or main_two.v or main_three.v or main_four.v or main_five.v or main_six.v or main_eight.v or main_nine.v or main_seven.v

            if main_menu.v or main_two.v or main_three.v or main_four.v or main_five.v or main_six.v or main_eight.v or main_nine.v or main_seven.v then
                    imgui.ShowCursor = true
            else
                    imgui.ShowCursor = false
            end
    end
end

function imgui.OnDrawFrame()

    if not main_menu.v and not main_two.v and not main_three.v and not main_four and not main_five.v and not main_six.v and not main_eight.v and not main_nine.v and not main_ten.v and not main_seven.v then
            imgui.Process = false
    end

    -- Main Menu --

    if main_menu.v then

        local sw, sh = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(800, 500), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin(u8'CMI Helper - Namalsk', main_menu, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

        if imgui.Button(u8'Устав', imgui.ImVec2(800,30)) then
            main_menu.v = false
            main_two.v = not main_two.v
        end

        if imgui.Button(u8'Для Заместителей', imgui.ImVec2(800,30)) then
            main_menu.v = false
            main_four.v = not main_two.v
        end

        if imgui.Button(u8'П.Р.О', imgui.ImVec2(800,30)) then
            main_menu.v = false
            main_three.v = not main_three.v
        end

        imgui.End()
    end

    -- Main Two --

    if main_two.v then

        local sw, sh = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(1100, 600), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin(u8'Устав', main_two, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

        if imgui.InputTextMultiline(u8"", text_buffer, imgui.ImVec2(1300, 550)) then
            cfg.Settings.input = u8:decode(buffer.v)
            inicfg.save(cfg, 'config')
        end

        if imgui.Button(u8'Назад', imgui.ImVec2(1100,30)) then
            main_menu.v = not main_menu.v
            main_two.v = false
        end

        imgui.End()
    end

    -- Main Three --

    if main_three.v then

        local sw, sh = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(800, 500), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin(u8'П.Р.О', main_three, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        if imgui.Button(u8'Назад', imgui.ImVec2(800,30)) then
            main_menu.v = not main_menu.v
            main_three.v = false
        end

        imgui.End()
    end

    -- Main Four --

    if main_four.v then

        local sw, sh = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(800, 500), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin(u8'Для Заместителей/Лидера', main_four, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

        if imgui.Button(u8'Увольнение', imgui.ImVec2(800,30)) then
            main_four.v = false
            main_five.v = not main_five.v
        end

        if imgui.Button(u8'Собеседование', imgui.ImVec2(800,30)) then
            main_four.v = false
            main_six.v = not main_six.v
        end

        if imgui.Button(u8'Звание', imgui.ImVec2(800,30)) then
            main_four.v = false
            main_eight.v = not main_six.v
        end

        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        if imgui.Button(u8'Назад', imgui.ImVec2(800,30)) then
            main_menu.v = not main_menu.v
            main_four.v = false
        end

        imgui.End()
    end


        -- Main Five --

    if main_five.v then

        local sw, sh = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(800, 500), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin(u8'Увольнение сотрудника', main_five, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

        if imgui.Button(u8'Увольнение По Собственному Желанию', imgui.ImVec2(800, 30)) then
            local arr = {"/do Сумка на плече.", "/do Планшет находится в сумке.", "/me движением правой руки достал планшет из сумки", "/do Планшет в руках.", "/me зашёл в раздел 'Сотрудники'", "/me удалил сотрудника из раздела, по причине : СЖ", "/do Процесс."}
            lua_thread.create(function()
                for k, v in ipairs(arr) do
                    sampSendChat(v)
                    wait(2000)
                end
                sampSetChatInputEnabled(true)
                sampSetChatInputText('/uninvite  Проф.Непригоден (СЖ)')
            end)
        end

        if imgui.Button(u8'Увольнение По Нарушению Устава', imgui.ImVec2(800, 30)) then
                local arr = {"/do Сумка на плече.", "/do Планшет находится в сумке.", "/me движением правой руки достал планшет из сумки", "/do Планшет в руках.", "/me зашёл в раздел 'Сотрудники'", "/me удалил сотрудника из раздела, по причине : Н.У", "/do Процесс."}
                lua_thread.create(function()
                        for k, v in ipairs(arr) do
                                sampSendChat(v)
                                wait(2000)
                        end
                        sampSetChatInputEnabled(true)
                        sampSetChatInputText('/uninvite  Проф.Непригоден (Н.У)')
                end)
        end

        if imgui.Button(u8'Увольнение По Прогулу Рабочего Дня', imgui.ImVec2(800, 30)) then
                local arr = {"/do Сумка на плече.", "/do Планшет находится в сумке.", "/me движением правой руки достал планшет из сумки", "/do Планшет в руках.", "/me зашёл в раздел 'Сотрудники'", "/me удалил сотрудника из раздела, по причине : Прогул Раб.Дня", "/do Процесс."}
                lua_thread.create(function()
                        for k, v in ipairs(arr) do
                                sampSendChat(v)
                                wait(2000)
                        end
                        sampSetChatInputEnabled(true)
                        sampSetChatInputText('/uninvite  Проф.Непригоден (Прогул Раб.Дня)')
                end)
        end

        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        if imgui.Button(u8'Назад', imgui.ImVec2(800,30)) then
            main_four.v = not main_four.v
            main_five.v = false
        end

            imgui.End()
        end

        -- Main Six --

        if main_six.v then

            local sw, sh = getScreenResolution()
            imgui.SetNextWindowSize(imgui.ImVec2(800, 500), imgui.Cond.FirstUseEver)
            imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

            imgui.Begin(u8'Собеседование', main_six, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

            if imgui.Button(u8'Поприветствовать', imgui.ImVec2(800, 30)) then
                local arr = {"Добрый день.", "Я так понял, вы на собеседование", "Прошу предъявить мне пакет с лицензией", "И паспортом"}
                lua_thread.create(function()
                    for k, v in ipairs(arr) do
                        sampSendChat(v)
                        wait(2000)
                    end
                    sampSetChatInputEnabled(true)
                    sampSetChatInputText('Хорошо...')
                end)
            end

            if imgui.Button(u8'Документы', imgui.ImVec2(800, 30)) then
                    local arr = {"/me протянул руку за пакетом", "/do Процесс.", "/me легким движением руки взял пакет, затем достал паспорт и лицензии", "/do Паспорт и лицензии в руках.", "/me открыл их на нужно странице, затем закрыл", "/do Лицензии и паспорт закрыты.", "/me положил лицензии и паспорт обратно, затем вернул их", "/do Процесс."}
                    lua_thread.create(function()
                            for k, v in ipairs(arr) do
                                    sampSendChat(v)
                                    wait(2000)
                            end
                            sampSetChatInputEnabled(true)
                            sampSetChatInputText('Хорошо...')
                    end)
            end

            if imgui.Button(u8'Психология', imgui.ImVec2(800, 30)) then
                    local arr = {"Сейчас будет психологический тест", "Сядьте", "/b Вставай, годен!", "/b Вставай, годен!", "Вставайте", "Вы молодец, прошли тест!"}
                    lua_thread.create(function()
                            for k, v in ipairs(arr) do
                                    sampSendChat(v)
                                    wait(2000)
                            end
                            sampSetChatInputEnabled(true)
                            sampSetChatInputText('Хорошо...')
                    end)
            end

            if imgui.Button(u8'Терминология', imgui.ImVec2(800, 30)) then
                    local arr = {"Пока я заполняю бланк, вы можете постоять", "/b ДМ, ТК, МГ в /b", "/me достал бланк с вопросами", "/me ввёл ответы кандидата", "/do Процесс.", "/me написал оценку под бланком, затем убрал его", "/do Процесс.", "/b ДМ, ТК, МГ в /b", "Хорошо..."}
                    lua_thread.create(function()
                            for k, v in ipairs(arr) do
                                    sampSendChat(v)
                                    wait(2000)
                            end
                            sampSetChatInputEnabled(true)
                            sampSetChatInputText('Я думаю, вы нам подходите.')
                    end)
            end

            if imgui.Button(u8'Годен!', imgui.ImVec2(800, 30)) then
                    local arr = {"Я вас поздравляю! Вот возьмите жетон и форму.", "/me достал пакет из под стола, затем разрезал его ножом", "/do Процесс.", "/me положил одежду и жетон на стол", "/do Процесс.", "Вот берите.", "Счастливой работы!"}
                    lua_thread.create(function()
                            for k, v in ipairs(arr) do
                                    sampSendChat(v)
                                    wait(2000)
                            end
                            sampSetChatInputEnabled(true)
                            sampSetChatInputText('/invite ')
                    end)
            end

            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            if imgui.Button(u8'Назад', imgui.ImVec2(800,30)) then
                main_five.v = not main_five.v
                main_six.v = false
            end

                imgui.End()
            end

        -- Main Eight --

        if main_eight.v then

            local sw, sh = getScreenResolution()
            imgui.SetNextWindowSize(imgui.ImVec2(800, 500), imgui.Cond.FirstUseEver)
            imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

            imgui.Begin(u8'Звание', main_eight, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

            if imgui.Button(u8'Выдать', imgui.ImVec2(800, 30)) then
                   local arr = {"Поздравляю! Ты повышен!", "/me достал жетон из правого кармана", "/do Жетон в руке.", "/me лёгким движением руки с гордостью передал его", "/do Процесс."}
                   lua_thread.create(function()
                       for k, v in ipairs(arr) do
                           sampSendChat(v)
                           wait(2000)
                       end
                       sampSetChatInputEnabled(true)
                       sampSetChatInputText('/setrank')
                    end)
            end

            if imgui.Button(u8'Забрать', imgui.ImVec2(800, 30)) then
                     local arr = {"Плохо! Отдавай свой жетон!", "/me забрал жетон у человека напротив, затем убрал его в карман", "/do Процесс.", "Можешь идти! Чтобы больше такого не повторялось"}
                     lua_thread.create(function()
                             for k, v in ipairs(arr) do
                                     sampSendChat(v)
                                     wait(2000)
                             end
                             sampSetChatInputEnabled(true)
                             sampSetChatInputText('/setrank')
                        end)
            end

            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            if imgui.Button(u8'Назад', imgui.ImVec2(800,30)) then
                main_six.v = not main_six.v
                main_eight.v = false
            end

                imgui.End()
            end
end
182 строка, у тебя нет переменной buffer
 

dondesanta

Новичок
10
0
Объясните пж, скрипт ниже ни в какую не работает без local events = require 'lib.samp.events', в чём прикол? Я не использую его.
Lua:
script_name('HACKFORREALLIFE')

local events = require 'lib.samp.events'

local tag = '[vzlom_piski]: '
main_color = 0xF0B400

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampAddChatMessage(tag..'Скрипт успе... Да кому это надо?', main_color)
        sampAddChatMessage(tag..'Автор скрипта: {FFFFFF}говнокодер{F0B400} (who? Не знаю, ну ладно)', main_color)
        sampAddChatMessage(tag..'Для активации пропиши: {FFFFFF}/free', main_color)
        sampRegisterChatCommand('free', cmd_free)
end

function cmd_free(arg)
    sampAddChatMessage(tag..'vZlOm уСпЕшНо НаЧат!', main_color)
end
 

Fott

Простреленный
3,431
2,270
Объясните пж, скрипт ниже ни в какую не работает без local events = require 'lib.samp.events', в чём прикол? Я не использую его.
Lua:
script_name('HACKFORREALLIFE')

local events = require 'lib.samp.events'

local tag = '[vzlom_piski]: '
main_color = 0xF0B400

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampAddChatMessage(tag..'Скрипт успе... Да кому это надо?', main_color)
        sampAddChatMessage(tag..'Автор скрипта: {FFFFFF}говнокодер{F0B400} (who? Не знаю, ну ладно)', main_color)
        sampAddChatMessage(tag..'Для активации пропиши: {FFFFFF}/free', main_color)
        sampRegisterChatCommand('free', cmd_free)
end

function cmd_free(arg)
    sampAddChatMessage(tag..'vZlOm уСпЕшНо НаЧат!', main_color)
end
wait(-1) в мейн добавь...
 
  • Нравится
Реакции: dondesanta

Corrygаn

Участник
225
6
У меня есть флудер состоящий из трех строк.
text_buffer1
text_buffer2
text_buffer3
Флудер:
local text_buffer1 = imgui.ImBuffer(256)
local text_buffer2 = imgui.ImBuffer(256)
local text_buffer3 = imgui.ImBuffer(256)
local text_zader1 = imgui.ImBuffer(256)
local text_zader2 = imgui.ImBuffer(256)
local text_zader3 = imgui.ImBuffer(256)

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

    stproflood = false
    ndproflood = false
    rdproflood = false

    imgui.Process = false
    apply_custom_style()

    while true do
        wait(0)

        if main_window_helper.v == false then
            imgui.Process = false
        end
    end
end

function imgui.OnDrawFrame()
    imgui.Begin("", main_window_helper, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.InputText(u8"Первая строка", text_buffer1)
    imgui.InputText(u8"Задержка", text_zader1)
    imgui.InputText(u8"Вторая строка", text_buffer2)
    imgui.InputText(u8"Задержка", text_zader2)
    imgui.InputText(u8"Третья строка", text_buffer3)
    imgui.InputText(u8"Задержка", text_zader3)
    if imgui.Button("Start flood", imgui.ImVec2(210, 40)) then
        sampAddChatMessage("[Central Market Helper]: " .. white_colour .. "Флудер активирован.", 0x256F60)
        stproflood = true
        ndproflood = true
        rdproflood = true
    end
    imgui.SameLine()
    imgui.SameLine()
    if imgui.Button("End flood", imgui.ImVec2(210, 40)) then
        sampAddChatMessage("[Central Market Helper]: " .. white_colour .. "Флудер деактивирован.", 0x256F60)
        stproflood = false
        ndproflood = false
        rdproflood = false
    end
    imgui.End()
end

function stproflood()
    while true do
        wait(text_zader1.v)
        if stproflood then
            sampSendChat(u8:decode(text_buffer1.v))
        end
    end
end

function ndproflood()
    while true do
        wait(text_zader2.v)
        if ndproflood then
            sampSendChat(u8:decode(text_buffer2.v))
        end
    end
end

function rdproflood()
    while true do
        wait(text_zader3.v)
        if rdproflood then
            sampSendChat(u8:decode(text_buffer3.v))
        end
    end
end
Как сделать так,, чтобы по нажатию кнопки "Start flood", текст записанный в text_buffer1, text_buffer2 и text_buffer3 сохранялся в .ini
P.S. text_zader1/2/3 - это инпут текст для задержки между отправкой флудера.
 
Последнее редактирование:

KIBERSTALKER

Участник
30
2
Вопрос к вам люди. Как сделать чтобы сохранялись Buffer? Я уже и так и сяк, и менял переменные, в итоге они нифега не сохраняются. Либо сохраняются, но потом исчезают. Мне нужно 2 и больше Buffer. Помогите

Code:
script_name('CMI Helper')
script_author('Wilman')

require "lib.moonloader"

local tag = '[ CMI ] Namalsk - '
local imgui = require 'imgui'
local label = 0
local keys = require  'vkeys'
local inicfg = require 'inicfg'
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local white_color = "{FFFFFF}"
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

-- Main's --

local main_menu = imgui.ImBool(false)
local main_two = imgui.ImBool(false)
local main_three = imgui.ImBool(false)
local main_four = imgui.ImBool(false)
local main_five = imgui.ImBool(false)
local main_six = imgui.ImBool(false)
local main_seven = imgui.ImBool(false)
local main_eight = imgui.ImBool(false)
local main_nine = imgui.ImBool(false)
local main_ten = imgui.ImBool(false)



-- Main's --

local inicfg = require 'inicfg'
local cfg = inicfg.load({
    Settings = {
        input = ""
    }
}, 'config')

local inicfg1 = require 'inicfg'
local cfg1 = inicfg1.load({
    Settings = {
        input = ""
    }
}, 'config1')

local text_buffer = imgui.ImBuffer(u8(cfg.Settings.input), 10000)
local buffer = imgui.ImBuffer(u8(cfg.Settings.input), 10000)



local sw, sh = getScreenResolution()

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

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

    colors[clr.FrameBg]                = ImVec4(0.16, 0.48, 0.42, 100)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 100)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.48, 0.42, 100)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 100)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.88, 0.77, 100)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.Button]                 = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.98, 0.82, 100)
    colors[clr.Header]                 = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.10, 0.75, 0.63, 100)
    colors[clr.SeparatorActive]        = ImVec4(0.10, 0.75, 0.63, 100)
    colors[clr.ResizeGrip]             = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 100)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.81, 0.35, 100)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.98, 0.85, 100)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 100)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 100)
    colors[clr.WindowBg]               = ImVec4(0.06, 0.06, 0.06, 100)
    colors[clr.ChildWindowBg]          = ImVec4(1.00, 1.00, 1.00, 100)
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 100)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 100)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 100)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 100)
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 100)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 100)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 100)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 100)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 100)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 100)
    colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 100)
    colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 100)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 100)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 100)
end

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

        sampRegisterChatCommand("nh", function ()
            main_menu.v = not main_menu.v
            imgui.Process = main_menu.v
            imgui.ShowCursor = main_menu.v
        end)

        imgui.Process = false

        sampAddChatMessage(tag .. "{FFFFFF}А{5A90CE}ктивирован!", main_color)

        while true do
            wait(0)

            imgui.Process = main_menu.v or main_two.v or main_three.v or main_four.v or main_five.v or main_six.v or main_eight.v or main_nine.v or main_seven.v

            if main_menu.v or main_two.v or main_three.v or main_four.v or main_five.v or main_six.v or main_eight.v or main_nine.v or main_seven.v then
                    imgui.ShowCursor = true
            else
                    imgui.ShowCursor = false
            end
    end
end

function imgui.OnDrawFrame()

    if not main_menu.v and not main_two.v and not main_three.v and not main_four and not main_five.v and not main_six.v and not main_eight.v and not main_nine.v and not main_ten.v and not main_seven.v then
            imgui.Process = false
    end

    -- Main Menu --

    if main_menu.v then

        local sw, sh = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(800, 500), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin(u8'CMI Helper - Namalsk', main_menu, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

        if imgui.Button(u8'Устав', imgui.ImVec2(800,30)) then
            main_menu.v = false
            main_two.v = not main_two.v
        end

        if imgui.Button(u8'Для Заместителей', imgui.ImVec2(800,30)) then
            main_menu.v = false
            main_four.v = not main_two.v
        end

        if imgui.Button(u8'П.Р.О', imgui.ImVec2(800,30)) then
            main_menu.v = false
            main_three.v = not main_three.v
        end

        imgui.End()
    end

    -- Main Two --

    if main_two.v then

        local sw, sh = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(1100, 600), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin(u8'Устав', main_two, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

        if imgui.InputTextMultiline(u8"", text_buffer, imgui.ImVec2(1300, 550)) then
            cfg.Settings.input = u8:decode(text_buffer.v)
            inicfg.save(cfg, 'config')
        end

        if imgui.Button(u8'Назад', imgui.ImVec2(1100,30)) then
            main_menu.v = not main_menu.v
            main_two.v = false
        end

        imgui.End()
    end

    -- Main Three --

    if main_three.v then

        local sw, sh = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(1100, 600), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin(u8'П.Р.О', main_three, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

        if imgui.InputTextMultiline(u8"", buffer, imgui.ImVec2(1100, 535)) then
            cfg.Settings.input = u8:decode(buffer.v)
            inicfg1.save(cfg1, 'config1')
        end

        if imgui.Button(u8'Назад', imgui.ImVec2(1100,25)) then
            main_menu.v = not main_menu.v
            main_three.v = false
        end

        imgui.End()
    end

    -- Main Four --

    if main_four.v then

        local sw, sh = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(800, 500), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin(u8'Для Заместителей/Лидера', main_four, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

        if imgui.Button(u8'Увольнение', imgui.ImVec2(800,30)) then
            main_four.v = false
            main_five.v = not main_five.v
        end

        if imgui.Button(u8'Собеседование', imgui.ImVec2(800,30)) then
            main_four.v = false
            main_six.v = not main_six.v
        end

        if imgui.Button(u8'Звание', imgui.ImVec2(800,30)) then
            main_four.v = false
            main_eight.v = not main_six.v
        end

        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        if imgui.Button(u8'Назад', imgui.ImVec2(800,30)) then
            main_menu.v = not main_menu.v
            main_four.v = false
        end

        imgui.End()
    end


        -- Main Five --

    if main_five.v then

        local sw, sh = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(800, 500), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin(u8'Увольнение сотрудника', main_five, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

        if imgui.Button(u8'Увольнение По Собственному Желанию', imgui.ImVec2(800, 30)) then
            local arr = {"/do Сумка на плече.", "/do Планшет находится в сумке.", "/me движением правой руки достал планшет из сумки", "/do Планшет в руках.", "/me зашёл в раздел 'Сотрудники'", "/me удалил сотрудника из раздела, по причине : СЖ", "/do Процесс."}
            lua_thread.create(function()
                for k, v in ipairs(arr) do
                    sampSendChat(v)
                    wait(2000)
                end
                sampSetChatInputEnabled(true)
                sampSetChatInputText('/uninvite  Проф.Непригоден (СЖ)')
            end)
        end

        if imgui.Button(u8'Увольнение По Нарушению Устава', imgui.ImVec2(800, 30)) then
                local arr = {"/do Сумка на плече.", "/do Планшет находится в сумке.", "/me движением правой руки достал планшет из сумки", "/do Планшет в руках.", "/me зашёл в раздел 'Сотрудники'", "/me удалил сотрудника из раздела, по причине : Н.У", "/do Процесс."}
                lua_thread.create(function()
                        for k, v in ipairs(arr) do
                                sampSendChat(v)
                                wait(2000)
                        end
                        sampSetChatInputEnabled(true)
                        sampSetChatInputText('/uninvite  Проф.Непригоден (Н.У)')
                end)
        end

        if imgui.Button(u8'Увольнение По Прогулу Рабочего Дня', imgui.ImVec2(800, 30)) then
                local arr = {"/do Сумка на плече.", "/do Планшет находится в сумке.", "/me движением правой руки достал планшет из сумки", "/do Планшет в руках.", "/me зашёл в раздел 'Сотрудники'", "/me удалил сотрудника из раздела, по причине : Прогул Раб.Дня", "/do Процесс."}
                lua_thread.create(function()
                        for k, v in ipairs(arr) do
                                sampSendChat(v)
                                wait(2000)
                        end
                        sampSetChatInputEnabled(true)
                        sampSetChatInputText('/uninvite  Проф.Непригоден (Прогул Раб.Дня)')
                end)
        end

        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        imgui.Text(" ")
        if imgui.Button(u8'Назад', imgui.ImVec2(800,30)) then
            main_four.v = not main_four.v
            main_five.v = false
        end

            imgui.End()
        end

        -- Main Six --

        if main_six.v then

            local sw, sh = getScreenResolution()
            imgui.SetNextWindowSize(imgui.ImVec2(800, 500), imgui.Cond.FirstUseEver)
            imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

            imgui.Begin(u8'Собеседование', main_six, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

            if imgui.Button(u8'Поприветствовать', imgui.ImVec2(800, 30)) then
                local arr = {"Добрый день.", "Я так понял, вы на собеседование", "Прошу предъявить мне пакет с лицензией", "И паспортом"}
                lua_thread.create(function()
                    for k, v in ipairs(arr) do
                        sampSendChat(v)
                        wait(2000)
                    end
                    sampSetChatInputEnabled(true)
                    sampSetChatInputText('Хорошо...')
                end)
            end

            if imgui.Button(u8'Документы', imgui.ImVec2(800, 30)) then
                    local arr = {"/me протянул руку за пакетом", "/do Процесс.", "/me легким движением руки взял пакет, затем достал паспорт и лицензии", "/do Паспорт и лицензии в руках.", "/me открыл их на нужно странице, затем закрыл", "/do Лицензии и паспорт закрыты.", "/me положил лицензии и паспорт обратно, затем вернул их", "/do Процесс."}
                    lua_thread.create(function()
                            for k, v in ipairs(arr) do
                                    sampSendChat(v)
                                    wait(2000)
                            end
                            sampSetChatInputEnabled(true)
                            sampSetChatInputText('Хорошо...')
                    end)
            end

            if imgui.Button(u8'Психология', imgui.ImVec2(800, 30)) then
                    local arr = {"Сейчас будет психологический тест", "Сядьте", "/b Вставай, годен!", "/b Вставай, годен!", "Вставайте", "Вы молодец, прошли тест!"}
                    lua_thread.create(function()
                            for k, v in ipairs(arr) do
                                    sampSendChat(v)
                                    wait(2000)
                            end
                            sampSetChatInputEnabled(true)
                            sampSetChatInputText('Хорошо...')
                    end)
            end

            if imgui.Button(u8'Терминология', imgui.ImVec2(800, 30)) then
                    local arr = {"Пока я заполняю бланк, вы можете постоять", "/b ДМ, ТК, МГ в /b", "/me достал бланк с вопросами", "/me ввёл ответы кандидата", "/do Процесс.", "/me написал оценку под бланком, затем убрал его", "/do Процесс.", "/b ДМ, ТК, МГ в /b", "Хорошо..."}
                    lua_thread.create(function()
                            for k, v in ipairs(arr) do
                                    sampSendChat(v)
                                    wait(2000)
                            end
                            sampSetChatInputEnabled(true)
                            sampSetChatInputText('Я думаю, вы нам подходите.')
                    end)
            end

            if imgui.Button(u8'Годен!', imgui.ImVec2(800, 30)) then
                    local arr = {"Я вас поздравляю! Вот возьмите жетон и форму.", "/me достал пакет из под стола, затем разрезал его ножом", "/do Процесс.", "/me положил одежду и жетон на стол", "/do Процесс.", "Вот берите.", "Счастливой работы!"}
                    lua_thread.create(function()
                            for k, v in ipairs(arr) do
                                    sampSendChat(v)
                                    wait(2000)
                            end
                            sampSetChatInputEnabled(true)
                            sampSetChatInputText('/invite ')
                    end)
            end

            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            if imgui.Button(u8'Назад', imgui.ImVec2(800,30)) then
                main_five.v = not main_five.v
                main_six.v = false
            end

                imgui.End()
            end

        -- Main Eight --

        if main_eight.v then

            local sw, sh = getScreenResolution()
            imgui.SetNextWindowSize(imgui.ImVec2(800, 500), imgui.Cond.FirstUseEver)
            imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

            imgui.Begin(u8'Звание', main_eight, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse)

            if imgui.Button(u8'Выдать', imgui.ImVec2(800, 30)) then
                   local arr = {"Поздравляю! Ты повышен!", "/me достал жетон из правого кармана", "/do Жетон в руке.", "/me лёгким движением руки с гордостью передал его", "/do Процесс."}
                   lua_thread.create(function()
                       for k, v in ipairs(arr) do
                           sampSendChat(v)
                           wait(2000)
                       end
                       sampSetChatInputEnabled(true)
                       sampSetChatInputText('/setrank')
                    end)
            end

            if imgui.Button(u8'Забрать', imgui.ImVec2(800, 30)) then
                     local arr = {"Плохо! Отдавай свой жетон!", "/me забрал жетон у человека напротив, затем убрал его в карман", "/do Процесс.", "Можешь идти! Чтобы больше такого не повторялось"}
                     lua_thread.create(function()
                             for k, v in ipairs(arr) do
                                     sampSendChat(v)
                                     wait(2000)
                             end
                             sampSetChatInputEnabled(true)
                             sampSetChatInputText('/setrank')
                        end)
            end

            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            imgui.Text(" ")
            if imgui.Button(u8'Назад', imgui.ImVec2(800,30)) then
                main_six.v = not main_six.v
                main_eight.v = false
            end

                imgui.End()
            end
end
 

F. Salisburry

Участник
42
11
Как сделать функцию, чтобы при появлении серверного маркера на карте выполнялось определенное действие?
1617799309138.png

Название маркера: Enemy Attack
 

Fott

Простреленный
3,431
2,270

Corrygаn

Участник
225
6
У меня есть флудер состоящий из трех строк.
text_buffer1
text_buffer2
text_buffer3
Как сделать так,, чтобы по нажатию кнопки "Start flood", текст записанный в text_buffer1, text_buffer2 и text_buffer3 сохранялся в .ini
P.S. text_zader1/2/3 - это инпут текст для задержки между отправкой флудера.
Флудер:
local text_buffer1 = imgui.ImBuffer(256)
local text_buffer2 = imgui.ImBuffer(256)
local text_buffer3 = imgui.ImBuffer(256)
local text_zader1 = imgui.ImBuffer(256)
local text_zader2 = imgui.ImBuffer(256)
local text_zader3 = imgui.ImBuffer(256)

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

    stproflood = false
    ndproflood = false
    rdproflood = false

    imgui.Process = false
    apply_custom_style()

    while true do
        wait(0)

        if main_window_helper.v == false then
            imgui.Process = false
        end
    end
end

function imgui.OnDrawFrame()
    imgui.Begin("", main_window_helper, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.InputText(u8"Первая строка", text_buffer1)
    imgui.InputText(u8"Задержка", text_zader1)
    imgui.InputText(u8"Вторая строка", text_buffer2)
    imgui.InputText(u8"Задержка", text_zader2)
    imgui.InputText(u8"Третья строка", text_buffer3)
    imgui.InputText(u8"Задержка", text_zader3)
    if imgui.Button("Start flood", imgui.ImVec2(210, 40)) then
        sampAddChatMessage("[Central Market Helper]: " .. white_colour .. "Флудер активирован.", 0x256F60)
        stproflood = true
        ndproflood = true
        rdproflood = true
    end
    imgui.SameLine()
    imgui.SameLine()
    if imgui.Button("End flood", imgui.ImVec2(210, 40)) then
        sampAddChatMessage("[Central Market Helper]: " .. white_colour .. "Флудер деактивирован.", 0x256F60)
        stproflood = false
        ndproflood = false
        rdproflood = false
    end
    imgui.End()
end

function stproflood()
    while true do
        wait(text_zader1.v)
        if stproflood then
            sampSendChat(u8:decode(text_buffer1.v))
        end
    end
end

function ndproflood()
    while true do
        wait(text_zader2.v)
        if ndproflood then
            sampSendChat(u8:decode(text_buffer2.v))
        end
    end
end

function rdproflood()
    while true do
        wait(text_zader3.v)
        if rdproflood then
            sampSendChat(u8:decode(text_buffer3.v))
        end
    end
end