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

PanSeek

t.me/dailypanseek
Всефорумный модератор
899
1,746
когда пишу /rec 1-15 и т.д ничего не происходит
Lua:
sampRegisterChatCommand("reс", function(arg)
    local ip, port = sampGetCurrentServerAddress()
    local time = tonumber(arg)
    if arg ~= nil then
        lua_thread.create(function()
            sampSetGamestate(1)
            wait(time * 1000)
            sampConnectToServer(ip, port)
        end)
    else
        lua_thread.create(function()
            sampSetGamestate(1)
            wait(15500)
            sampConnectToServer(ip, port)
        end)
    end
end)
 
  • Нравится
Реакции: James Saula и abnomegd

abnomegd

Активный
335
35
Lua:
sampRegisterChatCommand("reс", function(arg)
    local ip, port = sampGetCurrentServerAddress()
    local time = tonumber(arg)
    if arg ~= nil then
        lua_thread.create(function()
            sampSetGamestate(1)
            wait(time * 1000)
            sampConnectToServer(ip, port)
        end)
    else
        lua_thread.create(function()
            sampSetGamestate(1)
            wait(15500)
            sampConnectToServer(ip, port)
        end)
    end
end)
это всё в main?
 

abnomegd

Активный
335
35
ну крч типо хотел сделать fastbuy через активацию в имгуи окне, метка стоит работает убираю и тоже работает fastbuy
script:
require "lib.moonloader"
local keys = require "vkeys"
local imgui = require 'imgui'
local sampev   = require 'lib.samp.events'
local inicfg = require 'inicfg'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local directIni = "moonloader\\config\\settings.ini"

local mainIni = inicfg.load(nil, directIni)

local mainIni = inicfg.load({
    hotkey = {
        bindClock = "[18,82]",
        bindInvent = "[18,83]",
        bindLock = "[18,84]"
    }
}, directIni)

local config = inicfg.load(
    {
        scriptActivation = {
            fastBuy    = true
        }
    },
    'settings'
)

local configDescriptions = {
    fastBuy    = u8'FastBuy (позволяет покупать аптечки/маски быстро)',
} 

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

local tLastKeys = {}

local ActiveClockMenu = {
    v = decodeJson(mainIni.hotkey.bindClock)
}

local ActiveInventMenu = {
    v = decodeJson(mainIni.hotkey.bindInvent)
}

local ActiveLockMenu = {
    v = decodeJson(mainIni.hotkey.bindLock)
}

main_window_state = imgui.ImBool(false)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage("[BindARP]: {FFFFFF}Скрипт загружен!", 0x5CBCFF)
    sampAddChatMessage("[FBuy]: {FFFFFF}Скрипт загружен!", 0x5CBCFF) 
    sampRegisterChatCommand("bind", cmd_bind)
    sampRegisterChatCommand("fbuy", function(arg)
        lua_thread.create(function()
            local var1, var2 = string.match(arg, "(%w+) (%d+)")
            if var1 == nil or var1 == "" or var2 == nil or var2 == "" then
                sampAddChatMessage("[FBuy]: {FFFFFF}Ошибка, небыло введено нужное количество аптечек/масок!", 0x5CBCFF)
            else
                if var1 == "heal" then
                    sampAddChatMessage("[FBuy]: {FFFFFF}Вы начали скупать: {5CBCFF}" .. var2 .. " {FFFFFF}аптечек", 0x5CBCFF)
                    for i = 0, var2 do
                        sampSendChat("/buy")
                        wait(300)
                        sampSendDialogResponse(101, 1, 3,nil)
                        wait(200)
                        sampSendDialogResponse(374, 1, 0,nil)
                        i = i + 1
                        wait(200)
                    end
                elseif var1 == "mask" then
                    sampAddChatMessage("[FBuy]: {FFFFFF}Вы начали скупать: {5CBCFF}" .. var2 .. " {FFFFFF}масок", 0x5CBCFF)
                    for i = 0, var2 do
                        sampSendChat("/buy")
                        wait(300)
                        sampSendDialogResponse(101, 1, 9,nil)
                        wait(200)
                        sampSendDialogResponse(374, 1, 0,nil)
                        i = i + 1
                        wait(200)
                    end
                end
            end
        end)
    end)

    imgui.Process = false

    bindClock = rkeys.registerHotKey(ActiveClockMenu.v, true, clockFunc)
    bindInvent = rkeys.registerHotKey(ActiveInventMenu.v, true, inventFunc)
    bindLock = rkeys.registerHotKey(ActiveLockMenu.v, true, lockFunc)


    while true do
        wait(0)

  
    end
end

function cmd_bind(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function clockFunc()
    sampSendChat("/c 60")
end

function inventFunc()
    sampSendChat("/i")
end

function lockFunc()
    sampSendChat("/lock 1")
end

function imgui.OnDrawFrame()

    if not main_window_state.v then
        imgui.Process = false
    end

    if main_window_state.v then
        local sw, sh = getScreenResolution()

        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(400, 200), imgui.Cond.FirstUseEver)
        imgui.RenderInMenu = true -- Allowing rendering menu in afk

        apply_custom_style() -- Changing gui style

        imgui.Begin('Bind', imgui.WindowFlags.NoResize)

-- Initialising checkboxes
for key, value in pairs(configDescriptions) do
    if imgui.Checkbox(value, imgui.ImBool(config.scriptActivation[key])) then
        config.scriptActivation[key] = not config.scriptActivation[key]
    end
end

        imgui.Text(u8"Посмотреть время")
        imgui.SameLine()
        if imgui.HotKey("##1", ActiveClockMenu, tLastKeys, 100) then
            rkeys.changeHotKey(bindClock, ActiveClockMenu.v)
            sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(ActiveClockMenu.v), " + "), -1)
            sampAddChatMessage("Строчное значение: {F4A460}" .. encodeJson(ActiveClockMenu.v), -1)

            mainIni.hotkey.bindClock = encodeJson(ActiveClockMenu.v)
            inicfg.save(mainIni, directIni)
        end

        imgui.Text(u8"Открыть инвентарь")
        imgui.SameLine()
        if imgui.HotKey("##2", ActiveInventMenu, tLastKeys, 100) then
            rkeys.changeHotKey(bindInvent, ActiveInventMenu.v)
            sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(ActiveInventMenu.v), " + "), -1)
            sampAddChatMessage("Строчное значение: {F4A460}" .. encodeJson(ActiveInventMenu.v), -1)

            mainIni.hotkey.bindInvent = encodeJson(ActiveInventMenu.v)
            inicfg.save(mainIni, directIni)
        end

        imgui.Text(u8"Открыть/закрыть автомобиль-мотоцикл")
        imgui.SameLine()
        if imgui.HotKey("##3", ActiveLockMenu, tLastKeys, 100) then
            rkeys.changeHotKey(bindLock, ActiveLockMenu.v)
            sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(ActiveLockMenu.v), " + "), -1)
            sampAddChatMessage("Строчное значение: {F4A460}" .. encodeJson(ActiveLockMenu.v), -1)

-- Savaing data in config while script dies
function onScriptTerminate(script, quitGame)
    if script == thisScript() then
        inicfg.save(config, 'advanceFixSettings')
    end
end

            mainIni.hotkey.bindLock = encodeJson(ActiveLockMenu.v)
            inicfg.save(mainIni, directIni)
        end

-- Setting cursor position
imgui.SetCursorPosX(imgui.GetWindowSize().x / 2.7 - imgui.CalcTextSize('Скрыть').x + imgui.GetStyle().ItemSpacing.x)
imgui.SetCursorPosY(imgui.GetWindowSize().y - imgui.CalcTextSize('Скрыть').y - imgui.GetStyle().WindowPadding.y - imgui.GetStyle().ItemSpacing.y)

-- Handles button pressing
if imgui.Button(u8'Скрыть') then
    imgui.Process = not imgui.Process
end

        imgui.End()
    end
end

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

    style.WindowPadding     = ImVec2(15, 15)
    style.WindowRounding    = 5.0
    style.FramePadding      = ImVec2(5, 5)
    style.FrameRounding     = 4.0
    style.ItemSpacing       = ImVec2(12, 8)
    style.ItemInnerSpacing  = ImVec2(8, 6)
    style.IndentSpacing     = 25.0
    style.ScrollbarSize     = 15.0
    style.ScrollbarRounding = 9.0
    style.GrabMinSize       = 5.0
    style.GrabRounding      = 3.0

    colors[clr.Text]                 = ImVec4(0.80, 0.80, 0.83, 1.00)
    colors[clr.TextDisabled]         = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.WindowBg]             = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ChildWindowBg]        = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.PopupBg]              = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.Border]               = ImVec4(0.80, 0.80, 0.83, 0.88)
    colors[clr.BorderShadow]         = ImVec4(0.92, 0.91, 0.88, 0.00)
    colors[clr.FrameBg]              = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.FrameBgHovered]       = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.FrameBgActive]        = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.TitleBg]              = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.TitleBgCollapsed]     = ImVec4(1.00, 0.98, 0.95, 0.75)
    colors[clr.TitleBgActive]        = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.MenuBarBg]            = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ScrollbarBg]          = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ScrollbarGrab]        = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.ScrollbarGrabActive]  = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ComboBg]              = ImVec4(0.19, 0.18, 0.21, 1.00)
    colors[clr.CheckMark]            = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.SliderGrab]           = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.SliderGrabActive]     = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.Button]               = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ButtonHovered]        = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.ButtonActive]         = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.Header]               = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.HeaderHovered]        = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.HeaderActive]         = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ResizeGrip]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.ResizeGripHovered]    = ImVec4(0.56, 0.56, 0.58, 1.00)
    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.40, 0.39, 0.38, 0.63)
    colors[clr.PlotLinesHovered]     = ImVec4(0.25, 1.00, 0.00, 1.00)
    colors[clr.PlotHistogram]        = ImVec4(0.40, 0.39, 0.38, 0.63)
    colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 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
 

Стэнфорд

Потрачен
1,058
540
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Через luajit пытаюсь закодировать файл, но ничего не происходит. Другие скрипты кодирует, все делаю как всегда, но тот что нужно - перестал. В чем может быть проблема?
 

Next..

Известный
343
135
ну крч типо хотел сделать fastbuy через активацию в имгуи окне, метка стоит работает убираю и тоже работает fastbuy
script:
require "lib.moonloader"
local keys = require "vkeys"
local imgui = require 'imgui'
local sampev   = require 'lib.samp.events'
local inicfg = require 'inicfg'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local directIni = "moonloader\\config\\settings.ini"

local mainIni = inicfg.load(nil, directIni)

local mainIni = inicfg.load({
    hotkey = {
        bindClock = "[18,82]",
        bindInvent = "[18,83]",
        bindLock = "[18,84]"
    }
}, directIni)

local config = inicfg.load(
    {
        scriptActivation = {
            fastBuy    = true
        }
    },
    'settings'
)

local configDescriptions = {
    fastBuy    = u8'FastBuy (позволяет покупать аптечки/маски быстро)',
} 

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

local tLastKeys = {}

local ActiveClockMenu = {
    v = decodeJson(mainIni.hotkey.bindClock)
}

local ActiveInventMenu = {
    v = decodeJson(mainIni.hotkey.bindInvent)
}

local ActiveLockMenu = {
    v = decodeJson(mainIni.hotkey.bindLock)
}

main_window_state = imgui.ImBool(false)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage("[BindARP]: {FFFFFF}Скрипт загружен!", 0x5CBCFF)
    sampAddChatMessage("[FBuy]: {FFFFFF}Скрипт загружен!", 0x5CBCFF) 
    sampRegisterChatCommand("bind", cmd_bind)
    sampRegisterChatCommand("fbuy", function(arg)
        lua_thread.create(function()
            local var1, var2 = string.match(arg, "(%w+) (%d+)")
            if var1 == nil or var1 == "" or var2 == nil or var2 == "" then
                sampAddChatMessage("[FBuy]: {FFFFFF}Ошибка, небыло введено нужное количество аптечек/масок!", 0x5CBCFF)
            else
                if var1 == "heal" then
                    sampAddChatMessage("[FBuy]: {FFFFFF}Вы начали скупать: {5CBCFF}" .. var2 .. " {FFFFFF}аптечек", 0x5CBCFF)
                    for i = 0, var2 do
                        sampSendChat("/buy")
                        wait(300)
                        sampSendDialogResponse(101, 1, 3,nil)
                        wait(200)
                        sampSendDialogResponse(374, 1, 0,nil)
                        i = i + 1
                        wait(200)
                    end
                elseif var1 == "mask" then
                    sampAddChatMessage("[FBuy]: {FFFFFF}Вы начали скупать: {5CBCFF}" .. var2 .. " {FFFFFF}масок", 0x5CBCFF)
                    for i = 0, var2 do
                        sampSendChat("/buy")
                        wait(300)
                        sampSendDialogResponse(101, 1, 9,nil)
                        wait(200)
                        sampSendDialogResponse(374, 1, 0,nil)
                        i = i + 1
                        wait(200)
                    end
                end
            end
        end)
    end)

    imgui.Process = false

    bindClock = rkeys.registerHotKey(ActiveClockMenu.v, true, clockFunc)
    bindInvent = rkeys.registerHotKey(ActiveInventMenu.v, true, inventFunc)
    bindLock = rkeys.registerHotKey(ActiveLockMenu.v, true, lockFunc)


    while true do
        wait(0)

  
    end
end

function cmd_bind(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function clockFunc()
    sampSendChat("/c 60")
end

function inventFunc()
    sampSendChat("/i")
end

function lockFunc()
    sampSendChat("/lock 1")
end

function imgui.OnDrawFrame()

    if not main_window_state.v then
        imgui.Process = false
    end

    if main_window_state.v then
        local sw, sh = getScreenResolution()

        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(400, 200), imgui.Cond.FirstUseEver)
        imgui.RenderInMenu = true -- Allowing rendering menu in afk

        apply_custom_style() -- Changing gui style

        imgui.Begin('Bind', imgui.WindowFlags.NoResize)

-- Initialising checkboxes
for key, value in pairs(configDescriptions) do
    if imgui.Checkbox(value, imgui.ImBool(config.scriptActivation[key])) then
        config.scriptActivation[key] = not config.scriptActivation[key]
    end
end

        imgui.Text(u8"Посмотреть время")
        imgui.SameLine()
        if imgui.HotKey("##1", ActiveClockMenu, tLastKeys, 100) then
            rkeys.changeHotKey(bindClock, ActiveClockMenu.v)
            sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(ActiveClockMenu.v), " + "), -1)
            sampAddChatMessage("Строчное значение: {F4A460}" .. encodeJson(ActiveClockMenu.v), -1)

            mainIni.hotkey.bindClock = encodeJson(ActiveClockMenu.v)
            inicfg.save(mainIni, directIni)
        end

        imgui.Text(u8"Открыть инвентарь")
        imgui.SameLine()
        if imgui.HotKey("##2", ActiveInventMenu, tLastKeys, 100) then
            rkeys.changeHotKey(bindInvent, ActiveInventMenu.v)
            sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(ActiveInventMenu.v), " + "), -1)
            sampAddChatMessage("Строчное значение: {F4A460}" .. encodeJson(ActiveInventMenu.v), -1)

            mainIni.hotkey.bindInvent = encodeJson(ActiveInventMenu.v)
            inicfg.save(mainIni, directIni)
        end

        imgui.Text(u8"Открыть/закрыть автомобиль-мотоцикл")
        imgui.SameLine()
        if imgui.HotKey("##3", ActiveLockMenu, tLastKeys, 100) then
            rkeys.changeHotKey(bindLock, ActiveLockMenu.v)
            sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(ActiveLockMenu.v), " + "), -1)
            sampAddChatMessage("Строчное значение: {F4A460}" .. encodeJson(ActiveLockMenu.v), -1)

-- Savaing data in config while script dies
function onScriptTerminate(script, quitGame)
    if script == thisScript() then
        inicfg.save(config, 'advanceFixSettings')
    end
end

            mainIni.hotkey.bindLock = encodeJson(ActiveLockMenu.v)
            inicfg.save(mainIni, directIni)
        end

-- Setting cursor position
imgui.SetCursorPosX(imgui.GetWindowSize().x / 2.7 - imgui.CalcTextSize('Скрыть').x + imgui.GetStyle().ItemSpacing.x)
imgui.SetCursorPosY(imgui.GetWindowSize().y - imgui.CalcTextSize('Скрыть').y - imgui.GetStyle().WindowPadding.y - imgui.GetStyle().ItemSpacing.y)

-- Handles button pressing
if imgui.Button(u8'Скрыть') then
    imgui.Process = not imgui.Process
end

        imgui.End()
    end
end

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

    style.WindowPadding     = ImVec2(15, 15)
    style.WindowRounding    = 5.0
    style.FramePadding      = ImVec2(5, 5)
    style.FrameRounding     = 4.0
    style.ItemSpacing       = ImVec2(12, 8)
    style.ItemInnerSpacing  = ImVec2(8, 6)
    style.IndentSpacing     = 25.0
    style.ScrollbarSize     = 15.0
    style.ScrollbarRounding = 9.0
    style.GrabMinSize       = 5.0
    style.GrabRounding      = 3.0

    colors[clr.Text]                 = ImVec4(0.80, 0.80, 0.83, 1.00)
    colors[clr.TextDisabled]         = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.WindowBg]             = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ChildWindowBg]        = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.PopupBg]              = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.Border]               = ImVec4(0.80, 0.80, 0.83, 0.88)
    colors[clr.BorderShadow]         = ImVec4(0.92, 0.91, 0.88, 0.00)
    colors[clr.FrameBg]              = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.FrameBgHovered]       = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.FrameBgActive]        = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.TitleBg]              = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.TitleBgCollapsed]     = ImVec4(1.00, 0.98, 0.95, 0.75)
    colors[clr.TitleBgActive]        = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.MenuBarBg]            = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ScrollbarBg]          = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ScrollbarGrab]        = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.ScrollbarGrabActive]  = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ComboBg]              = ImVec4(0.19, 0.18, 0.21, 1.00)
    colors[clr.CheckMark]            = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.SliderGrab]           = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.SliderGrabActive]     = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.Button]               = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ButtonHovered]        = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.ButtonActive]         = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.Header]               = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.HeaderHovered]        = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.HeaderActive]         = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ResizeGrip]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.ResizeGripHovered]    = ImVec4(0.56, 0.56, 0.58, 1.00)
    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.40, 0.39, 0.38, 0.63)
    colors[clr.PlotLinesHovered]     = ImVec4(0.25, 1.00, 0.00, 1.00)
    colors[clr.PlotHistogram]        = ImVec4(0.40, 0.39, 0.38, 0.63)
    colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 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
А где у тебя проверка стоит метка или нет?
 

Morse

Потрачен
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Через luajit пытаюсь закодировать файл, но ничего не происходит. Другие скрипты кодирует, все делаю как всегда, но тот что нужно - перестал. В чем может быть проблема?
ошибка в скрипте
 

Gorskin

{Reverse Developer} ✓
Проверенный
1,253
1,057
Помогите получить координаты полоски ХП в худе.
 

cobachok228

Новичок
4
1
Привет всем, столкнулся с такой проблемой. В общем решил вставить картинку в имгуи окно и когда я включаю имгуи то у меня стаёт 44 фпс, что делать? :(
img = imgui.CreateTextureFromFile(getGameDirectory() .. "\\moonloader\\resource\\fred.jpg")
imgui.Image(img, imgui.ImVec2(300, 300))

Видео: тык
 

#SameLine

Активный
417
37
Есть главное окно пример "main_gui.v" второе - информационная панель в нем не должно быть курсора "extra_gui.v", делаю в extra imgui.ShowCursor = false а в main_gui imgui.ShowCursor = true не работает, оба окна остаются без курсора, help
 

Gorskin

{Reverse Developer} ✓
Проверенный
1,253
1,057
Привет всем, столкнулся с такой проблемой. В общем решил вставить картинку в имгуи окно и когда я включаю имгуи то у меня стаёт 44 фпс, что делать? :(
img = imgui.CreateTextureFromFile(getGameDirectory() .. "\\moonloader\\resource\\fred.jpg")
imgui.Image(img, imgui.ImVec2(300, 300))

Видео: тык
img = imgui.CreateTextureFromFile(getGameDirectory() .. "\\moonloader\\resource\\fred.jpg")
вынеси из фрейма, у тебя каждый кадр идет открытие картинки. Закинь выше main() и всё
 

paulohardy

вы еще постите говно? тогда я иду к вам
Всефорумный модератор
1,892
1,256
Есть главное окно пример "main_gui.v" второе - информационная панель в нем не должно быть курсора "extra_gui.v", делаю в extra imgui.ShowCursor = false а в main_gui imgui.ShowCursor = true не работает, оба окна остаются без курсора, help
imgui.ShowCursor = main_gui.v