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

Daysi

Новичок
2
0
Привет, опытные программисты. У меня к вам вопрос.
Как мне в коде прописать то что я сейчас объясню.
Я пишу один скрипт и мне нужно там сократить серверную команду после чего сделать возможность чтобы в ней могли использоваться указанные пользователем данные.
Теперь прямой пример. Эта команда - /fixmycar. Я хочу сократить её до /fxc. А далее как-то прописать чтобы цифры указанные в /fxc также указывались далее в /fixmycar.
Пример:
Я хочу заспавнить свою булку так как её угнали. И у меня есть моя команда /fxc. Я пишу /fxc + ид моей булки из /cars. То есть /fxc 822. Теперь команда /fxc исполнить /fixmycar и она должна учесть цифры "822" и также ввести их вместе с командой для спавна транспорта. То есть /fxc 822 = /fixmycar 822.
Товарищи программисты какие будут идеи? И надеюсь это не особо сложно чтобы вы мне ответили, а не послали куда подальше с такими запросами.
 

Rice.

Известный
Модератор
1,758
1,714
Привет, опытные программисты. У меня к вам вопрос.
Как мне в коде прописать то что я сейчас объясню.
Я пишу один скрипт и мне нужно там сократить серверную команду после чего сделать возможность чтобы в ней могли использоваться указанные пользователем данные.
Теперь прямой пример. Эта команда - /fixmycar. Я хочу сократить её до /fxc. А далее как-то прописать чтобы цифры указанные в /fxc также указывались далее в /fixmycar.
Пример:
Я хочу заспавнить свою булку так как её угнали. И у меня есть моя команда /fxc. Я пишу /fxc + ид моей булки из /cars. То есть /fxc 822. Теперь команда /fxc исполнить /fixmycar и она должна учесть цифры "822" и также ввести их вместе с командой для спавна транспорта. То есть /fxc 822 = /fixmycar 822.
Товарищи программисты какие будут идеи? И надеюсь это не особо сложно чтобы вы мне ответили, а не послали куда подальше с такими запросами.
Lua:
sampRegisterChatCommand('fxc', function(arg)
    if arg:match('%d+') then
        local arg = arg:match('%d+')
        sampSendChat('/fixmycar '..arg)
    end
end)
 
  • Нравится
Реакции: Daysi

Pashyka

Участник
220
17
Добрый день всем, такой вопрос:
"Возможно ли открыть серверный диалог, который привязан к интерьеру или к машине, на примере команды /newsredak, данная команда работает в определённом интерьере, но работает не везде, на втором этаже она системно не работает, как сделать так, чтобы данная команда открывалась по всей Инте вне зависимости от положения игрока, можно ли как-то эмулировать, что игрок находится в машине, или же находится там, где эта команда действует?
 

tsunamiqq

Участник
433
17
При нажатии на кнопку "АвтоПиар" нету менюшки, как можно решить?
Lua:
script_name('FamilyHelper v.1.0')
script_author('Lycorn')
script_description('FamilyHelper')
script_version('1.0')
require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
cp1251 = encoding.CP1251
local inicfg = require 'inicfg'
local directIni = 'moonloader\\config\\famhelper by lycorn.ini'
local mainIni = inicfg.load(nil, directIni)
local act = 0
--local stateIni = inicfg.save(mainIni, directIni)
local status = inicfg.load(mainIni, directIni)
local mainIni = inicfg.load({
    config = {
        vr=false,
        fam=false,
        j=false,
        ad=false,
        vr_text=false,
        fam_text=false,
        j_text=false,
        ad_text=false,
        vr_delay=120000,
        fam_delay=120000,
        j_delay=120000,
    }
}, "famhelper by lycorn")
inicfg.save(mainIni, 'famhelper by lycorn.ini')
local text_vr = imgui.ImBuffer(256)
local checked1 = imgui.ImBool(false)
local checked2 = imgui.ImBool(false)
local checked3 = imgui.ImBool(false)
local checked4 = imgui.ImBool(false)
local main_window_state = imgui.ImBool(false)
local checkbox = imgui.ImBool(false)
function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-1, 0)
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
        imgui.Begin('Family Helper v 1.0', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild('##tabs', imgui.ImVec2(200, 460), true)
        if imgui.Button('Настройки', imgui.ImVec2(185,50), main_window_state) then act = 0 end
        if imgui.Button('АвтоПиар', imgui.ImVec2(185,50), main_window_state) then act = 1 end
        imgui.EndChild()
        imgui.SameLine()
        if act == 0 then
            imgui.BeginChild('##once', imgui.ImVec2(860, 460), true)
            imgui.EndChild()
        elseif act == 1 then
            imgui.BeginChild('##twice', imgui.ImVec2(860, 460), true)
            imgui.SetCursorPosX(300)
            if imgui.Checkbox('/vr', checked1) then
                mainIni.config.vr = checked1.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/fam', checked2) then
                mainIni.config.fam = checked2.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/ad', checked3) then
                mainIni.config.ad = checked3.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/j', checked4) then
                mainIni.config.j = checked4.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.Separator()
            if vr.v then
                if imgui.InputText('Введите текст в /vr', text_vr, main_window_state) then
                    mainIni.config.vr_text = text_vr.v
                    inicfg.save(mainIni, "famhelper by lycorn.ini")
                end
            end
            imgui.EndChild()
        end
    end
    imgui.End()
end
if vr then
        sampSendChat("/vr "..mainIni.config.vr_text)
        inicfg.load(mainIni, 'famhelper by lycorn.ini')
        end
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(2000) end
    sampAddChatMessage(u8:decode'[FamHelper] Автор скрипта - lycorn', 0x00BFFF)
    sampAddChatMessage(u8:decode'[FamHelper] Версия скрипта - 1.0', 0x00BFFF)
    sampAddChatMessage(u8:decode'[FamHelper] Активация хелпера /famh', 0x00BFFF)
    sampAddChatMessage(u8:decode'[FamHelper] По всем вопросам пишите в ВК - @lycorn.maks', 0x00BFFF)
    sampRegisterChatCommand('famh', function() main_window_state.v = not main_window_state.v end)
    while true do
        wait(0)
        imgui.Process = main_window_state.v
        if checkbox.v then
            printStringNow('test', 1000)
        end
    end
end
function apply_custom_style()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
   
    colors[clr.Text]                 = ImVec4(1.00, 1.00, 1.00, 0.78)
    colors[clr.TextDisabled]         = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.WindowBg]             = ImVec4(0.11, 0.15, 0.17, 1.00)
    colors[clr.ChildWindowBg]        = ImVec4(0.15, 0.18, 0.22, 1.00)
    colors[clr.PopupBg]              = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.Border]               = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]         = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]              = ImVec4(0.20, 0.25, 0.29, 1.00)
    colors[clr.FrameBgHovered]       = ImVec4(0.12, 0.20, 0.28, 1.00)
    colors[clr.FrameBgActive]        = ImVec4(0.09, 0.12, 0.14, 1.00)
    colors[clr.TitleBg]              = ImVec4(0.53, 0.20, 0.16, 0.65)
    colors[clr.TitleBgActive]        = ImVec4(0.56, 0.14, 0.14, 1.00)
    colors[clr.TitleBgCollapsed]     = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.MenuBarBg]            = ImVec4(0.15, 0.18, 0.22, 1.00)
    colors[clr.ScrollbarBg]          = ImVec4(0.02, 0.02, 0.02, 0.39)
    colors[clr.ScrollbarGrab]        = ImVec4(0.20, 0.25, 0.29, 1.00)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.18, 0.22, 0.25, 1.00)
    colors[clr.ScrollbarGrabActive]  = ImVec4(0.09, 0.21, 0.31, 1.00)
    colors[clr.ComboBg]              = ImVec4(0.20, 0.25, 0.29, 1.00)
    colors[clr.CheckMark]            = ImVec4(1.00, 0.28, 0.28, 1.00)
    colors[clr.SliderGrab]           = ImVec4(0.64, 0.14, 0.14, 1.00)
    colors[clr.SliderGrabActive]     = ImVec4(1.00, 0.37, 0.37, 1.00)
    colors[clr.Button]               = ImVec4(0.59, 0.13, 0.13, 1.00)
    colors[clr.ButtonHovered]        = ImVec4(0.69, 0.15, 0.15, 1.00)
    colors[clr.ButtonActive]         = ImVec4(0.67, 0.13, 0.07, 1.00)
    colors[clr.Header]               = ImVec4(0.20, 0.25, 0.29, 0.55)
    colors[clr.HeaderHovered]        = ImVec4(0.98, 0.38, 0.26, 0.80)
    colors[clr.HeaderActive]         = ImVec4(0.98, 0.26, 0.26, 1.00)
    colors[clr.Separator]            = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.SeparatorHovered]     = ImVec4(0.60, 0.60, 0.70, 1.00)
    colors[clr.SeparatorActive]      = ImVec4(0.70, 0.70, 0.90, 1.00)
    colors[clr.ResizeGrip]           = ImVec4(0.26, 0.59, 0.98, 0.25)
    colors[clr.ResizeGripHovered]    = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.ResizeGripActive]     = ImVec4(0.06, 0.05, 0.07, 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(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.TextSelectedBg]       = ImVec4(0.25, 1.00, 0.00, 0.43)
    colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
end
apply_custom_style()
 

YarikVL

Известный
Проверенный
4,709
1,802
При нажатии на кнопку "АвтоПиар" нету менюшки, как можно решить?
Lua:
script_name('FamilyHelper v.1.0')
script_author('Lycorn')
script_description('FamilyHelper')
script_version('1.0')
require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
cp1251 = encoding.CP1251
local inicfg = require 'inicfg'
local directIni = 'moonloader\\config\\famhelper by lycorn.ini'
local mainIni = inicfg.load(nil, directIni)
local act = 0
--local stateIni = inicfg.save(mainIni, directIni)
local status = inicfg.load(mainIni, directIni)
local mainIni = inicfg.load({
    config = {
        vr=false,
        fam=false,
        j=false,
        ad=false,
        vr_text=false,
        fam_text=false,
        j_text=false,
        ad_text=false,
        vr_delay=120000,
        fam_delay=120000,
        j_delay=120000,
    }
}, "famhelper by lycorn")
inicfg.save(mainIni, 'famhelper by lycorn.ini')
local text_vr = imgui.ImBuffer(256)
local checked1 = imgui.ImBool(false)
local checked2 = imgui.ImBool(false)
local checked3 = imgui.ImBool(false)
local checked4 = imgui.ImBool(false)
local main_window_state = imgui.ImBool(false)
local checkbox = imgui.ImBool(false)
function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-1, 0)
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
        imgui.Begin('Family Helper v 1.0', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild('##tabs', imgui.ImVec2(200, 460), true)
        if imgui.Button('Настройки', imgui.ImVec2(185,50), main_window_state) then act = 0 end
        if imgui.Button('АвтоПиар', imgui.ImVec2(185,50), main_window_state) then act = 1 end
        imgui.EndChild()
        imgui.SameLine()
        if act == 0 then
            imgui.BeginChild('##once', imgui.ImVec2(860, 460), true)
            imgui.EndChild()
        elseif act == 1 then
            imgui.BeginChild('##twice', imgui.ImVec2(860, 460), true)
            imgui.SetCursorPosX(300)
            if imgui.Checkbox('/vr', checked1) then
                mainIni.config.vr = checked1.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/fam', checked2) then
                mainIni.config.fam = checked2.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/ad', checked3) then
                mainIni.config.ad = checked3.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/j', checked4) then
                mainIni.config.j = checked4.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.Separator()
            if vr.v then
                if imgui.InputText('Введите текст в /vr', text_vr, main_window_state) then
                    mainIni.config.vr_text = text_vr.v
                    inicfg.save(mainIni, "famhelper by lycorn.ini")
                end
            end
            imgui.EndChild()
        end
    end
    imgui.End()
end
if vr then
        sampSendChat("/vr "..mainIni.config.vr_text)
        inicfg.load(mainIni, 'famhelper by lycorn.ini')
        end
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(2000) end
    sampAddChatMessage(u8:decode'[FamHelper] Автор скрипта - lycorn', 0x00BFFF)
    sampAddChatMessage(u8:decode'[FamHelper] Версия скрипта - 1.0', 0x00BFFF)
    sampAddChatMessage(u8:decode'[FamHelper] Активация хелпера /famh', 0x00BFFF)
    sampAddChatMessage(u8:decode'[FamHelper] По всем вопросам пишите в ВК - @lycorn.maks', 0x00BFFF)
    sampRegisterChatCommand('famh', function() main_window_state.v = not main_window_state.v end)
    while true do
        wait(0)
        imgui.Process = main_window_state.v
        if checkbox.v then
            printStringNow('test', 1000)
        end
    end
end
function apply_custom_style()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
 
    colors[clr.Text]                 = ImVec4(1.00, 1.00, 1.00, 0.78)
    colors[clr.TextDisabled]         = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.WindowBg]             = ImVec4(0.11, 0.15, 0.17, 1.00)
    colors[clr.ChildWindowBg]        = ImVec4(0.15, 0.18, 0.22, 1.00)
    colors[clr.PopupBg]              = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.Border]               = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]         = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]              = ImVec4(0.20, 0.25, 0.29, 1.00)
    colors[clr.FrameBgHovered]       = ImVec4(0.12, 0.20, 0.28, 1.00)
    colors[clr.FrameBgActive]        = ImVec4(0.09, 0.12, 0.14, 1.00)
    colors[clr.TitleBg]              = ImVec4(0.53, 0.20, 0.16, 0.65)
    colors[clr.TitleBgActive]        = ImVec4(0.56, 0.14, 0.14, 1.00)
    colors[clr.TitleBgCollapsed]     = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.MenuBarBg]            = ImVec4(0.15, 0.18, 0.22, 1.00)
    colors[clr.ScrollbarBg]          = ImVec4(0.02, 0.02, 0.02, 0.39)
    colors[clr.ScrollbarGrab]        = ImVec4(0.20, 0.25, 0.29, 1.00)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.18, 0.22, 0.25, 1.00)
    colors[clr.ScrollbarGrabActive]  = ImVec4(0.09, 0.21, 0.31, 1.00)
    colors[clr.ComboBg]              = ImVec4(0.20, 0.25, 0.29, 1.00)
    colors[clr.CheckMark]            = ImVec4(1.00, 0.28, 0.28, 1.00)
    colors[clr.SliderGrab]           = ImVec4(0.64, 0.14, 0.14, 1.00)
    colors[clr.SliderGrabActive]     = ImVec4(1.00, 0.37, 0.37, 1.00)
    colors[clr.Button]               = ImVec4(0.59, 0.13, 0.13, 1.00)
    colors[clr.ButtonHovered]        = ImVec4(0.69, 0.15, 0.15, 1.00)
    colors[clr.ButtonActive]         = ImVec4(0.67, 0.13, 0.07, 1.00)
    colors[clr.Header]               = ImVec4(0.20, 0.25, 0.29, 0.55)
    colors[clr.HeaderHovered]        = ImVec4(0.98, 0.38, 0.26, 0.80)
    colors[clr.HeaderActive]         = ImVec4(0.98, 0.26, 0.26, 1.00)
    colors[clr.Separator]            = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.SeparatorHovered]     = ImVec4(0.60, 0.60, 0.70, 1.00)
    colors[clr.SeparatorActive]      = ImVec4(0.70, 0.70, 0.90, 1.00)
    colors[clr.ResizeGrip]           = ImVec4(0.26, 0.59, 0.98, 0.25)
    colors[clr.ResizeGripHovered]    = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.ResizeGripActive]     = ImVec4(0.06, 0.05, 0.07, 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(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.TextSelectedBg]       = ImVec4(0.25, 1.00, 0.00, 0.43)
    colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
end
apply_custom_style()
В мунлоге нечего нету?
Попробуй в 18 строке вставить это:
local mainIni = inicfg.load(inicfg.load({
В 31 строке после квадратной скобки попробуй поставить запятую
И в 32 строке в конце поставь ещё одну скобку чтобы закрыть скобку с 18 строки
 

Rice.

Известный
Модератор
1,758
1,714
При нажатии на кнопку "АвтоПиар" нету менюшки, как можно решить?
Lua:
script_name('FamilyHelper v.1.0')
script_author('Lycorn')
script_description('FamilyHelper')
script_version('1.0')
require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
cp1251 = encoding.CP1251
local inicfg = require 'inicfg'
local directIni = 'moonloader\\config\\famhelper by lycorn.ini'
local mainIni = inicfg.load(nil, directIni)
local act = 0
--local stateIni = inicfg.save(mainIni, directIni)
local status = inicfg.load(mainIni, directIni)
local mainIni = inicfg.load({
    config = {
        vr=false,
        fam=false,
        j=false,
        ad=false,
        vr_text=false,
        fam_text=false,
        j_text=false,
        ad_text=false,
        vr_delay=120000,
        fam_delay=120000,
        j_delay=120000,
    }
}, "famhelper by lycorn")
inicfg.save(mainIni, 'famhelper by lycorn.ini')
local text_vr = imgui.ImBuffer(256)
local checked1 = imgui.ImBool(false)
local checked2 = imgui.ImBool(false)
local checked3 = imgui.ImBool(false)
local checked4 = imgui.ImBool(false)
local main_window_state = imgui.ImBool(false)
local checkbox = imgui.ImBool(false)
function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-1, 0)
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
        imgui.Begin('Family Helper v 1.0', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild('##tabs', imgui.ImVec2(200, 460), true)
        if imgui.Button('Настройки', imgui.ImVec2(185,50), main_window_state) then act = 0 end
        if imgui.Button('АвтоПиар', imgui.ImVec2(185,50), main_window_state) then act = 1 end
        imgui.EndChild()
        imgui.SameLine()
        if act == 0 then
            imgui.BeginChild('##once', imgui.ImVec2(860, 460), true)
            imgui.EndChild()
        elseif act == 1 then
            imgui.BeginChild('##twice', imgui.ImVec2(860, 460), true)
            imgui.SetCursorPosX(300)
            if imgui.Checkbox('/vr', checked1) then
                mainIni.config.vr = checked1.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/fam', checked2) then
                mainIni.config.fam = checked2.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/ad', checked3) then
                mainIni.config.ad = checked3.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/j', checked4) then
                mainIni.config.j = checked4.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.Separator()
            if vr.v then
                if imgui.InputText('Введите текст в /vr', text_vr, main_window_state) then
                    mainIni.config.vr_text = text_vr.v
                    inicfg.save(mainIni, "famhelper by lycorn.ini")
                end
            end
            imgui.EndChild()
        end
    end
    imgui.End()
end
if vr then
        sampSendChat("/vr "..mainIni.config.vr_text)
        inicfg.load(mainIni, 'famhelper by lycorn.ini')
        end
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(2000) end
    sampAddChatMessage(u8:decode'[FamHelper] Автор скрипта - lycorn', 0x00BFFF)
    sampAddChatMessage(u8:decode'[FamHelper] Версия скрипта - 1.0', 0x00BFFF)
    sampAddChatMessage(u8:decode'[FamHelper] Активация хелпера /famh', 0x00BFFF)
    sampAddChatMessage(u8:decode'[FamHelper] По всем вопросам пишите в ВК - @lycorn.maks', 0x00BFFF)
    sampRegisterChatCommand('famh', function() main_window_state.v = not main_window_state.v end)
    while true do
        wait(0)
        imgui.Process = main_window_state.v
        if checkbox.v then
            printStringNow('test', 1000)
        end
    end
end
function apply_custom_style()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
  
    colors[clr.Text]                 = ImVec4(1.00, 1.00, 1.00, 0.78)
    colors[clr.TextDisabled]         = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.WindowBg]             = ImVec4(0.11, 0.15, 0.17, 1.00)
    colors[clr.ChildWindowBg]        = ImVec4(0.15, 0.18, 0.22, 1.00)
    colors[clr.PopupBg]              = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.Border]               = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]         = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]              = ImVec4(0.20, 0.25, 0.29, 1.00)
    colors[clr.FrameBgHovered]       = ImVec4(0.12, 0.20, 0.28, 1.00)
    colors[clr.FrameBgActive]        = ImVec4(0.09, 0.12, 0.14, 1.00)
    colors[clr.TitleBg]              = ImVec4(0.53, 0.20, 0.16, 0.65)
    colors[clr.TitleBgActive]        = ImVec4(0.56, 0.14, 0.14, 1.00)
    colors[clr.TitleBgCollapsed]     = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.MenuBarBg]            = ImVec4(0.15, 0.18, 0.22, 1.00)
    colors[clr.ScrollbarBg]          = ImVec4(0.02, 0.02, 0.02, 0.39)
    colors[clr.ScrollbarGrab]        = ImVec4(0.20, 0.25, 0.29, 1.00)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.18, 0.22, 0.25, 1.00)
    colors[clr.ScrollbarGrabActive]  = ImVec4(0.09, 0.21, 0.31, 1.00)
    colors[clr.ComboBg]              = ImVec4(0.20, 0.25, 0.29, 1.00)
    colors[clr.CheckMark]            = ImVec4(1.00, 0.28, 0.28, 1.00)
    colors[clr.SliderGrab]           = ImVec4(0.64, 0.14, 0.14, 1.00)
    colors[clr.SliderGrabActive]     = ImVec4(1.00, 0.37, 0.37, 1.00)
    colors[clr.Button]               = ImVec4(0.59, 0.13, 0.13, 1.00)
    colors[clr.ButtonHovered]        = ImVec4(0.69, 0.15, 0.15, 1.00)
    colors[clr.ButtonActive]         = ImVec4(0.67, 0.13, 0.07, 1.00)
    colors[clr.Header]               = ImVec4(0.20, 0.25, 0.29, 0.55)
    colors[clr.HeaderHovered]        = ImVec4(0.98, 0.38, 0.26, 0.80)
    colors[clr.HeaderActive]         = ImVec4(0.98, 0.26, 0.26, 1.00)
    colors[clr.Separator]            = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.SeparatorHovered]     = ImVec4(0.60, 0.60, 0.70, 1.00)
    colors[clr.SeparatorActive]      = ImVec4(0.70, 0.70, 0.90, 1.00)
    colors[clr.ResizeGrip]           = ImVec4(0.26, 0.59, 0.98, 0.25)
    colors[clr.ResizeGripHovered]    = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.ResizeGripActive]     = ImVec4(0.06, 0.05, 0.07, 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(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.TextSelectedBg]       = ImVec4(0.25, 1.00, 0.00, 0.43)
    colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
end
apply_custom_style()
Lua:
function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-1, 0)
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
        imgui.Begin('Family Helper v 1.0', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild('##tabs', imgui.ImVec2(200, 460), true)
        if imgui.Button('Настройки', imgui.ImVec2(185,50)) then act = 0 end
        if imgui.Button('АвтоПиар', imgui.ImVec2(185,50)) then act = 1 end
        imgui.EndChild()
        imgui.SameLine()
        if act == 0 then
            imgui.BeginChild('##once', imgui.ImVec2(860, 460), true)
            imgui.EndChild()
        end
        if act == 1 then
            imgui.BeginChild('##twice', imgui.ImVec2(860, 460), true)
            imgui.SetCursorPosX(300)
            if imgui.Checkbox('/vr', checked1) then
                mainIni.config.vr = checked1.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/fam', checked2) then
                mainIni.config.fam = checked2.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/ad', checked3) then
                mainIni.config.ad = checked3.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/j', checked4) then
                mainIni.config.j = checked4.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.Separator()
            if vr.v then
                if imgui.InputText('Введите текст в /vr', text_vr, main_window_state) then
                    mainIni.config.vr_text = text_vr.v
                    inicfg.save(mainIni, "famhelper by lycorn.ini")
                end
            end
            imgui.EndChild()
        end
    end
    imgui.End()
end
 

tsunamiqq

Участник
433
17
Lua:
function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-1, 0)
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
        imgui.Begin('Family Helper v 1.0', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild('##tabs', imgui.ImVec2(200, 460), true)
        if imgui.Button('Настройки', imgui.ImVec2(185,50)) then act = 0 end
        if imgui.Button('АвтоПиар', imgui.ImVec2(185,50)) then act = 1 end
        imgui.EndChild()
        imgui.SameLine()
        if act == 0 then
            imgui.BeginChild('##once', imgui.ImVec2(860, 460), true)
            imgui.EndChild()
        end
        if act == 1 then
            imgui.BeginChild('##twice', imgui.ImVec2(860, 460), true)
            imgui.SetCursorPosX(300)
            if imgui.Checkbox('/vr', checked1) then
                mainIni.config.vr = checked1.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/fam', checked2) then
                mainIni.config.fam = checked2.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/ad', checked3) then
                mainIni.config.ad = checked3.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/j', checked4) then
                mainIni.config.j = checked4.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.Separator()
            if vr.v then
                if imgui.InputText('Введите текст в /vr', text_vr, main_window_state) then
                    mainIni.config.vr_text = text_vr.v
                    inicfg.save(mainIni, "famhelper by lycorn.ini")
                end
            end
            imgui.EndChild()
        end
    end
    imgui.End()
end
не, не помогло

В мунлоге нечего нету?
Попробуй в 18 строке вставить это:
local mainIni = inicfg.load(inicfg.load({
В 31 строке после квадратной скобки попробуй поставить запятую
И в 32 строке в конце поставь ещё одну скобку чтобы закрыть скобку с 18 строки
не помогло, после этого ошибки тока были
 

Rice.

Известный
Модератор
1,758
1,714
При нажатии на кнопку "АвтоПиар" нету менюшки, как можно решить?
Lua:
script_name('FamilyHelper v.1.0')
script_author('Lycorn')
script_description('FamilyHelper')
script_version('1.0')
require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
cp1251 = encoding.CP1251
local inicfg = require 'inicfg'
local directIni = 'moonloader\\config\\famhelper by lycorn.ini'
local mainIni = inicfg.load(nil, directIni)
local act = 0
--local stateIni = inicfg.save(mainIni, directIni)
local status = inicfg.load(mainIni, directIni)
local mainIni = inicfg.load({
    config = {
        vr=false,
        fam=false,
        j=false,
        ad=false,
        vr_text=false,
        fam_text=false,
        j_text=false,
        ad_text=false,
        vr_delay=120000,
        fam_delay=120000,
        j_delay=120000,
    }
}, "famhelper by lycorn")
inicfg.save(mainIni, 'famhelper by lycorn.ini')
local text_vr = imgui.ImBuffer(256)
local checked1 = imgui.ImBool(false)
local checked2 = imgui.ImBool(false)
local checked3 = imgui.ImBool(false)
local checked4 = imgui.ImBool(false)
local main_window_state = imgui.ImBool(false)
local checkbox = imgui.ImBool(false)
function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-1, 0)
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
        imgui.Begin('Family Helper v 1.0', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild('##tabs', imgui.ImVec2(200, 460), true)
        if imgui.Button('Настройки', imgui.ImVec2(185,50), main_window_state) then act = 0 end
        if imgui.Button('АвтоПиар', imgui.ImVec2(185,50), main_window_state) then act = 1 end
        imgui.EndChild()
        imgui.SameLine()
        if act == 0 then
            imgui.BeginChild('##once', imgui.ImVec2(860, 460), true)
            imgui.EndChild()
        elseif act == 1 then
            imgui.BeginChild('##twice', imgui.ImVec2(860, 460), true)
            imgui.SetCursorPosX(300)
            if imgui.Checkbox('/vr', checked1) then
                mainIni.config.vr = checked1.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/fam', checked2) then
                mainIni.config.fam = checked2.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/ad', checked3) then
                mainIni.config.ad = checked3.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.SameLine()
            if imgui.Checkbox('/j', checked4) then
                mainIni.config.j = checked4.v
                inicfg.save(mainIni, 'famhelper by lycorn.ini')
            end
            imgui.Separator()
            if vr.v then
                if imgui.InputText('Введите текст в /vr', text_vr, main_window_state) then
                    mainIni.config.vr_text = text_vr.v
                    inicfg.save(mainIni, "famhelper by lycorn.ini")
                end
            end
            imgui.EndChild()
        end
    end
    imgui.End()
end
if vr then
        sampSendChat("/vr "..mainIni.config.vr_text)
        inicfg.load(mainIni, 'famhelper by lycorn.ini')
        end
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(2000) end
    sampAddChatMessage(u8:decode'[FamHelper] Автор скрипта - lycorn', 0x00BFFF)
    sampAddChatMessage(u8:decode'[FamHelper] Версия скрипта - 1.0', 0x00BFFF)
    sampAddChatMessage(u8:decode'[FamHelper] Активация хелпера /famh', 0x00BFFF)
    sampAddChatMessage(u8:decode'[FamHelper] По всем вопросам пишите в ВК - @lycorn.maks', 0x00BFFF)
    sampRegisterChatCommand('famh', function() main_window_state.v = not main_window_state.v end)
    while true do
        wait(0)
        imgui.Process = main_window_state.v
        if checkbox.v then
            printStringNow('test', 1000)
        end
    end
end
function apply_custom_style()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
  
    colors[clr.Text]                 = ImVec4(1.00, 1.00, 1.00, 0.78)
    colors[clr.TextDisabled]         = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.WindowBg]             = ImVec4(0.11, 0.15, 0.17, 1.00)
    colors[clr.ChildWindowBg]        = ImVec4(0.15, 0.18, 0.22, 1.00)
    colors[clr.PopupBg]              = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.Border]               = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]         = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]              = ImVec4(0.20, 0.25, 0.29, 1.00)
    colors[clr.FrameBgHovered]       = ImVec4(0.12, 0.20, 0.28, 1.00)
    colors[clr.FrameBgActive]        = ImVec4(0.09, 0.12, 0.14, 1.00)
    colors[clr.TitleBg]              = ImVec4(0.53, 0.20, 0.16, 0.65)
    colors[clr.TitleBgActive]        = ImVec4(0.56, 0.14, 0.14, 1.00)
    colors[clr.TitleBgCollapsed]     = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.MenuBarBg]            = ImVec4(0.15, 0.18, 0.22, 1.00)
    colors[clr.ScrollbarBg]          = ImVec4(0.02, 0.02, 0.02, 0.39)
    colors[clr.ScrollbarGrab]        = ImVec4(0.20, 0.25, 0.29, 1.00)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.18, 0.22, 0.25, 1.00)
    colors[clr.ScrollbarGrabActive]  = ImVec4(0.09, 0.21, 0.31, 1.00)
    colors[clr.ComboBg]              = ImVec4(0.20, 0.25, 0.29, 1.00)
    colors[clr.CheckMark]            = ImVec4(1.00, 0.28, 0.28, 1.00)
    colors[clr.SliderGrab]           = ImVec4(0.64, 0.14, 0.14, 1.00)
    colors[clr.SliderGrabActive]     = ImVec4(1.00, 0.37, 0.37, 1.00)
    colors[clr.Button]               = ImVec4(0.59, 0.13, 0.13, 1.00)
    colors[clr.ButtonHovered]        = ImVec4(0.69, 0.15, 0.15, 1.00)
    colors[clr.ButtonActive]         = ImVec4(0.67, 0.13, 0.07, 1.00)
    colors[clr.Header]               = ImVec4(0.20, 0.25, 0.29, 0.55)
    colors[clr.HeaderHovered]        = ImVec4(0.98, 0.38, 0.26, 0.80)
    colors[clr.HeaderActive]         = ImVec4(0.98, 0.26, 0.26, 1.00)
    colors[clr.Separator]            = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.SeparatorHovered]     = ImVec4(0.60, 0.60, 0.70, 1.00)
    colors[clr.SeparatorActive]      = ImVec4(0.70, 0.70, 0.90, 1.00)
    colors[clr.ResizeGrip]           = ImVec4(0.26, 0.59, 0.98, 0.25)
    colors[clr.ResizeGripHovered]    = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.ResizeGripActive]     = ImVec4(0.06, 0.05, 0.07, 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(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.TextSelectedBg]       = ImVec4(0.25, 1.00, 0.00, 0.43)
    colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
end
apply_custom_style()
Скинь скрипт полностью
 

Varik_Soft

Участник
72
3
Всем привет ! Мне нужно определить в какое время написал человек сообщение в чат игры, пытался с timestamp, но не вышло, подскажите что делать пожалуйста
 

Rice.

Известный
Модератор
1,758
1,714
Всем привет ! Мне нужно определить в какое время написал человек сообщение в чат игры, пытался с timestamp, но не вышло, подскажите что делать пожалуйста
Lua:
local sampev = require 'lib.samp.events'

function sampev.onServerMessage(color, text)
    if text:find('Привет') then
        sampAddChatMessage('Сообщение было отправлено в '..os.date('%H:%M:%S'), -1)
    end
end
 
  • Нравится
Реакции: Varik_Soft