Полезные сниппеты и функции

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,778
11,220
Описание: возвращает 2д координаты всех углов модели по айди модели машины/скина и хендлу ( простое использование функции getModelDemensions() ).
Код:
Lua:
function getCarModelCornersIn2d(id, handle)
    local x1, y1, z1, x2, y2, z2 = getModelDimensions(id)
    local t = {
        [1] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x1         , y1 * -1.1, z1))},
        [2] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x1 * -1.0  , y1 * -1.1, z1))},
        [3] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x1 * -1.0  , y1       , z1))},
        [4] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x1         , y1       , z1))},
        [5] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x2 * -1.0  , y2       , z2))},
        [6] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x2 * -1.0  , y2 * -0.9, z2))},
        [7] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x2         , y2 * -0.9, z2))},
        [8] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x2         , y2       , z2))},
    }
    return t
end
Lua:
function getCharModelCornersIn2d(id, handle)
    local x1, y1, z1, x2, y2, z2 = getModelDimensions(id)
    local t = {
        [1] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x1         , y1 * -1.1, z1))}, -- {x = x1, y = y1 * -1.0, z = z1},
        [2] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x1 * -1.0  , y1 * -1.1, z1))}, -- {x = x1 * -1.0, y = y1 * -1.0, z = z1},
        [3] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x1 * -1.0  , y1       , z1))}, -- {x = x1 * -1.0, y = y1, z = z1},
        [4] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x1         , y1       , z1))}, -- {x = x1, y = y1, z = z1},
        [5] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x2 * -1.0  , y2       , z2))}, -- {x = x2 * -1.0, y = 0, z = 0},
        [6] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x2 * -1.0  , y2 * -0.9, z2))}, -- {x = x2 * -1.0, y = y2 * -1.0, z = z2},
        [7] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x2         , y2 * -0.9, z2))}, -- {x = x2, y = y2 * -1.0, z = z2},
        [8] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x2         , y2       , z2))}, -- {x = x2, y = y2, z = z2},
    }
    return t
end
Пример использования:
Lua:
local font = renderCreateFont('Tahoma', 10, 4)

function main()
    while not isSampAvailable() do wait(0) end
    while true do
        wait(0)
        if isCharInAnyCar(PLAYER_PED) then
            local c = getCarModelCornersIn2d(getCarModel(storeCarCharIsInNoSave(PLAYER_PED)), storeCarCharIsInNoSave(PLAYER_PED))
            for i = 1, #c do
                renderDrawPolygon(c[i][1] - 2, c[i][2] - 2, 10, 10, 10, 0, 0xFFff004d)
                renderFontDrawText(font, 'Corner #'..i, c[i][1], c[i][2], 0xFFFFFFFF, 0x90000000)
            end
            renderDrawLine(c[1][1], c[1][2], c[2][1], c[2][2],2, 0xFFff004d)
            renderDrawLine(c[2][1], c[2][2], c[3][1], c[3][2],2, 0xFFff004d)
            renderDrawLine(c[3][1], c[3][2], c[4][1], c[4][2],2, 0xFFff004d)
            renderDrawLine(c[4][1], c[4][2], c[1][1], c[1][2],2, 0xFFff004d)

            renderDrawLine(c[5][1], c[5][2], c[6][1], c[6][2],2, 0xFFff004d)
            renderDrawLine(c[6][1], c[6][2], c[7][1], c[7][2],2, 0xFFff004d)
            renderDrawLine(c[7][1], c[7][2], c[8][1], c[8][2],2, 0xFFff004d)
            renderDrawLine(c[8][1], c[8][2], c[5][1], c[5][2],2, 0xFFff004d)

            renderDrawLine(c[1][1], c[1][2], c[5][1], c[5][2],2, 0xFFff004d)
            renderDrawLine(c[2][1], c[2][2], c[8][1], c[8][2],2, 0xFFff004d)
            renderDrawLine(c[3][1], c[3][2], c[7][1], c[7][2],2, 0xFFff004d)
            renderDrawLine(c[4][1], c[4][2], c[6][1], c[6][2],2, 0xFFff004d)
        end
    end
end

function getCarModelCornersIn2d(id, handle)
    local x1, y1, z1, x2, y2, z2 = getModelDimensions(id)
    local t = {
        [1] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x1         , y1 * -1.1, z1))},
        [2] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x1 * -1.0  , y1 * -1.1, z1))},
        [3] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x1 * -1.0  , y1       , z1))},
        [4] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x1         , y1       , z1))},
        [5] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x2 * -1.0  , y2       , z2))},
        [6] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x2 * -1.0  , y2 * -0.9, z2))},
        [7] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x2         , y2 * -0.9, z2))},
        [8] = {convert3DCoordsToScreen(getOffsetFromCarInWorldCoords(handle, x2         , y2       , z2))},
    }
    return t
end
Lua:
local font = renderCreateFont('Tahoma', 10, 4)

function main()
    while not isSampAvailable() do wait(0) end
    while true do
        wait(0)
        local c = getCharModelCornersIn2d(getCharModel(PLAYER_PED), PLAYER_PED)
        for i = 1, #c do
            renderDrawPolygon(c[i][1] - 2, c[i][2] - 2, 10, 10, 10, 0, 0xFFff004d)
            renderFontDrawText(font, 'Corner #'..i, c[i][1], c[i][2], 0xFFFFFFFF, 0x90000000)
        end
        renderDrawLine(c[1][1], c[1][2], c[2][1], c[2][2],2, 0xFFff004d)
        renderDrawLine(c[2][1], c[2][2], c[3][1], c[3][2],2, 0xFFff004d)
        renderDrawLine(c[3][1], c[3][2], c[4][1], c[4][2],2, 0xFFff004d)
        renderDrawLine(c[4][1], c[4][2], c[1][1], c[1][2],2, 0xFFff004d)

        renderDrawLine(c[5][1], c[5][2], c[6][1], c[6][2],2, 0xFFff004d)
        renderDrawLine(c[6][1], c[6][2], c[7][1], c[7][2],2, 0xFFff004d)
        renderDrawLine(c[7][1], c[7][2], c[8][1], c[8][2],2, 0xFFff004d)
        renderDrawLine(c[8][1], c[8][2], c[5][1], c[5][2],2, 0xFFff004d)

        renderDrawLine(c[1][1], c[1][2], c[5][1], c[5][2],2, 0xFFff004d)
        renderDrawLine(c[2][1], c[2][2], c[8][1], c[8][2],2, 0xFFff004d)
        renderDrawLine(c[3][1], c[3][2], c[7][1], c[7][2],2, 0xFFff004d)
        renderDrawLine(c[4][1], c[4][2], c[6][1], c[6][2],2, 0xFFff004d)
    end
end

function getCharModelCornersIn2d(id, handle)
    local x1, y1, z1, x2, y2, z2 = getModelDimensions(id)
    local t = {
        [1] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x1         , y1 * -1.1, z1))}, -- {x = x1, y = y1 * -1.0, z = z1},
        [2] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x1 * -1.0  , y1 * -1.1, z1))}, -- {x = x1 * -1.0, y = y1 * -1.0, z = z1},
        [3] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x1 * -1.0  , y1       , z1))}, -- {x = x1 * -1.0, y = y1, z = z1},
        [4] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x1         , y1       , z1))}, -- {x = x1, y = y1, z = z1},
        [5] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x2 * -1.0  , y2       , z2))}, -- {x = x2 * -1.0, y = 0, z = 0},
        [6] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x2 * -1.0  , y2 * -0.9, z2))}, -- {x = x2 * -1.0, y = y2 * -1.0, z = z2},
        [7] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x2         , y2 * -0.9, z2))}, -- {x = x2, y = y2 * -1.0, z = z2},
        [8] = {convert3DCoordsToScreen(getOffsetFromCharInWorldCoords(handle, x2         , y2       , z2))}, -- {x = x2, y = y2, z = z2},
    }
    return t
end

1640610245062.png
1640610623160.png
 

Rice.

https://t.me/riceoff
Модератор
1,691
1,437
Описание: Стильная imgui.Button с помощью библиотеки "MoonMonet". Для работы требуется - https://www.blast.hk/threads/105945/
Функция:
Lua:
function imgui.ColorButton(text, color, size)
        if color == nil or color == '' then
        else
            if not colors[color] then colors[color] = MonetLua.buildColors(color, 1.0, true) end
            local ret = colors[color]
            imgui.PushStyleColor(imgui.Col.Button, ColorAccentsAdapter(color):apply_alpha(0xaa):as_vec4())
            imgui.PushStyleColor(imgui.Col.ButtonActive, ColorAccentsAdapter(ret.accent1.color_700):apply_alpha(0xaa):as_vec4())
            imgui.PushStyleColor(imgui.Col.ButtonHovered, ColorAccentsAdapter(ret.accent1.color_500):apply_alpha(0xaa):as_vec4())
        end
        if size == nil then
            local button = imgui.Button(text)
        else
            local button = imgui.Button(text, size)
        end
        if color == nil or color == '' then
        else
            imgui.PopStyleColor(3)
        end
    return button
end

local function explode_argb(argb)
    local bit = require 'bit'
    local a = bit.band(bit.rshift(argb, 24), 0xFF)
    local r = bit.band(bit.rshift(argb, 16), 0xFF)
    local g = bit.band(bit.rshift(argb, 8), 0xFF)
    local b = bit.band(argb, 0xFF)
    return a, r, g, b
end

function ColorAccentsAdapter(color)
    local a, r, g, b = explode_argb(color)
    local ret = {a = a, r = r, g = g, b = b}
    function ret:apply_alpha(alpha)
        self.a = alpha
        return self
    end
    function ret:as_vec4()
        return imgui.ImVec4(self.r / 255, self.g / 255, self.b / 255, self.a / 255)
    end
    return ret
end

Пример использования:

Lua:
imgui.ColorButton('Button', 0x1E90FF, imgui.ImVec2(250, 25)) -- Полноценная кнопка
imgui.ColorButton('Button 2', '', imgui.ImVec2(250, 25)) -- Кнопка с размером, но без цвета
imgui.ColorButton('Button 3', 0xFF6347) -- Кнопка без размера, но с цветом

 
  • Нравится
Реакции: Citrys и _raz0r

leekyrave

Известный
420
223
Описание: RadioButton, только на обычных кнопках.

Функция:

Lua:
function imgui.CustomRadioButton(title, current_number, button_number, ...)
    if tonumber(current_number.v) == tonumber(button_number) then
        imgui.PushStyleColor(imgui.Col.Button, imgui.GetStyle().Colors[imgui.Col.CheckMark])
        imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.GetStyle().Colors[imgui.Col.CheckMark])
        imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.GetStyle().Colors[imgui.Col.CheckMark])

        local result = imgui.Button(title, ...)

        imgui.PopStyleColor(3)
        return result
    else
        if imgui.Button(title, ...) then current_number.v = tonumber(button_number) return true end
    end
end

Пример использования:
Lua:
if imgui.CustomRadioButton(fa.ICON_FA_ALIGN_LEFT, cheats['fAlignKL'], 1, imgui.ImVec2(101.5,20)) then ini.cheats.fAlignKL = cheats['fAlignKL'].v save() end
imgui.Hint(u8"Центрирование текста по левому краю")
imgui.SameLine()
imgui.Hint(u8"Центрирование текста по центру краю")
if imgui.CustomRadioButton(fa.ICON_FA_ALIGN_CENTER, cheats['fAlignKL'], 2, imgui.ImVec2(101.5,20)) then ini.cheats.fAlignKL = cheats['fAlignKL'].v save() end
imgui.SameLine()
imgui.Hint(u8"Центрирование текста по правому краю")
if imgui.CustomRadioButton(fa.ICON_FA_ALIGN_RIGHT, cheats['fAlignKL'], 3, imgui.ImVec2(101.5,20)) then ini.cheats.fAlignKL = cheats['fAlignKL'].v save() end

Возможный результат(снизу):
vUcpMBQ.png
 
Последнее редактирование:

vl4sov

Известный
5
30
Описание: Кастомный InputText с подсказкой для mimgui

Функция:
Lua:
function imgui.CustomInputTextWithHint(name, bool, hint, size, width, color, password)
    if not size then size = 1.0 end
    if not hint then hint = '' end
    if not width then width = 100 end
    if password then flags = imgui.InputTextFlags.Password else flags = '' end
    local clr = imgui.Col
    local pos = imgui.GetCursorScreenPos()
    local rounding = imgui.GetStyle().WindowRounding -- or ChildRounding
    local drawList = imgui.GetWindowDrawList()
    imgui.BeginChild("##"..name, imgui.ImVec2(width + 10, 25), false) -- 
        imgui.SetCursorPosX(5)
        imgui.SetWindowFontScale(size) -- size
        imgui.PushStyleColor(imgui.Col.FrameBg, imgui.ImVec4(0.15, 0.18, 0.27, 0.00)) -- alpha 0.00 or color == WindowBg & ChildBg
        imgui.PushItemWidth(width) -- width
        if password then
            result = imgui.InputTextWithHint(name, u8(hint), bool, sizeof(bool), flags)
        else
            result = imgui.InputTextWithHint(name, u8(hint), bool, sizeof(bool)) -- imgui.InputTextWithHint
        end
        imgui.PopItemWidth()
        imgui.PopStyleColor(1)
        imgui.SetWindowFontScale(1.0) -- defoult size
        drawList:AddLine(imgui.ImVec2(pos.x, pos.y + (25*size)), imgui.ImVec2(pos.x + width + 15, pos.y + (25*size)), color, 3 * size) -- draw line
    imgui.EndChild()
    return result
end

Пример использования:
Lua:
resX, resY = getScreenResolution()
windows = {
    testwindow = {
        enable = new.bool(),
        login = new.char[256](),
        password = new.char[256]()
    }
}
imgui.OnFrame(
    function() return windows.testwindow.enable[0] and not isPauseMenuActive() end,
    function(self)
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(300, 200), imgui.Cond.FirstUseEver)
        imgui.PushStyleVarVec2(imgui.StyleVar.WindowPadding, imgui.ImVec2(0, 0))
        local flags = imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar + imgui.WindowFlags.NoTitleBar
        imgui.Begin('##LoginWindow', windows.newmenu.enable, flags)
            imgui.SetCursorPos( imgui.ImVec2(95, 15) )
            imgui.SubTitle(u8'Авторизация')
            imgui.SetCursorPos( imgui.ImVec2(60, 45) )
            imgui.CustomInputTextWithHint('##login', windows.testwindow.login, 'Username', 1.2, 150, imgui.ColorConvertFloat4ToU32(mc))
            imgui.SetCursorPos( imgui.ImVec2(60, 95) )
            imgui.CustomInputTextWithHint('##password', windows.testwindow.password, 'Password', 1.2, 150, imgui.ColorConvertFloat4ToU32(mc), true) -- 1. name  2. bool  3. hint  4. size  5. width  6. color  7. password flag
            imgui.SetCursorPos( imgui.ImVec2(100, 150) )
            imgui.Button(u8'Войти', imgui.ImVec2(100, 30))
        imgui.End()
        imgui.PopStyleVar()
    end
)

WSYqcfA.gif
 
Последнее редактирование:

Rice.

https://t.me/riceoff
Модератор
1,691
1,437
Описание:
Круглая кнопка Imgui в стиле сайтов

Функция:
Lua:
function imgui.CircleButton(text, bool, number)
    if bool.v == number then
        imgui.PushStyleVar(imgui.StyleVar.FrameRounding, 15)
        imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(1.00, 0.16, 0.16, 1.00))
        imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(1.00, 0.16, 0.16, 1.00))
        imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(1.00, 0.16, 0.16, 1.00))
        local button = imgui.Button(text, imgui.ImVec2(10, 10))
        imgui.PopStyleColor(3)
        imgui.PopStyleVar(1)
        return button
    else
        if imgui.Button(text, imgui.ImVec2(10, 10)) then
            bool.v = number
            return true
        end
    end
end
Пример использования:
Lua:
local b_button = imgui.ImInt(1)

-- Imgui
if b_button.v == 1 then -- Текст: https://freeqn.net/
    imgui.PushFont(fontsize501)
    imgui.CenterText(u8'1/3 страница', imgui.ImVec4(0.649, 0.649, 0.649, 1.000))
    imgui.CenterText(u8'Играйте как киберспортсмен')
    imgui.PopFont()
    imgui.NewLine()
    imgui.PushFont(fontsize502)
    imgui.CenterText(u8('Начните играть с готовыми\nнастройками, которые подходят\nбольшинству игроков'))
    imgui.NewLine()
    imgui.Separator()
    imgui.NewLine()
    imgui.CenterText(u8('Настраивайте задержку выстрела,\nскорость наведения, радиус действия,\nчасть тела (включая приоритет)'))
    imgui.PopFont()
elseif b_button.v == 2 then
    imgui.PushFont(fontsize501)
    imgui.CenterText(u8'2/3 страница', imgui.ImVec4(0.649, 0.649, 0.649, 1.000))
    imgui.CenterText(u8'Inventory changer')
    imgui.PopFont()
    imgui.NewLine()
    imgui.PushFont(fontsize502)
    imgui.CenterText(u8('Друзья с читом увидят ваши скины,\nножи и перчатки'))
    imgui.NewLine()
    imgui.Separator()
    imgui.NewLine()
    imgui.CenterText(u8('Открывайте кейсы и сувенирные\nнаборы'))
    imgui.NewLine()
    imgui.Separator()
    imgui.NewLine()
    imgui.CenterText(u8('Добавляйте значки, музыкальные\nнаборы и агентов'))
    imgui.PopFont()
elseif b_button.v == 3 then
    imgui.PushFont(fontsize501)
    imgui.CenterText(u8'3/3 страница', imgui.ImVec4(0.649, 0.649, 0.649, 1.000))
    imgui.CenterText(u8'Играйте против других читов')
    imgui.PopFont()
    imgui.NewLine()
    imgui.PushFont(fontsize502)
    imgui.CenterText(u8('Чит будет стрелять сам во всех\nпротивников, которым можно нанести\nурон. Выбирайте минимальный урон,\nшанс попадания, части тела'))
    imgui.NewLine()
    imgui.Separator()
    imgui.NewLine()
    imgui.CenterText(u8('Чит сам поймет, какие функции нужно\nвыключить, чтобы не получить бан\nили ошибку VAC'))
    imgui.PopFont()
end

imgui.CircleButton('##1', b_button, 1)
imgui.SameLine()
imgui.NewLine()
imgui.SameLine()
imgui.CircleButton('##2', b_button, 2)
imgui.SameLine()
imgui.NewLine()
imgui.SameLine()
imgui.CircleButton('##3', b_button, 3)
 

leekyrave

Известный
420
223
Описание: Таблица скинов и их айдишники, указаны индексы, т.к на некоторых серверах есть кастомные скины

Код:

Lua:
local tSkinsName = {
    [0] = "Carl CJ",
    [1] = "The Truth",
    [2] = "Maccer",
    [3] = "Andre",
    [4] = "Barry",
    [5] = "Barry",
    [6] = "Emmet",
    [7] = "Taxi Driver",
    [8] = "Janitor",
    [9] = "Normal Ped",
    [10] = "Old Woman",
    [11] = "Casino croupier",
    [12] = "Casino croupier",
    [13] = "Street Girl",
    [14] = "Normal Ped",
    [15] = "Mr.Whittaker",
    [16] = "Airport Ground Worker",
    [17] = "Businessman",
    [18] = "Beach Visitor",
    [19] = "DJ",
    [20] = "Rich Guy",
    [21] = "Normal Ped",
    [22] = "Normal Ped",
    [23] = "BMXer",
    [24] = "Madd Dogg BodyGuard",
    [25] = "Madd Dogg BodyGuard",
    [26] = "Backpacker",
    [27] = "Construction Worker",
    [28] = "Drug Dealer",
    [29] = "Drug Dealer",
    [30] = "Drug Dealer",
    [31] = "Farm-Town",
    [32] = "Farm-Town",
    [33] = "Farm-Town",
    [34] = "Farm-Town",
    [35] = "Gardener",
    [36] = "Golfer",
    [37] = "Golfer",
    [38] = "Normal Ped",
    [39] = "Normal Ped",
    [40] = "Normal Ped",
    [41] = "Normal Ped",
    [42] = "Jethro",
    [43] = "Normal Ped",
    [44] = "Normal Ped",
    [45] = "Beach Visitor",
    [46] = "Normal Ped",
    [47] = "Normal Ped",
    [48] = "Normal Ped",
    [49] = "Snakehead",
    [50] = "Mechanic",
    [51] = "Mountain Biker",
    [52] = "Mountain Biker",
    [53] = "Unknown",
    [54] = "Normal Ped",
    [55] = "Normal Ped",
    [56] = "Normal Ped",
    [57] = "Oriental Ped",
    [58] = "Oriental Ped",
    [59] = "Normal Ped",
    [60] = "Normal Ped",
    [61] = "Pilot",
    [62] = "Colonel Fuhrberger",
    [63] = "Prostitute",
    [64] = "Prostitute",
    [65] = "Kendl Johnson",
    [66] = "Pool Player",
    [67] = "Pool Player",
    [68] = "Priest",
    [69] = "Normal Ped",
    [70] = "Scientist",
    [71] = "Security Guard",
    [72] = "Hippy",
    [73] = "Hippy",
    [74] = "CJ",
    [75] = "Prostitute",
    [76] = "Normal Ped",
    [77] = "Homeless",
    [78] = "Homeless",
    [78] = "Homeless",
    [79] = "Homeless",
    [80] = "Boxer",
    [81] = "Boxer",
    [82] = "Black Elvis",
    [83] = "White Elvis",
    [84] = "Blue Elvis",
    [85] = "Prostitute",
    [86] = "Ryder with robbery mask",
    [87] = "Stripper",
    [88] = "Normal Ped",
    [89] = "Normal Ped",
    [90] = "Jogger",
    [91] = "Rich Woman",
    [92] = "Normal Ped",
    [93] = "Normal Ped",
    [94] = "Normal Ped",
    [95] = "Normal Ped",
    [96] = "Jogger",
    [97] = "Lifeguard",
    [98] = "Normal Ped",
    [99] = "Rollerskater",
    [100] = "Biker",
    [101] = "Normal Ped",
    [102] = "Ballas",
    [103] = "Ballas",
    [104] = "Ballas",
    [105] = "Grove Street Fam.",
    [106] = "Grove Street Fam.",
    [107] = "Grove Street Fam.",
    [108] = "Los Santos Vagos",
    [109] = "Los Santos Vagos",
    [110] = "Los Santos Vagos",
    [111] = "The Russian Mafia",
    [112] = "The Russian Mafia",
    [113] = "The Russian Mafia Boss",
    [114] = "Varrios Los Aztecas",
    [115] = "Varrios Los Aztecas",
    [116] = "Varrios Los Aztecas",
    [117] = "Triad",
    [118] = "Triad",
    [119] = "Johhny Sindacco",
    [120] = "Triad Boss",
    [121] = "Da Nang Boy",
    [122] = "Da Nang Boy",
    [123] = "Da Nang Boy",
    [124] = "The Mafia",
    [125] = "The Mafia",
    [126] = "The Mafia",
    [127] = "The Mafia",
    [128] = "Farm Inhabitant",
    [129] = "Farm Inhabitant",
    [130] = "Farm Inhabitant",
    [131] = "Farm Inhabitant",
    [132] = "Farm Inhabitant",
    [133] = "Farm Inhabitant",
    [134] = "Homeless",
    [135] = "Homeless",
    [136] = "Normal Ped",
    [137] = "Homeless",
    [138] = "Beach Visitor",
    [139] = "Beach Visitor",
    [140] = "Beach Visitor",
    [141] = "Businesswoman",
    [142] = "Taxi Driver",
    [143] = "Crack Maker",
    [144] = "Crack Maker",
    [145] = "Crack Maker",
    [146] = "Crack Maker",
    [147] = "Businessman",
    [148] = "Businesswoman",
    [149] = "Big Smoke Armored",
    [150] = "Businesswoman",
    [151] = "Normal Ped",
    [152] = "Prostitute",
    [153] = "Construction Worker",
    [154] = "Beach Visitor",
    [155] = "Well Stacked Pizza Worker",
    [156] = "Barber",
    [157] = "Hillbilly",
    [158] = "Farmer",
    [158] = "Farmer",
    [159] = "Hillbilly",
    [160] = "Hillbilly",
    [161] = "Farmer",
    [162] = "Hillbilly",
    [163] = "Black Bouncer",
    [164] = "White Bouncer",
    [165] = "White MIB agent",
    [166] = "Black MIB agent",
    [167] = "Cluckin",
    [168] = "Hotdog",
    [169] = "Normal Ped",
    [170] = "Normal Ped",
    [171] = "Blackjack Dealer",
    [172] = "Casino croupier",
    [173] = "San Fierro Rifa",
    [174] = "San Fierro Rifa",
    [175] = "San Fierro Rifa",
    [176] = "Barber",
    [177] = "Barber",
    [178] = "Whore",
    [179] = "Ammunation Salesman",
    [180] = "Tattoo Artist",
    [181] = "Punk",
    [182] = "Cab Driver",
    [183] = "Normal Ped",
    [184] = "Normal Ped",
    [185] = "Normal Ped",
    [186] = "Normal Ped",
    [187] = "Buisnessman",
    [188] = "Normal Ped",
    [189] = "Normal Ped",
    [190] = "Barbara Schternvart",
    [191] = "Helena Wankstein",
    [192] = "Michelle Cannes",
    [193] = "Katie Zhan",
    [194] = "Millie Perkins",
    [195] = "Denise Robinson",
    [196] = "Farm-Town inhabitant",
    [197] = "Hillbilly",
    [198] = "Farm-Town inhabitant",
    [199] = "Farm-Town inhabitant",
    [200] = "Hillbilly",
    [201] = "Farmer",
    [202] = "Farmer",
    [203] = "Karate Teacher",
    [204] = "Karate Teacher",
    [205] = "Burger Shot Cashier",
    [206] = "Cab Driver",
    [207] = "Prostitute",
    [208] = "Su Xi Mu",
    [209] = "Oriental Noodle stand vendor",
    [210] = "Oriental Noodle stand vendor",
    [211] = "Clothes shop staff",
    [212] = "Homeless",
    [213] = "Weird old man",
    [214] = "Waitress",
    [215] = "Normal Ped",
    [216] = "Normal Ped",
    [217] = "Clothes shop staff",
    [218] = "Normal Ped",
    [219] = "Rich Woman",
    [220] = "Cab Driver",
    [221] = "Normal Ped",
    [222] = "Normal Ped",
    [223] = "Normal Ped",
    [224] = "Normal Ped",
    [225] = "Normal Ped",
    [226] = "Normal Ped",
    [227] = "Oriental Buisnessman",
    [228] = "Oriental Ped",
    [229] = "Oriental Ped",
    [230] = "Homeless",
    [231] = "Normal Ped",
    [232] = "Normal Ped",
    [233] = "Normal Ped",
    [234] = "Cab Driver",
    [235] = "Normal Ped",
    [236] = "Normal Ped",
    [237] = "Prostitute",
    [238] = "Prostitute",
    [239] = "Homeless",
    [240] = "The D.A",
    [241] = "Afro-American",
    [242] = "Mexican",
    [243] = "Prostitute",
    [244] = "Stripper",
    [245] = "Prostitute",
    [246] = "Stripper",
    [247] = "Biker",
    [248] = "Biker",
    [249] = "Pimp",
    [250] = "Normal Ped",
    [251] = "Lifeguard",
    [252] = "Naked Valet",
    [253] = "Bus Driver",
    [254] = "Biker Drug Dealer",
    [255] = "Chauffeur",
    [256] = "Stripper",
    [257] = "Stripper",
    [258] = "Heckler",
    [259] = "Heckler",
    [260] = "Construction Worker",
    [261] = "Cab driver",
    [262] = "Cab driver",
    [263] = "Normal Ped",
    [264] = "Clown",
    [265] = "Officer Frank Tenpenny",
    [266] = "Officer Eddie Pulaski",
    [267] = "Officer Jimmy Hernandez",
    [268] = "Dwaine",
    [269] = "Melvin «Big Smoke» Harris",
    [270] = "Sean «Sweet» Johnson",
    [271] = "Lance «Ryder» Wilson",
    [272] = "Marco Forelli",
    [273] = "T-Bone Mendez",
    [274] = "Paramedic",
    [275] = "Paramedic",
    [276] = "Paramedic",
    [277] = "Firefighter",
    [278] = "Firefighter",
    [279] = "Firefighter",
    [280] = "Los Santos Police Officer",
    [281] = "San Fierro Police Officer",
    [282] = "Las Venturas Police Officer",
    [283] = "County Sheriff",
    [284] = "LSPD Motorbike Cop",
    [285] = "S.W.A.T Special Forces",
    [286] = "Federal Agent",
    [287] = "San Andreas",
    [288] = "Desert Sheriff",
    [289] = "Zero",
    [290] = "Ken Rosenberg",
    [291] = "Kent Paul",
    [292] = "Cesar Vialpando",
    [293] = "Jeffery",
    [294] = "Wu Zi Mu",
    [295] = "Michael Toreno",
    [296] = "Jizzy B",
    [297] = "Madd Dogg",
    [298] = "Catalina",
    [299] = "Claude Speed",
    [300] = "Los Santos Police Officer",
    [301] = "San Fierro Police Officer",
    [302] = "Las Venturas Police Officer",
    [303] = "Los Santos Police Officer",
    [304] = "Los Santos Police Officer",
    [305] = "Las Venturas Police Officer",
    [306] = "Los Santos Police Officer",
    [307] = "San Fierro Police Officer",
    [308] = "San Fierro Paramedic",
    [309] = "Las Venturas Police Officer",
    [310] = "Country Sheriff",
    [311] = "Desert Sheriff"
}
 
Последнее редактирование:
  • Нравится
Реакции: tyukapa и ShikamaruRU

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,778
11,220
Описание: ущербная кнопка с двумя скругленными углами
Пример использования:
Lua:
if imgui.HalfRoundedButton('Hello world', 100, 30, 4) then
    sampAddChatMessage('Hello world!', -1)
end
1641809147140.png


Код:

Lua:
function imgui.HalfRoundedButton(text, sizeX, sizeY, out_size, bebra)
    local colors = {
        def = imgui.GetStyle().Colors[imgui.Col.Button],
        hover = imgui.GetStyle().Colors[imgui.Col.ButtonHovered],
        back = imgui.GetStyle().Colors[imgui.Col.WindowBg],
    }
    local p = imgui.GetCursorScreenPos()
    local dl = imgui.GetWindowDrawList()
    local cur = imgui.GetCursorPos()
    if imgui.InvisibleButton(text, imgui.ImVec2(sizeX, sizeY)) then
        return true
    end
    local col = imgui.IsItemHovered() and colors.hover or colors.def
    dl:AddRectFilled(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x + sizeX, p.y + sizeY), imgui.GetColorU32(col), 10, 1 + 4)
    imgui.SetCursorPos(imgui.ImVec2(cur.x, cur.y))
    dl:AddRectFilled(imgui.ImVec2(p.x + out_size / 2, p.y + out_size / 2), imgui.ImVec2(p.x + sizeX - out_size / 2, p.y + sizeY - out_size / 2), imgui.GetColorU32(colors.back), 10, 1 + 4)
    local ts = imgui.CalcTextSize(text)
    imgui.SetCursorPos(imgui.ImVec2(cur.x + sizeX / 2 - ts.x / 2, cur.y + sizeY / 2 - ts.y / 2))
    imgui.TextColored(col, text)
end
 

kin4stat

mq-team
Всефорумный модератор
2,730
4,712
Описание: ущербная кнопка с двумя скругленными углами
Пример использования:
Lua:
if imgui.HalfRoundedButton('Hello world', 100, 30, 4) then
    sampAddChatMessage('Hello world!', -1)
end
Посмотреть вложение 130901
Код:
Lua:
function imgui.HalfRoundedButton(text, sizeX, sizeY, out_size, bebra)
    local colors = {
        def = imgui.GetStyle().Colors[imgui.Col.Button],
        hover = imgui.GetStyle().Colors[imgui.Col.ButtonHovered],
        back = imgui.GetStyle().Colors[imgui.Col.WindowBg],
    }
    local p = imgui.GetCursorScreenPos()
    local dl = imgui.GetWindowDrawList()
    local cur = imgui.GetCursorPos()
    if imgui.InvisibleButton(text, imgui.ImVec2(sizeX, sizeY)) then
        return true
    end
    local col = imgui.IsItemHovered() and colors.hover or colors.def
    dl:AddRectFilled(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x + sizeX, p.y + sizeY), imgui.GetColorU32(col), 10, 1 + 4)
    imgui.SetCursorPos(imgui.ImVec2(cur.x, cur.y))
    dl:AddRectFilled(imgui.ImVec2(p.x + out_size / 2, p.y + out_size / 2), imgui.ImVec2(p.x + sizeX - out_size / 2, p.y + sizeY - out_size / 2), imgui.GetColorU32(colors.back), 10, 1 + 4)
    local ts = imgui.CalcTextSize(text)
    imgui.SetCursorPos(imgui.ImVec2(cur.x + sizeX / 2 - ts.x / 2, cur.y + sizeY / 2 - ts.y / 2))
    imgui.TextColored(col, text)
end
Взял бы код скругленного квадрата, и изменил PathArcToFast на PathArcTo, чтобы не было этих кривых скруглений пиксельных
 

neverlane

t.me/neverlane00
Друг
997
1,132
Описание: ставит дефолт значения в таблицу если нет ключа (+ параметр для глубокого дефолта)
Пример использования:
беброчка:
-- не глубокая проверка
tbl = defaults({ negr = 1, bebra = { sy = 3} }, { bebra = { sx = 32 } })
print(tbl.bebra.sx)
print(tbl.bebra.sy)
-- output:
-- nil
-- 3

-- глубокая проверка
tbl = defaults({ negr = 1, bebra = { sy = 3} }, { bebra = { sx = 32 } }, true)
print(tbl.bebra.sx)
print(tbl.bebra.sy)
-- output:
-- 32
-- 3

Код:

lua kizn:
function defaults(check, def, deep)
    deep = deep or false
    local function _hasProp(obj, prop)
        for k in pairs(obj) do
            if (k == prop) then return true end
        end
        return false
    end
    for defk, defv in pairs(def) do
        if(_hasProp(check, defk)) then
            if(deep and type(check[defk]) == 'table' and type(defv) == 'table') then
                defaults(check[defk], defv, deep)
            end
        else
            check[defk] = defv       
        end
    end
    return check
end
 
  • Ха-ха
Реакции: Cosmo

Cosmo

Известный
Друг
646
2,598
Описание:
Функиця, которая проверяет включен ли CapsLock
Lua:
local ffi = require "ffi"

ffi.cdef [[
    typedef short SHORT;
    SHORT __stdcall GetKeyState(int nVirtKey);
]]

function isCapsLockActive()
    local state = ffi.C.GetKeyState(0x14) -- // VK_CAPITAL
    return bit.band(state, 0x01) == 1
end

Пример использования:
В какой-то игре видел, когда включен капс-лок, то игрок передвигается только пешком. Вот аналог:
Lua:
function main()
    while true do
       
        local capslock = isCapsLockActive()
        if isButtonPressed(PLAYER_HANDLE, 0) or isButtonPressed(PLAYER_HANDLE, 1) then
            setGameKeyState(21, capslock and 255 or 0)
        end

        wait(0)
    end
end
 

kin4stat

mq-team
Всефорумный модератор
2,730
4,712
mimgui Красивый BeginChild но с заголовком и возможностью изменить цвет не меняя его в стиле.
Основу функции взял у Cosmo
Lua:
-- Все цвета указываются так: imgui.ImVec4(0.34, 0.36, 0.78, 1.00)
--colorBegin - Цвет заголовка
--colorText - Цвет текста в заголовке
--colorLine - Цвет обводки чилда
--offset - Смещение заголовка на "ваше число (int)" пикселей вправо

function imgui.BeginTitleChild(str_id, size, colorBegin, colorText, colorLine, offset)
    colorBegin = colorBegin or imgui.ImVec4(0.34, 0.36, 0.78, 1.00)
    colorText = colorText or imgui.ImVec4(1.00, 1.00, 1.00, 1.00)
    colorLine = colorLine or imgui.ImVec4(0.34, 0.36, 0.78, 1.00)
    offset = offset or 50
    local DL = imgui.GetWindowDrawList()
    local posS = imgui.GetCursorScreenPos()
    local rounding = imgui.GetStyle().ChildRounding
    local title = str_id:gsub('##.+$', '')
    local sizeT = imgui.CalcTextSize(title)
    local bgColor = imgui.ColorConvertFloat4ToU32(imgui.GetStyle().Colors[imgui.Col.WindowBg])
    imgui.PushStyleColor(imgui.Col.Border, imgui.ImVec4(0, 0, 0, 0))
    imgui.BeginChild(str_id, size, true)
    imgui.SetCursorPos(imgui.ImVec2(0, 30))
    imgui.Spacing()
    imgui.PopStyleColor(1)
    size.x = size.x == -1.0 and imgui.GetWindowWidth() or size.x
    size.y = size.y == -1.0 and imgui.GetWindowHeight() or size.y
    DL:AddRect(posS, imgui.ImVec2(posS.x + size.x, posS.y + size.y), imgui.ColorConvertFloat4ToU32(colorLine), rounding, _, 1)
    DL:AddRectFilled(imgui.ImVec2(posS.x, posS.y), imgui.ImVec2(posS.x + size.x, posS.y + size.x/size.y + 25), imgui.ColorConvertFloat4ToU32(colorBegin), rounding, 1 + 2)
    DL:AddText(imgui.ImVec2(posS.x + offset, posS.y + 15 - (sizeT.y / 2)), imgui.ColorConvertFloat4ToU32(colorText), title)
end
Пример использования:
Lua:
imgui.BeginTitleChild(u8"Погода и время", imgui.ImVec2(335, 230), imgui.ImVec4(0.34, 0.36, 0.78, 1.00), imgui.ImVec4(1.00, 1.00, 1.00, 1.00), imgui.ImVec4(0.34, 0.36, 0.78, 1.00), 120)
    imgui.Text(u8"Погода:")
    imgui.PushItemWidth(320)
    if imgui.SliderInt(u8"##Weather", sliders.weather, 0, 45) then
        ini.settings.weather = sliders.weather[0]
        save()
    end
    imgui.Text(u8"Часы:")
    if imgui.SliderInt(u8"##hours", sliders.hours, 0, 23) then
        ini.settings.hours = sliders.hours[0]
        save()
        gotofunc("SetTime")
    end
    imgui.Text(u8"Минуты:")
    if imgui.SliderInt(u8"##min", sliders.min, 0, 59) then
        ini.settings.min = sliders.min[0]
        save()
        gotofunc("SetTime")
    end
    imgui.PopItemWidth()
    if imgui.Checkbox(u8"Блокировать изменение погоды сервером", checkboxes.blockweather) then
        ini.settings.blockweather = checkboxes.blockweather[0]
        save()
    end
    if imgui.Checkbox(u8"Блокировать изменение времени сервером", checkboxes.blocktime) then
        ini.settings.blocktime = checkboxes.blocktime[0]
        save()
    end
imgui.EndChild()
ImGui::PushStyleVar уже не в моде?)
 
  • Нравится
Реакции: Gorskin

Andrinall

Известный
680
532
Описание: Прикрепляет объект, созданный функцией "createObject", к игроку или транспорту без эмуляции RPC или использования ffi.
Из минусов - нельзя прикрепить к определённой кости(я не нашёл в списках адресов какую-то инфу про прикрепление к костям, возможно плохо искал)

Lua:
--[[
 > hObject  - Handle объекта
 > hPlayer  - Handle педа
 > hVehicle - Handle транспорта
 > pOffsets, vOffsets - смешение от центра игрока/транспорта. Передаётся в виде таблицы.
   - Можно не передавать, тогда будет стандарт { 0.0, 0.0, 0.0 }
 > pAngles,  vAngles  - поворот объекта. Как я понял - указывается в радианах. Передаётся в виде таблицы.
   - Можно не передавать, тогда будет стандарт { 0.0, 0.0, 0.0 }
 
 Offsets[1] += вправо, -= влево ; X
 Offsets[2] += вперёд, -= назад ; Y
 Offsets[3] += вверх,  -= вниз  ; Z
 
 Angles[1] = X
 Angles[2] = Y
 Angles[3] = Z
]]
Lua:
function attachObjectToPlayer( hObject, hPlayer, pOffsets, pAngles )
    if doesObjectExist( hObject ) and doesCharExist( hPlayer ) then
        if not pOffsets then pOffsets = { 0.0, 0.0, 0.0 } end
        if not pAngles then pAngles = { 0.0, 0.0, 0.0 } end
       
        setObjectCoordinates( hObject, getCharCoordinates( hPlayer ) ) -- без доп установки позиции почему-то иногда неправильно выставлялись оффсеты
        setObjectCollision( hObject, false ) -- по желанию можно убрать
       
        local pointer = getObjectPointer( hObject )
       
        memory.setuint32( pointer + 0xFC, getCharPointer( hPlayer ) ) -- прикрепляем
       
        memory.setfloat( pointer + 0x100, pOffsets[1] ) -- задаём оффсет
        memory.setfloat( pointer + 0x104, pOffsets[2] )
        memory.setfloat( pointer + 0x108, pOffsets[3] )

        memory.setfloat( pointer + 0x10C, pAngles[1] ) -- задаём угол
        memory.setfloat( pointer + 0x110, pAngles[2] )
        memory.setfloat( pointer + 0x114, pAngles[3] )

        return true
    end
    return false
end
Lua:
function attachObjectToVehicle( hObject, hVehicle, vOffsets, vAngles )
    if doesObjectExist( hObject ) and doesVehicleExist( hVehicle ) then
        if not vOffsets then vOffsets = { 0.0, 0.0, 0.0 } end
        if not vAngles then vAngles = { 0.0, 0.0, 0.0 } end
       
        setObjectCoordinates( hObject, getCarCoordinates( hVehicle ) ) -- без доп установки позиции почему-то иногда неправильно выставлялись оффсеты
        setObjectCollision( hObject, false ) -- по желанию можно убрать
       
        local pointer = getObjectPointer( hObject )
       
        memory.setuint32( pointer + 0xFC, getCarPointer( hVehicle ) ) -- прикрепляем
       
        memory.setfloat( pointer + 0x100, vOffsets[1] ) -- задаём оффсет
        memory.setfloat( pointer + 0x104, vOffsets[2] )
        memory.setfloat( pointer + 0x108, vOffsets[3] )

        memory.setfloat( pointer + 0x10C, vAngles[1] ) -- задаём угол
        memory.setfloat( pointer + 0x110, vAngles[2] )
        memory.setfloat( pointer + 0x114, vAngles[3] )
       
        return true
    end
    return false
end

Lua:
local memory = require 'memory'
local playerObj, vehObj = nil, nil

--main
sampRegisterChatCommand('attach', function( )
    if isCharIsAnyCar( PLAYER_PED ) and not vehObj then
        local car = storeCarCharIsInNoSave( PLAYER_PED )
        vehObj = createObject( 1083, getCarCoordinates( car ) )
        if attachObjectToVehicle( vehObj, car, { 0.0, 0.0, 5.0 }, { 0.0, 0.0, 3.14/2 } ) then -- прикрепит объект над крышей транспорта, поперёк
            print( ("Объект %d прикреплён к авто %d"):format( getObjectModel( vehObj ), getCarModel( car ) ) )
        end
    elseif not isCharInAnyCar( PLAYER_PED ) and not playerObj then
        playerObj = createObject( 1083, getCharCoordinates( PLAYER_PED ) )
        if attachObjectToPlayer( playerObj, PLAYER_PED, { 0.0, 0.0, 5.0 }, { 0.0, 0.0, 3.14/2 } ) then -- прикрепит объект над персонажем, поперёк
            print( ("Объект %d прикреплён к педу %d"):format( getObjectModel( playerObj ), PLAYER_PED ) )
        end
    else
        if playerObj then deleteObject( playerObj ); playerObj = nil end -- удаляются как простые объекты
        if vehObj then    deleteObject( vehObj );    vehObj = nil    end
    end
end)

-- вне main копируем функции

Извиняюсь, если говнокод. 😉
 
  • Злость
  • Нравится
Реакции: Vespan и THERION

kin4stat

mq-team
Всефорумный модератор
2,730
4,712
Описание: Прикрепляет объект, созданный функцией "createObject", к игроку или транспорту без эмуляции RPC или использования ffi.
Из минусов - нельзя прикрепить к определённой кости(я не нашёл в списках адресов какую-то инфу про прикрепление к костям, возможно плохо искал)

Lua:
--[[
 > hObject  - Handle объекта
 > hPlayer  - Handle педа
 > hVehicle - Handle транспорта
 > pOffsets, vOffsets - смешение от центра игрока/транспорта. Передаётся в виде таблицы.
   - Можно не передавать, тогда будет стандарт { 0.0, 0.0, 0.0 }
 > pAngles,  vAngles  - поворот объекта. Как я понял - указывается в радианах. Передаётся в виде таблицы.
   - Можно не передавать, тогда будет стандарт { 0.0, 0.0, 0.0 }
 
 Offsets[1] += вправо, -= влево ; X
 Offsets[2] += вперёд, -= назад ; Y
 Offsets[3] += вверх,  -= вниз  ; Z
 
 Angles[1] = X
 Angles[2] = Y
 Angles[3] = Z
]]
Lua:
function attachObjectToPlayer( hObject, hPlayer, pOffsets, pAngles )
    if doesObjectExist( hObject ) and doesCharExist( hPlayer ) then
        if not pOffsets then pOffsets = { 0.0, 0.0, 0.0 } end
        if not pAngles then pAngles = { 0.0, 0.0, 0.0 } end
     
        setObjectCoordinates( hObject, getCharCoordinates( hPlayer ) ) -- без доп установки позиции почему-то иногда неправильно выставлялись оффсеты
        setObjectCollision( hObject, false ) -- по желанию можно убрать
     
        local pointer = getObjectPointer( hObject )
     
        memory.setuint32( pointer + 0xFC, getCharPointer( hPlayer ) ) -- прикрепляем
     
        memory.setfloat( pointer + 0x100, pOffsets[1] ) -- задаём оффсет
        memory.setfloat( pointer + 0x104, pOffsets[2] )
        memory.setfloat( pointer + 0x108, pOffsets[3] )

        memory.setfloat( pointer + 0x10C, pAngles[1] ) -- задаём угол
        memory.setfloat( pointer + 0x110, pAngles[2] )
        memory.setfloat( pointer + 0x114, pAngles[3] )

        return true
    end
    return false
end
Lua:
function attachObjectToVehicle( hObject, hVehicle, vOffsets, vAngles )
    if doesObjectExist( hObject ) and doesVehicleExist( hVehicle ) then
        if not vOffsets then vOffsets = { 0.0, 0.0, 0.0 } end
        if not vAngles then vAngles = { 0.0, 0.0, 0.0 } end
     
        setObjectCoordinates( hObject, getCarCoordinates( hVehicle ) ) -- без доп установки позиции почему-то иногда неправильно выставлялись оффсеты
        setObjectCollision( hObject, false ) -- по желанию можно убрать
     
        local pointer = getObjectPointer( hObject )
     
        memory.setuint32( pointer + 0xFC, getCarPointer( hVehicle ) ) -- прикрепляем
     
        memory.setfloat( pointer + 0x100, vOffsets[1] ) -- задаём оффсет
        memory.setfloat( pointer + 0x104, vOffsets[2] )
        memory.setfloat( pointer + 0x108, vOffsets[3] )

        memory.setfloat( pointer + 0x10C, vAngles[1] ) -- задаём угол
        memory.setfloat( pointer + 0x110, vAngles[2] )
        memory.setfloat( pointer + 0x114, vAngles[3] )
     
        return true
    end
    return false
end

Lua:
local memory = require 'memory'
local playerObj, vehObj = nil, nil

--main
sampRegisterChatCommand('attach', function( )
    if isCharIsAnyCar( PLAYER_PED ) and not vehObj then
        local car = storeCarCharIsInNoSave( PLAYER_PED )
        vehObj = createObject( 1083, getCarCoordinates( car ) )
        if attachObjectToVehicle( vehObj, car, { 0.0, 0.0, 5.0 }, { 0.0, 0.0, 3.14/2 } ) then -- прикрепит объект над крышей транспорта, поперёк
            print( ("Объект %d прикреплён к авто %d"):format( getObjectModel( vehObj ), getCarModel( car ) ) )
        end
    elseif not isCharInAnyCar( PLAYER_PED ) and not playerObj then
        playerObj = createObject( 1083, getCharCoordinates( PLAYER_PED ) )
        if attachObjectToPlayer( playerObj, PLAYER_PED, { 0.0, 0.0, 5.0 }, { 0.0, 0.0, 3.14/2 } ) then -- прикрепит объект над персонажем, поперёк
            print( ("Объект %d прикреплён к педу %d"):format( getObjectModel( playerObj ), PLAYER_PED ) )
        end
    else
        if playerObj then deleteObject( playerObj ); playerObj = nil end -- удаляются как простые объекты
        if vehObj then    deleteObject( vehObj );    vehObj = nil    end
    end
end)

-- вне main копируем функции

Извиняюсь, если говнокод. 😉
К вашему вниманию: функция attachObjectToChar(Object object, Ped ped, float offsetX, float offsetY, float offsetZ, float rotationX, float rotationY, float rotationZ)
а также функция attachObjectToCar(Object object, Vehicle car, float offsetX, float offsetY, float offsetZ, float rotationX, float rotationY, float rotationZ)
 

lorgon

Известный
657
268
Описание: Рисует градиентный треугольник по координатам вершин
Lua:
function AddTriangleMulticolor(a, b, c, colorA, colorB, colorC)
    local draw = imgui.GetWindowDrawList()
    local uv = imgui.GetFontTexUvWhitePixel()
    draw:PrimReserve(3, 3)
    draw:PrimVtx(a, uv, colorA)
    draw:PrimVtx(b, uv, colorB)
    draw:PrimVtx(c, uv, colorC)
end
Пример использования:
Lua:
local clr = {
  a = imgui.GetColorU32Vec4(imgui.ImVec4(1, 0, 0, 1)),
  b = imgui.GetColorU32Vec4(imgui.ImVec4(0, 1, 0, 1)),
  c = imgui.GetColorU32Vec4(imgui.ImVec4(0, 0, 1, 1)),
}
AddTriangleMulticolor(imgui.ImVec2(0, 0), imgui.ImVec2(30, 60), imgui.ImVec2(60, 0), clr.a, clr.b, clr.c)
1643464821067.png
 

neverlessy

Потрачен
170
121
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Описание: Подсказка при наведении на кнопку ImGui
Вначале скрипта
Lua:
local encoding = require 'encoding'
encoding.default = "CP1251"
local u8 = encoding.UTF8
Где-то в коде
Lua:
function imgui.CustomButton(label, size, description)
    local result = imgui.Button(u8(label), size, u8(description))
    if imgui.IsItemHovered() then
        imgui.BeginTooltip()
            imgui.PushTextWrapPos(600)
                imgui.TextUnformatted(description)
            imgui.PopTextWrapPos()
        imgui.EndTooltip()
    end
        return result
end
Пример использования:
Lua:
imgui.CustomButton(u8"Кнопка!", imgui.ImVec2(80, 80), u8:encode("Подсказка!"))

09.38.56.906.jpg