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

Fomikus

Известный
Проверенный
469
339
Описание: Кастомный чекбокс для имгуи (Максимально приближен к оригинальному), однако вместо галочки - квадратик
p.s Цвета использует из стиля (Как и обычный)
V0rxZLEJE2.gif

Lua:
function fCheckbox(text, bool, size, fill_size, round, fill_round)
    local size = size or imgui.GetTextLineHeightWithSpacing() + 1
    local fill_size = fill_size or 0.1
    local round = round or 1.0
    local fill_round = fill_round or 1.0
    local p = imgui.GetCursorScreenPos()
    if imgui.InvisibleButton('f##'..text, imgui.ImVec2(size + imgui.CalcTextSize(text).x, size)) then
        bool.v = not bool.v
    end
    if imgui.IsItemActive() then
        imgui.GetWindowDrawList():AddRectFilled(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x + size, p.y + size), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBgActive]), round)
    elseif imgui.IsItemHovered()  then
        imgui.GetWindowDrawList():AddRectFilled(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x + size, p.y + size), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBgHovered]), round)
    else
        imgui.GetWindowDrawList():AddRectFilled(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x + size, p.y + size), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBg]), round)
    end
    if bool.v then imgui.GetWindowDrawList():AddRectFilled(imgui.ImVec2(p.x + size * fill_size, p.y + size * fill_size), imgui.ImVec2(p.x + size - size * fill_size, p.y + size - size * fill_size), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.CheckMark]), fill_round) end
    imgui.SameLine()
    imgui.SetCursorPosX(imgui.GetCursorPosX() - imgui.CalcTextSize(text).x)
    imgui.SetCursorPosY(imgui.GetCursorPosY() + 1 + imgui.GetStyle().ItemSpacing.y / 2)
    imgui.Text(text)
    imgui.SetCursorPosY(imgui.GetCursorPosY() - imgui.GetStyle().ItemSpacing.y / 2)
end
Пример использования:
Lua:
--Вне всего
local imBool = imgui.ImBool(false)

--imgui.OnDrawFrame()
        fCheckbox('Default fCheckbox(20, 0.1)', imBool)
        fCheckbox('fCheckbox with size 20 and fill_size 0.15', imBool, 20)
        fCheckbox('fCheckbox with size 20 and fill_size 0.2', imBool, 20, 0.2, 5)
        fCheckbox('fCheckbox with size 20 and fill_size 0.3', imBool, 20, 0.3, 10, 10)

--Сама функция
function fCheckbox(text, bool, size, fill_size, round, fill_round)
    local size = size or imgui.GetTextLineHeightWithSpacing() + 1
    local fill_size = fill_size or 0.1
    local round = round or 1.0
    local fill_round = fill_round or 1.0
    local p = imgui.GetCursorScreenPos()
    if imgui.InvisibleButton('f##'..text, imgui.ImVec2(size + imgui.CalcTextSize(text).x, size)) then
        bool.v = not bool.v
    end
    if imgui.IsItemActive() then
        imgui.GetWindowDrawList():AddRectFilled(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x + size, p.y + size), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBgActive]), round)
    elseif imgui.IsItemHovered()  then
        imgui.GetWindowDrawList():AddRectFilled(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x + size, p.y + size), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBgHovered]), round)
    else
        imgui.GetWindowDrawList():AddRectFilled(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x + size, p.y + size), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBg]), round)
    end
    if bool.v then imgui.GetWindowDrawList():AddRectFilled(imgui.ImVec2(p.x + size * fill_size, p.y + size * fill_size), imgui.ImVec2(p.x + size - size * fill_size, p.y + size - size * fill_size), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.CheckMark]), fill_round) end
    imgui.SameLine()
    imgui.SetCursorPosX(imgui.GetCursorPosX() - imgui.CalcTextSize(text).x)
    imgui.SetCursorPosY(imgui.GetCursorPosY() + 1 + imgui.GetStyle().ItemSpacing.y / 2)
    imgui.Text(text)
    imgui.SetCursorPosY(imgui.GetCursorPosY() - imgui.GetStyle().ItemSpacing.y / 2)
end
UPD: Добавил возможность менять "окружность"
 
Последнее редактирование:

_raz0r

t.me/sssecretway | ТГК: t.me/razor_code
Модератор
1,888
3,048
Описание: Изменяет координаты хп бара по X и Y координате
Lua:
function editHealthBarCoordinates(posX, posY)
    local X = memory.getuint32(0x58EE87, true)
    local Y = memory.getuint32(0x58EE68, true)
    memory.setfloat(X, posX)
    memory.setfloat(Y, posY)
end
Пример использования:
Lua:
function main()
    repeat wait(0) until isSampAvailable()
    editHealthBarCoordinates(120.0, 120.0)
end
1597260216293.png
 

_raz0r

t.me/sssecretway | ТГК: t.me/razor_code
Модератор
1,888
3,048
Описание: Изменяет цвет отражения от фар
Lua:
function editVehicleLightsColor(r, g, b)
    memory.setuint8(0x6E1689, r, true)
    memory.setuint8(0x6E1687, g, true)
    memory.setuint8(0x6E1685, b, true)
    memory.setuint8(0x6E1560, r, true)
    memory.setuint8(0x6E155E, g, true)
    memory.setuint8(0x6E1556, b, true)
end
Пример использования:
Lua:
function main()
        editVehicleLightsColor(255, 0, 0)
end
1597350367968.png
 
Последнее редактирование:

_raz0r

t.me/sssecretway | ТГК: t.me/razor_code
Модератор
1,888
3,048
Описание: Изменяет дистанцию прорисовки /dl для SA:MP 0.3.7 R4
Lua:
function editDLDrawDistance(distance)
    local handle = getModuleHandle("samp.dll")
    if handle == 0x0 then return end
    memory.setfloat(handle + 0xE5804, distance, 1) -- стандартное значение 20.0
end
Пример использования:
Lua:
editDLDrawDistance(999.9)
 

imring

Ride the Lightning
Всефорумный модератор
2,355
2,516
Описание: Конвертирует HEX в DEC и так же DEC в HEX
Lua:
function hex_to_dec(hex)
  if type(hex) ~= "string" then
    sampAddChatMessage("[Ошибка]: {FFFFFF}Тип значения не строковый.", 0xFF0000)
  end
    local dec = tonumber(string.sub(hex, 1), 16)
  return dec
end

function dec_to_hex(dec)
  if type(dec) ~= "number" then
    sampAddChatMessage("[Ошибка]: {FFFFFF}Тип значения не числовой.", 0xFF0000)
  end
  if dec - math.floor(dec) > 0 then
    sampAddChatMessage("[Ошибка]: {FFFFFF}Попытка применить побитовую операцию к нецелому числу.", 0xFF0000)
  end
  if dec < 0 then
    dec = bit.tobits(bit.bnot(math.abs(dec)) + 1)
    dec = bit.tonumb(dec)
  end
  local hex_tbl = {'A', 'B', 'C', 'D', 'E', 'F'}
  local hex = ""
  while dec ~= 0 do
    last = math.fmod(dec, 16)
    if last < 10 then
      hex = tostring(last) .. hex
    else
      hex = hex_tbl[last - 10 + 1] .. hex
    end
    dec = math.floor(dec / 16)
  end
  if hex == "" then
    hex = "0"
  end
  return hex
end
Пример использования:
Lua:
dec_to_hex(4289003775)
hex_to_dec("FFA500FF")
hex_to_dec("0xFFA500FF")
Lua:
local hex = ('%x'):format(4289003775)
local dec = tonumber('FFA500FF', 16)
 

_raz0r

t.me/sssecretway | ТГК: t.me/razor_code
Модератор
1,888
3,048
Описание: Делает скриншот в SA:MP 0.3.7 R4 (требуется FFI)
Lua:
function sampTakeScreenshot()
    ffi.cast('void (__cdecl *)(void)', getModuleHandle("samp.dll") + 0x755F0)( )
end
Пример использования:
Lua:
sampTakeScreenshot()
 

aurora_

Участник
11
47
Описание: Кастомный слайдер для ImGui
Безымянный.png

Lua:
function imgui.CustomSlider(str_id, min, max, width, int) -- by aurora
    local p = imgui.GetCursorScreenPos()
    local draw_list = imgui.GetWindowDrawList()
    local pos = imgui.GetWindowPos()
    local posx,posy = getCursorPos()
    local n = max - min
    if int.v == 0 then
        int.v = min
    end
    local col_bg_active = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.ButtonActive])
    local col_bg_notactive = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.ModalWindowDarkening])
    draw_list:AddRectFilled(imgui.ImVec2(p.x + 7, p.y + 12), imgui.ImVec2(p.x + (width/n)*(int.v-min), p.y + 12), col_bg_active, 5.0)
    draw_list:AddRectFilled(imgui.ImVec2(p.x + (width/n)*(int.v-min), p.y + 12), imgui.ImVec2(p.x + width, p.y + 12), col_bg_notactive, 5.0)
    for i = 0, n do
        if posx > (p.x + i*width/(max+1) ) and posx < (p.x + (i+1)*width/(max+1)) and posy > p.y + 2 and posy < p.y + 22 and imgui.IsMouseDown(0) then
            int.v = i + min
            draw_list:AddCircleFilled(imgui.ImVec2(p.x + (width/n)*(int.v-min) + 4,  p.y + 7*2 - 2), 7+2, col_bg_active)
        end
    end
    imgui.SetCursorPos(imgui.ImVec2(p.x + width + 6 - pos.x, p.y - 8 - pos.y))
    imgui.Text(tostring(int.v))
    draw_list:AddCircleFilled(imgui.ImVec2(p.x + (width/n)*(int.v-min) + 4,  p.y + 7*2 - 2), 7, col_bg_active)
    imgui.NewLine()
    return int
end
Пример использования:
Lua:
--Вне всего
local int = imgui.ImInt(0)

--Imgui.OnDrawFrame()
imgui.CustomSlider("Slider1", 0, 10, 200, int) -- Название слайдера(Slider1), Мин. значение(0), Макс. значение(10), Ширина(200), Значение(int)

--Функция слайдера(выше)
 

Cosmo

Известный
Друг
646
2,591
Описание:
Подсказка с анимацией появления, можно выставить задержку появления (если не указывать будет без задержки)
P.s. На гифке для наглядности, чуть более доработаная версия, с иконками (faAwesome) и imgui.TextColored

Lua:
function imgui.Hint(str_id, hint, delay)
    local hovered = imgui.IsItemHovered()
    local animTime = 0.2
    local delay = delay or 0.00
    local show = true

    if not allHints then allHints = {} end
    if not allHints[str_id] then
        allHints[str_id] = {
            status = false,
            timer = 0
        }
    end

    if hovered then
        for k, v in pairs(allHints) do
            if k ~= str_id and os.clock() - v.timer <= animTime  then
                show = false
            end
        end
    end

    if show and allHints[str_id].status ~= hovered then
        allHints[str_id].status = hovered
        allHints[str_id].timer = os.clock() + delay
    end

    if show then
        local between = os.clock() - allHints[str_id].timer
        if between <= animTime then
            local s = function(f)
                return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
            end
            local alpha = hovered and s(between / animTime) or s(1.00 - between / animTime)
            imgui.PushStyleVarFloat(imgui.StyleVar.Alpha, alpha)
            imgui.SetTooltip(hint)
            imgui.PopStyleVar()
        elseif hovered then
            imgui.SetTooltip(hint)
        end
    end
end

Пример использования:
Lua:
imgui.Text('Секрет!')
imgui.Hint('hintSecret', 'Ты меня не видел и я тебя тоже. Всё, давай.')
hintDemo.gif
 
Последнее редактирование:

_raz0r

t.me/sssecretway | ТГК: t.me/razor_code
Модератор
1,888
3,048
Описание: Изменяет местоположение текста текущего диалога
Lua:
function editDialogTextPos(x, y)
     local shitdword = memory.getuint32(getModuleHandle("samp.dll") + 0x21A0B8, true)
     memory.write(shitdword + 0x04, x, 4, true) — X
     memory.write(shitdword + 0x08, y, 4, true) — Y
end
Пример использования:
Lua:
editDialogTextPos(150, 150)
1598010228884.png
 

RTD

Нестандартное звание
Модератор
391
413
Описание: Выбирает раскладку. При первом вызове профризит
Lua:
local ffi = require 'ffi'
ffi.cdef[[
    intptr_t LoadKeyboardLayoutA(const char* pwszKLID, unsigned int Flags);
    int PostMessageA(intptr_t hWnd, unsigned int Msg, unsigned int wParam, long lParam);
    intptr_t GetActiveWindow();
]]
do
local buffer = {}
function setKeyboardLanguage(lang)
    if buffer[lang] == nil then
        buffer[lang] = ffi.C.LoadKeyboardLayoutA(lang, 1);
    end
    ffi.C.PostMessageA(ffi.C.GetActiveWindow(), 0x50, 1, buffer[lang]);
end
end
Пример использования:
Lua:
setKeyboardLanguage("00000409") --en
setKeyboardLanguage("00000419") --ru
setKeyboardLanguage("00000422") --ua
 

aurora_

Участник
11
47
Описание: CheckComboBox для imgui (нет в обычной ImGui)
gta_sa_OmLTrHFx5Z.png

Lua:
function imgui.CheckComboBox(str_id, array, chosen_array) -- by aurora
    local p = imgui.GetCursorScreenPos()
    local pos = imgui.GetWindowPos()
    local choose = imgui.ImInt(0)
    local textbuffer = table.concat(chosen_array, ", ", 1,#chosen_array)
    local buf = imgui.ImBuffer(textbuffer,256)
    for i = 1, #chosen_array do
        if chosen_array[i]:find('[+]') then
            chosen_array[i] = chosen_array[i]:match("%p+%p(.+)")
        end
    end
    if imgui.Combo(str_id, choose, array) then
        for i = 0, #array do
            if choose.v == i then
                chosen.v = false
                for k,v in ipairs(chosen_array) do
                    if '[+]' .. v == array[i+1] then
                        chosen.v = true
                        table.remove(chosen_array,k)
                        array[i+1] = array[i+1]:match("%p+%p(.+)")
                    end
                end
                if not chosen.v then
                    table.insert(chosen_array, array[i+1])
                    table.remove(array, i+1)
                    table.insert(array,i+1,'[+]' .. chosen_array[#chosen_array])
                end
            end
        end
    end
    imgui.SameLine()
    imgui.SetCursorPosX(p.x-pos.x)
    imgui.PushItemWidth(imgui.CalcItemWidth()-20)
    imgui.InputText("##" .. str_id,buf)
    imgui.NewLine()
end
Пример использования:
Lua:
local items = {'first','second','third','fourth'} -- Список
local chosen_items = {} -- Массив, куда будут записываться выбранные элементы списка

local chosen = imgui.ImBool(false) -- Нужно для показа, выбран ли определенный элемент или нет
-- Вне всего

imgui.CheckComboBox('CheckComboBox1', items, chosen_items)
-- В имгуи

function imgui.CheckComboBox(str_id, array, chosen_array) -- by aurora
    local p = imgui.GetCursorScreenPos()
    local pos = imgui.GetWindowPos()
    local choose = imgui.ImInt(0)
    local textbuffer = table.concat(chosen_array, ", ", 1,#chosen_array)
    local buf = imgui.ImBuffer(textbuffer,256)
    for i = 1, #chosen_array do
        if chosen_array[i]:find('[+]') then
            chosen_array[i] = chosen_array[i]:match("%p+%p(.+)")
        end
    end
    if imgui.Combo(str_id, choose, array) then
        for i = 0, #array do
            if choose.v == i then
                chosen.v = false
                for k,v in ipairs(chosen_array) do
                    if '[+]' .. v == array[i+1] then
                        chosen.v = true
                        table.remove(chosen_array,k)
                        array[i+1] = array[i+1]:match("%p+%p(.+)")
                    end
                end
                if not chosen.v then
                    table.insert(chosen_array, array[i+1])
                    table.remove(array, i+1)
                    table.insert(array,i+1,'[+]' .. chosen_array[#chosen_array])
                end
            end
        end
    end
    imgui.SameLine()
    imgui.SetCursorPosX(p.x-pos.x)
    imgui.PushItemWidth(imgui.CalcItemWidth()-20)
    imgui.InputText("##" .. str_id,buf)
    imgui.NewLine()
end
-- Сама функция
 
Последнее редактирование:

Fott

Простреленный
3,425
2,251
Описание: Изменяет координаты радара по X и Y координате при помощи ffi
Lua:
local ffi = require 'ffi'
ffi.cdef
[[
    void *malloc(size_t size);
    void free(void *ptr);
]]


function changeRadarPos(posX, posY)
    local positionX = ffi.cast('float*', ffi.C.malloc(4))
    local positionY = ffi.cast('float*', ffi.C.malloc(4))
    positionX[0] = posX
    positionY[0] = posY
    ffi.cast('float**', 0x58A79B)[0] = positionX
    ffi.cast('float**', 0x5834D4)[0] = positionX
    ffi.cast('float**', 0x58A836)[0] = positionX
    ffi.cast('float**', 0x58A8E9)[0] = positionX
    ffi.cast('float**', 0x58A98A)[0] = positionX
    ffi.cast('float**', 0x58A469)[0] = positionX
    ffi.cast('float**', 0x58A5E2)[0] = positionX
    ffi.cast('float**', 0x58A6E6)[0] = positionX

    ffi.cast('float**', 0x58A7C7)[0] = positionY
    ffi.cast('float**', 0x58A868)[0] = positionY
    ffi.cast('float**', 0x58A913)[0] = positionY
    ffi.cast('float**', 0x58A9C7)[0] = positionY
    ffi.cast('float**', 0x583500)[0] = positionY
    ffi.cast('float**', 0x58A499)[0] = positionY
    ffi.cast('float**', 0x58A60E)[0] = positionY
    ffi.cast('float**', 0x58A71E)[0] = positionY
end

function onExitScript()
    ffi.C.free(positionX)
    ffi.C.free(positionY)
end

Пример использования:
Lua:
changeRadarPos(123, 123)
 

_raz0r

t.me/sssecretway | ТГК: t.me/razor_code
Модератор
1,888
3,048
Описание: Изменяет цвета прицела (знаю что есть плагин от человечка)
Lua:
function changeCrosshairColor(rgba)
    local r = bit.band(bit.rshift(rgba, 24), 0xFF)
    local g = bit.band(bit.rshift(rgba, 16), 0xFF)
    local b = bit.band(bit.rshift(rgba, 8), 0xFF)
    local a = bit.band(rgba, 0xFF)

    memory.setuint8(0x58E301, r, true)
    memory.setuint8(0x58E3DA, r, true)
    memory.setuint8(0x58E433, r, true)
    memory.setuint8(0x58E47C, r, true)

    memory.setuint8(0x58E2F6, g, true)
    memory.setuint8(0x58E3D1, g, true)
    memory.setuint8(0x58E42A, g, true)
    memory.setuint8(0x58E473, g, true)

    memory.setuint8(0x58E2F1, b, true)
    memory.setuint8(0x58E3C8, b, true)
    memory.setuint8(0x58E425, b, true)
    memory.setuint8(0x58E466, b, true)

    memory.setuint8(0x58E2EC, a, true)
    memory.setuint8(0x58E3BF, a, true)
    memory.setuint8(0x58E420, a, true)
    memory.setuint8(0x58E461, a, true)
end
Пример использования:
Lua:
changeCrosshairColor(0xFF00FFFF)
1599304875026.png
 

lemonager

;)
Всефорумный модератор
809
1,701
Описание: Изменение стиля шрифта в esc - "Меню игры" (0 - 3) :
Lua:
memory.setuint8(0x57958B, 2, true)-- 2 замените на число 0 - 3
Изменение общего стиля шрифта в esc (0 - 3) :
Lua:
memory.setuint8(0x5799AD, 1, true)--1 замените на число 0 - 3
Изменение цвета обводки шрифта в главном меню(RGB):
Lua:
memory.setuint8(0x579A3E, r, true)-- основной шрифт \ обводка
memory.setuint8(0x579A3C, g, true)
memory.setuint8(0x579A3A, b, true)

memory.setuint8(0x57974C, r, true) -- выйти с игры \ обводка
memory.setuint8(0x57974A, g, true)
memory.setuint8(0x579748, b, true)
GTA_SA_MP 2020-09-09 19-42-38 (online-video-cutter.com).gif

Lua:
function changeMenuColors(speed)
     local r = math.floor(math.sin(os.clock() * speed) * 50 + 50)
     local g = math.floor(math.sin(os.clock() * speed + 3) * 50 + 50)
     local b = math.floor(math.sin(os.clock() * speed + 5) * 50 + 50)
     memory.setuint8(0x57974C, r, true)
     memory.setuint8(0x57974A, g, true)
     memory.setuint8(0x579748, b, true)

     memory.setuint8(0x579A3E, r, true)
     memory.setuint8(0x579A3C, g, true)
     memory.setuint8(0x579A3A, b, true)
end
Использовать в цикле..
 
Последнее редактирование:

CaJlaT

Овощ
Модератор
2,806
2,603
Описание: Изменение цвета обводки радара
Lua:
function changeRadarColor(rgba)
    local r = bit.band(bit.rshift(rgba, 24), 0xFF)
    local g = bit.band(bit.rshift(rgba, 16), 0xFF)
    local b = bit.band(bit.rshift(rgba, 8), 0xFF)
    local a = bit.band(rgba, 0xFF)
    memory.write(0x58A798, r, 1, true)
    memory.write(0x58A89A, r, 1, true)
    memory.write(0x58A8EE, r, 1, true)
    memory.write(0x58A9A2, r, 1, true)

    memory.write(0x58A790, g, 1, true)
    memory.write(0x58A896, g, 1, true)
    memory.write(0x58A8E6, g, 1, true)
    memory.write(0x58A99A, g, 1, true)

    memory.write(0x58A78E, b, 1, true)
    memory.write(0x58A894, b, 1, true)
    memory.write(0x58A8DE, b, 1, true)
    memory.write(0x58A996, b, 1, true)

    memory.write(0x58A789, a, 1, true)
    memory.write(0x58A88F, a, 1, true)
    memory.write(0x58A8D9, a, 1, true)
    memory.write(0x58A98F, a, 1, true)
end
Пример использования: радужная обводка
ezgif.com-video-to-gif.gif


Lua:
local memory = require 'memory'
function main()
    while true do
        wait(0)
        local r, g, b, a = rainbow(3, 255)
        changeRadarColor(join_argb(r, g, b, a))
    end
end

function changeRadarColor(rgba)
    local r = bit.band(bit.rshift(rgba, 24), 0xFF)
    local g = bit.band(bit.rshift(rgba, 16), 0xFF)
    local b = bit.band(bit.rshift(rgba, 8), 0xFF)
    local a = bit.band(rgba, 0xFF)
    memory.write(0x58A798, r, 1, true)
    memory.write(0x58A89A, r, 1, true)
    memory.write(0x58A8EE, r, 1, true)
    memory.write(0x58A9A2, r, 1, true)

    memory.write(0x58A790, g, 1, true)
    memory.write(0x58A896, g, 1, true)
    memory.write(0x58A8E6, g, 1, true)
    memory.write(0x58A99A, g, 1, true)

    memory.write(0x58A78E, b, 1, true)
    memory.write(0x58A894, b, 1, true)
    memory.write(0x58A8DE, b, 1, true)
    memory.write(0x58A996, b, 1, true)

    memory.write(0x58A789, a, 1, true)
    memory.write(0x58A88F, a, 1, true)
    memory.write(0x58A8D9, a, 1, true)
    memory.write(0x58A98F, a, 1, true)
end
function rainbow(speed, alpha)
    return math.floor(math.sin(os.clock() * speed) * 127 + 128), math.floor(math.sin(os.clock() * speed + 2) * 127 + 128), math.floor(math.sin(os.clock() * speed + 4) * 127 + 128), alpha
end
function join_argb(a, r, g, b)
  local argb = b  -- b
  argb = bit.bor(argb, bit.lshift(g, 8))  -- g
  argb = bit.bor(argb, bit.lshift(r, 16)) -- r
  argb = bit.bor(argb, bit.lshift(a, 24)) -- a
  return argb
end
UPD: Добавил альфа-канал, спасибо @S E V E N
 
Последнее редактирование: