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

tsunamiqq

Участник
433
17
Как узнать количество пользователей скриптом через код, и вывести это в окно mimgui
 

Дядя Энрик.

Активный
321
75
какой используется радиобуттон?
это обычный или функция?
1693785709790.png
 
  • Эм
Реакции: qdIbp и Akionka

KyRDa

Участник
85
37
Как можно с помощью этой функции сделать анимацию появления меню из нижней части экрана? До конца не понял как это реализовать в скрипте, правильно не получилось чтобы оно работало

Lua:
local imgui = require 'mimgui'

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

local new = imgui.new
local WinState = new.bool()

imgui.OnFrame(function() return WinState[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 300, 100
        imgui.SetNextWindowBgAlpha(0.0)
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('', _, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoMove + imgui.WindowFlags.NoScrollbar + imgui.WindowFlags.NoScrollWithMouse)
 
        local dl = imgui.GetWindowDrawList()
        local p = imgui.GetCursorScreenPos()

        local style = imgui.GetStyle()
        local windowRounding = style.WindowRounding
        local windowColor = imgui.ColorConvertFloat4ToU32(style.Colors[imgui.Col.WindowBg])

        dl:AddRectFilled(imgui.ImVec2(p.x + 10, p.y), imgui.ImVec2(p.x + 290, p.y + 80), windowColor, windowRounding, 10)
        dl:AddRectFilled(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x + 10, p.y + 80), 0xFC2F2CCC, windowRounding, 5)
        dl:AddRectFilledMultiColor(imgui.ImVec2(p.x + 10, p.y), imgui.ImVec2(p.x + 150, p.y + 80), 0xFC2F2CCC, 0x00000000, 0x00000000, 0xFC2F2CCC)

        imgui.End()
    end
)

function main()
    sampRegisterChatCommand('cmd', function() WinState[0] = not WinState[0] end)
    wait(-1)
end

function bringVec2To(from, to, start_time, duration)
    local timer = os.clock() - start_time
    if timer >= 0.00 and timer <= duration then
        local count = timer / (duration / 100)
        return imgui.ImVec2(
            from.x + (count * (to.x - from.x) / 100),
            from.y + (count * (to.y - from.y) / 100)
        ), true
    end
    return (timer > duration) and to or from, false
end

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    theme()
end)

function theme()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    imgui.GetStyle().WindowPadding = imgui.ImVec2(5, 5)
    imgui.GetStyle().FramePadding = imgui.ImVec2(5, 5)
    imgui.GetStyle().ItemSpacing = imgui.ImVec2(5, 5)
    imgui.GetStyle().ItemInnerSpacing = imgui.ImVec2(2, 2)
    imgui.GetStyle().TouchExtraPadding = imgui.ImVec2(0, 0)
    imgui.GetStyle().IndentSpacing = 0
    imgui.GetStyle().ScrollbarSize = 10
    imgui.GetStyle().GrabMinSize = 10
    --==[ BORDER ]==--
    imgui.GetStyle().WindowBorderSize = 0
    imgui.GetStyle().ChildBorderSize = 1
    imgui.GetStyle().PopupBorderSize = 1
    imgui.GetStyle().FrameBorderSize = 1
    imgui.GetStyle().TabBorderSize = 1
    --==[ ROUNDING ]==--
    imgui.GetStyle().WindowRounding = 8
    imgui.GetStyle().ChildRounding = 8
    imgui.GetStyle().FrameRounding = 8
    imgui.GetStyle().PopupRounding = 8
    imgui.GetStyle().ScrollbarRounding = 8
    imgui.GetStyle().GrabRounding = 8
    imgui.GetStyle().TabRounding = 8
    colors[clr.FrameBg]                = ImVec4(0.16, 0.48, 0.42, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.98, 0.85, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.98, 0.85, 0.67)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.48, 0.42, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.88, 0.77, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.Button]                 = ImVec4(0.26, 0.98, 0.85, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.98, 0.82, 1.00)
    colors[clr.Header]                 = ImVec4(0.26, 0.98, 0.85, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.98, 0.85, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.10, 0.75, 0.63, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.10, 0.75, 0.63, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.26, 0.98, 0.85, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.98, 0.85, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.98, 0.85, 0.95)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.81, 0.35, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.98, 0.85, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.WindowBg]               = ImVec4(0.12, 0.12, 0.12, 0.94)
    colors[clr.ChildBg]          = ImVec4(1.00, 1.00, 1.00, 0.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.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 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)
end

Lua:
local timer = nil
local edit = imgui.new.float[4](1.00, 1.00, 1.00, 1.00)
local duration = imgui.new.float[1](1.00)
local col = {
    old = imgui.ImVec4(edit[0], edit[1], edit[2], edit[3]),
    new = imgui.ImVec4(edit[0], edit[1], edit[2], edit[3])
}
function bringVec4To(from, to, start_time, duration)
    local timer = os.clock() - start_time
    if timer >= 0.00 and timer <= duration then
        local count = timer / (duration / 100)
        return imgui.ImVec4(
            from.x + (count * (to.x - from.x) / 100),
            from.y + (count * (to.y - from.y) / 100),
            from.z + (count * (to.z - from.z) / 100),
            from.w + (count * (to.w - from.w) / 100)
        ), true
    end
    return (timer > duration) and to or from, false
end
AnimButton = function(label, size, duration)
    if type(duration) ~= "table" then
        duration = { 1.0, 0.3 }
    end

    local cols = {
        default = imgui.ImVec4(imgui.GetStyle().Colors[imgui.Col.Button]),
        hovered = imgui.ImVec4(imgui.GetStyle().Colors[imgui.Col.ButtonHovered]),
        active  = imgui.ImVec4(imgui.GetStyle().Colors[imgui.Col.ButtonActive])
    }

    if UI_ANIMBUT == nil then
        UI_ANIMBUT = {}
    end
    if not UI_ANIMBUT[label] then
        UI_ANIMBUT[label] = {
            color = cols.default,
            clicked = { nil, nil },
            hovered = {
                cur = false,
                old = false,
                clock = nil,
            }
        }
    end
    local pool = UI_ANIMBUT[label]

    if pool["clicked"][1] and pool["clicked"][2] then
        if os.clock() - pool["clicked"][1] <= duration[2] then
            pool["color"] = bringVec4To(
                pool["color"],
                cols.active,
                pool["clicked"][1],
                duration[2]
            )
            goto no_hovered
        end

        if os.clock() - pool["clicked"][2] <= duration[2] then
            pool["color"] = bringVec4To(
                pool["color"],
                pool["hovered"]["cur"] and cols.hovered or cols.default,
                pool["clicked"][2],
                duration[2]
            )
            goto no_hovered
        end
    end

    if pool["hovered"]["clock"] ~= nil then
        if os.clock() - pool["hovered"]["clock"] <= duration[1] then
            pool["color"] = bringVec4To(
                pool["color"],
                pool["hovered"]["cur"] and cols.hovered or cols.default,
                pool["hovered"]["clock"],
                duration[1]
            )
        else
            pool["color"] = pool["hovered"]["cur"] and cols.hovered or cols.default
        end
    end

    ::no_hovered::

    imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(pool["color"]))
    imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(pool["color"]))
    imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(pool["color"]))
    local result = imgui.Button(label, size or imgui.ImVec2(0, 0))
    imgui.PopStyleColor(3)

    if result then
        pool["clicked"] = {
            os.clock(),
            os.clock() + duration[2]
        }
    end

    pool["hovered"]["cur"] = imgui.IsItemHovered()
    if pool["hovered"]["old"] ~= pool["hovered"]["cur"] then
        pool["hovered"]["old"] = pool["hovered"]["cur"]
        pool["hovered"]["clock"] = os.clock()
    end

    return result
end
Вызывать так
Lua:
AnimButton(текст, размер, продолжительность)
 

Вложения

  • 1693837854820.png
    1693837854820.png
    53.2 KB · Просмотры: 16

kyrtion

Известный
764
277
какой используется радиобуттон?
это обычный или функция?
Посмотреть вложение 214225
1. узнать позиция курсора, расширить так чтобы было прямо.
2. рендерить на AddCircleFilled, и теперь иконка срисовать в кнопке
3. добавить на проверку нажатий, если нажал то выполнить функцию
4. переходим на сет курсор пос справо, если будет еще одна кнопка.

общем, тебе следует создать новую функцию, как radiobutton в аддон мимгуи
 

KyRDa

Участник
85
37
  • Нравится
Реакции: Дядя Энрик.

kyrtion

Известный
764
277
Это больше похоже на скруглённую кнопку, чем на радио
Lua:
imgui.PushStyleVarFloat(imgui.StyleVar.FrameRounding, 12)
imgui.Button('', imgui.ImVec2(20, 20))
imgui.PopStyleVar()
в imgui.button не округляется углов, к примеру, 40 углов чтобы было прям круг без ступеньки
 
  • Нравится
Реакции: KyRDa

tsunamiqq

Участник
433
17
он про то сколько людей скриптом пользуются
такое есть в VACS,но с использованием SNET вроде,и то криво
Верно

если ты про это вообще
Lua:
sampGetPlayerCount(false) -- true, кол-в игроков в зоне стрима
Я про это
он про то сколько людей скриптом пользуются
такое есть в VACS,но с использованием SNET вроде,и то криво
 

Heav

Активный
185
70
Lua:
local timer = nil
local edit = imgui.new.float[4](1.00, 1.00, 1.00, 1.00)
local duration = imgui.new.float[1](1.00)
local col = {
    old = imgui.ImVec4(edit[0], edit[1], edit[2], edit[3]),
    new = imgui.ImVec4(edit[0], edit[1], edit[2], edit[3])
}
function bringVec4To(from, to, start_time, duration)
    local timer = os.clock() - start_time
    if timer >= 0.00 and timer <= duration then
        local count = timer / (duration / 100)
        return imgui.ImVec4(
            from.x + (count * (to.x - from.x) / 100),
            from.y + (count * (to.y - from.y) / 100),
            from.z + (count * (to.z - from.z) / 100),
            from.w + (count * (to.w - from.w) / 100)
        ), true
    end
    return (timer > duration) and to or from, false
end
AnimButton = function(label, size, duration)
    if type(duration) ~= "table" then
        duration = { 1.0, 0.3 }
    end

    local cols = {
        default = imgui.ImVec4(imgui.GetStyle().Colors[imgui.Col.Button]),
        hovered = imgui.ImVec4(imgui.GetStyle().Colors[imgui.Col.ButtonHovered]),
        active  = imgui.ImVec4(imgui.GetStyle().Colors[imgui.Col.ButtonActive])
    }

    if UI_ANIMBUT == nil then
        UI_ANIMBUT = {}
    end
    if not UI_ANIMBUT[label] then
        UI_ANIMBUT[label] = {
            color = cols.default,
            clicked = { nil, nil },
            hovered = {
                cur = false,
                old = false,
                clock = nil,
            }
        }
    end
    local pool = UI_ANIMBUT[label]

    if pool["clicked"][1] and pool["clicked"][2] then
        if os.clock() - pool["clicked"][1] <= duration[2] then
            pool["color"] = bringVec4To(
                pool["color"],
                cols.active,
                pool["clicked"][1],
                duration[2]
            )
            goto no_hovered
        end

        if os.clock() - pool["clicked"][2] <= duration[2] then
            pool["color"] = bringVec4To(
                pool["color"],
                pool["hovered"]["cur"] and cols.hovered or cols.default,
                pool["clicked"][2],
                duration[2]
            )
            goto no_hovered
        end
    end

    if pool["hovered"]["clock"] ~= nil then
        if os.clock() - pool["hovered"]["clock"] <= duration[1] then
            pool["color"] = bringVec4To(
                pool["color"],
                pool["hovered"]["cur"] and cols.hovered or cols.default,
                pool["hovered"]["clock"],
                duration[1]
            )
        else
            pool["color"] = pool["hovered"]["cur"] and cols.hovered or cols.default
        end
    end

    ::no_hovered::

    imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(pool["color"]))
    imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(pool["color"]))
    imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(pool["color"]))
    local result = imgui.Button(label, size or imgui.ImVec2(0, 0))
    imgui.PopStyleColor(3)

    if result then
        pool["clicked"] = {
            os.clock(),
            os.clock() + duration[2]
        }
    end

    pool["hovered"]["cur"] = imgui.IsItemHovered()
    if pool["hovered"]["old"] ~= pool["hovered"]["cur"] then
        pool["hovered"]["old"] = pool["hovered"]["cur"]
        pool["hovered"]["clock"] = os.clock()
    end

    return result
end
Вызывать так
Lua:
AnimButton(текст, размер, продолжительность)

Не совсем то, что я имел в виду.

То что я имел в виду:
Lua:
local imgui = require('mimgui')
local renderWindow = imgui.new.bool(true)

local animation = {
    start = 0,
    pos = imgui.ImVec2(0, 0)
}

imgui.OnFrame(
    function() return renderWindow[0] end,
    function(this)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 290, 200
        imgui.SetNextWindowBgAlpha(0.0)
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        if (imgui.Begin('Main Window', renderWindow)) then
            if (imgui.Button('Start')) then
                animation.start = os.clock()
            end

            local style = imgui.GetStyle()
            local windowRounding = style.WindowRounding
            local windowColor = imgui.ColorConvertFloat4ToU32(style.Colors[imgui.Col.WindowBg])

            local dl = imgui.GetWindowDrawList()
            animation.pos = bringVec2To(imgui.ImVec2(0, 200), imgui.ImVec2(0, 0), animation.start, 0.5)
            imgui.SetCursorPos(animation.pos)
            local p = imgui.GetCursorScreenPos()
            dl:AddRectFilled(imgui.ImVec2(p.x + 10, p.y + 100), imgui.ImVec2(p.x + 290, p.y + 180), windowColor, windowRounding, 10)
            dl:AddRectFilled(imgui.ImVec2(p.x, p.y + 100), imgui.ImVec2(p.x + 10, p.y + 180), 0xFC2F2CCC, windowRounding, 5)
            dl:AddRectFilledMultiColor(imgui.ImVec2(p.x + 10, p.y + 100), imgui.ImVec2(p.x + 150, p.y + 180), 0xFC2F2CCC, 0x00000000, 0x00000000, 0xFC2F2CCC)

            imgui.End()
        end
    end
)

function bringVec2To(from, to, start_time, duration)
    local timer = os.clock() - start_time
    if timer >= 0.00 and timer <= duration then
        local count = timer / (duration / 100)
        return imgui.ImVec2(
            from.x + (count * (to.x - from.x) / 100),
            from.y + (count * (to.y - from.y) / 100)
        ), true
    end
    return (timer > duration) and to or from, false
end

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    theme()
end)

function theme()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    imgui.GetStyle().WindowPadding = imgui.ImVec2(5, 5)
    imgui.GetStyle().FramePadding = imgui.ImVec2(5, 5)
    imgui.GetStyle().ItemSpacing = imgui.ImVec2(5, 5)
    imgui.GetStyle().ItemInnerSpacing = imgui.ImVec2(2, 2)
    imgui.GetStyle().TouchExtraPadding = imgui.ImVec2(0, 0)
    imgui.GetStyle().IndentSpacing = 0
    imgui.GetStyle().ScrollbarSize = 10
    imgui.GetStyle().GrabMinSize = 10
    --==[ BORDER ]==--
    imgui.GetStyle().WindowBorderSize = 1
    imgui.GetStyle().ChildBorderSize = 1
    imgui.GetStyle().PopupBorderSize = 1
    imgui.GetStyle().FrameBorderSize = 1
    imgui.GetStyle().TabBorderSize = 1
    --==[ ROUNDING ]==--
    imgui.GetStyle().WindowRounding = 8
    imgui.GetStyle().ChildRounding = 8
    imgui.GetStyle().FrameRounding = 8
    imgui.GetStyle().PopupRounding = 8
    imgui.GetStyle().ScrollbarRounding = 8
    imgui.GetStyle().GrabRounding = 8
    imgui.GetStyle().TabRounding = 8
    colors[clr.FrameBg]                = ImVec4(0.16, 0.48, 0.42, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.98, 0.85, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.98, 0.85, 0.67)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.48, 0.42, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.88, 0.77, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.Button]                 = ImVec4(0.26, 0.98, 0.85, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.98, 0.82, 1.00)
    colors[clr.Header]                 = ImVec4(0.26, 0.98, 0.85, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.98, 0.85, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.10, 0.75, 0.63, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.10, 0.75, 0.63, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.26, 0.98, 0.85, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.98, 0.85, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.98, 0.85, 0.95)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.81, 0.35, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.98, 0.85, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.WindowBg]               = ImVec4(0.12, 0.12, 0.12, 0.94)
    colors[clr.ChildBg]          = ImVec4(1.00, 1.00, 1.00, 0.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.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 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)
end
Теперь другая проблема, как можно отображать примитив на других координатах, а не координатах на которых заканчивается анимация?
Lua:
-- Я про эти координаты (2 аргумент к функции bringVec2To)
animation.pos = bringVec2To(imgui.ImVec2(0, 200), imgui.ImVec2(0, 0), animation.start, 0.5)
 
Последнее редактирование:

Alex_Floui

Известный
5
0
Смотрите, есть 3 Пикапа домов:
'property_orange', 'property_red' и 'property_fsale', оранжевый, красный и зеленый.
Есть на N-сервере система домов, где соответственно к каждому дому установлен разный из этих пикапов и конечно же присвоен свой ID дома.
Как сделать так, чтобы как только изменяется Пикап у какого либо дома на один из этих трех, циклично и в разном порядке, но чаще всего,
это смена с Красного на Оранжевый, с Оранжевого на Зеленый, а с Зеленого на Красный. Так вот..

Сделав проверку на это, чтобы всё это выводилось в Диалоговое окно, разбивая на 3 строки, через которые можно перейти в следующие диалоговые окна. Назвав эти строки пусть даже по этим 3 цветам.

Красный
в этом диалоговом окне, выводятся все строки с занятыми домами на данный момент времени по всей карте
Оранжевый
в этом окне, просто говоря, выводятся дома, у которого Оранжевый Пикап на данный момент времени по всей карте
Зеленый
ну и в этом, свободные дома на данный момент времени по всей карте

Прикрепляя к ним айди дома, и дав нам понять, что прямо сейчас если мы приедим к какому то из домов, мы увидим там Оранжевый ПикАп, увидев информацию об этом в
нашем диалоговом окне скрипта соответственно.


Буду очень признателен, хотя-бы даже за наводящий экземпляр этой проверки и вывода.
Понятное дело, что сделать это универсально под всё не получится, и вот только по этому хотя-бы наводящий пример, откуда будет понятно, что по такой-то, такой-то последовательности можно будет
внести все ID домов сервера и тому подобное.
 
  • Эм
Реакции: nanobrick

Madeo Capaldi

Участник
42
2
Как мне сделать, чтобы number с функции onServerMessage передавался в функцию bote_cmd
Делаю number глобальной - выдает:
attempt to concatenate global 'number' (a nil value)
stack traceback
Lua:
require('lib.moonloader')
local ev = require('lib.samp.events')
function main()
  
    while not isSampAvailable()  do wait(0)   end 
sampRegisterChatCommand('bote', bote_cmd)

  
        function ev.onServerMessage(_, text)
            local nick,dom
                if text:find ('Владелец:%s(%w+_%w+).%sТелефон:%s(%d*)%s%|%sЛичный%sдом%s№%s(%d*)')  then
               nick, number, dom  = text:match ('Владелец:%s(%w+_%w+).%sТелефон:%s(%d*)%s|%sЛичный%sдом%s№%s(%d*)')
                end
                
        end
        while true do
            wait(0)
        end
    
    end

        function bote_cmd(arg)
            sampSendChat ("/number "..arg)
            if arg == 0 then
                 sampAddChatMessage ("Вы не ввели id", -1  )
                else
                 sampAddChatMessage ( "/call " .. number, -1 )
               end
    
        end
 

chapo

17.10.2024...
Друг
8,801
11,369
Как мне сделать, чтобы number с функции onServerMessage передавался в функцию bote_cmd
Делаю number глобальной - выдает:
attempt to concatenate global 'number' (a nil value)
stack traceback
Lua:
require('lib.moonloader')
local ev = require('lib.samp.events')
function main()
 
    while not isSampAvailable()  do wait(0)   end
sampRegisterChatCommand('bote', bote_cmd)

 
        function ev.onServerMessage(_, text)
            local nick,dom
                if text:find ('Владелец:%s(%w+_%w+).%sТелефон:%s(%d*)%s%|%sЛичный%sдом%s№%s(%d*)')  then
               nick, number, dom  = text:match ('Владелец:%s(%w+_%w+).%sТелефон:%s(%d*)%s|%sЛичный%sдом%s№%s(%d*)')
                end
               
        end
        while true do
            wait(0)
        end
   
    end

        function bote_cmd(arg)
            sampSendChat ("/number "..arg)
            if arg == 0 then
                 sampAddChatMessage ("Вы не ввели id", -1  )
                else
                 sampAddChatMessage ( "/call " .. number, -1 )
               end
   
        end
код больше похож на кашу из дерьма. Опиши что именно тебе нужно