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

Angr

Известный
291
97
Описание: enum в мире Lua, а то много делают страшных вещей в коде и сами путаются
Lua:
function enum( name )
    return function( array )
        for i, v in ipairs( array ) do
            _G[ v ] = i
        end
    end
end
Пример использования:
Lua:
enum "dialogStyles" {
    "DIALOG_STYLE_MSGBOX",
    "DIALOG_STYLE_INPUT",
    "DIALOG_STYLE_LIST",
    "DIALOG_STYLE_PASSWORD",
    "DIALOG_STYLE_TABLIST",
    "DIALOG_STYLE_TABLIST_HEADERS",
}


local type = sampGetCurrentDialogType()
if type == DIALOG_STYLE_LIST then
    -- TODO: ...
end

-- Пример 2
enum "adminRights" {
    "PLAYER_KICK",
    "PLAYER_BAN",
    "PLAYER_MUTE",
    "PLAYER_FREEZE",
    "PLAYER_SHOUT",
    "PLAYER_SET_HEALTH",
    "PLAYER_SET_ARMOUR",
    "PLAYER_SET_SKIN",
    "PLAYER_SET_MONEY",
    "PLAYER_SET_STAT",
    "PLAYER_SET_TEAM",
    "PLAYER_SET_INTERIOR",
    "PLAYER_SET_DIMENSION",
    "PLAYER_JETPACK",
    "PLAYER_SET_GROUP",
    "PLAYER_GIVE_VEHICLE",
    "PLAYER_GIVE_WEAPON",
    "PLAYER_SLAP",
    "PLAYER_WARP",
    "PLAYER_WARP_TO"
}

print( PLAYER_WARP_TO ) -- выведет 20
 
Последнее редактирование:

The Spark

Известный
654
666
Описание: Удобный враппер для http запросов. Работает везде: samp, rakbot, raklite (два примера).
Используется https://www.blast.hk/threads/20532/post-256096, но функция чуть переделана.
Принимает url, options и callback.
Возвращает bool, response, statusCode, headers и status.

options:
query = {) -- параметры GET запроса.
body = {} -- тело запроса (POST, PUT и тд).
headers = {} -- заголовки. По стандарту ["Content-Type"] = "application/x-www-form-urlencoded", ["Accept"] = "*/*"
method = "" -- по стандарту GET.

callback:
При указании, запрос выполняется в отдельном потоке. Возвращает bool, response, statusCode, headers, status.

Если не указывать options и callback - выполнится GET запрос в текущем потоке.

Код: (неизвестные функции в примере)
Lua:
function wrapperHttpRequest(url, options, callback) -- return bool, response, statusCode, headers, status
    local options = options or {}
 
    local method = options.method or "GET"
    local url = (options.query) and url .. "?" .. http_build_query(options.query) or url
    local body = (options.body) and http_build_query(options.body) or nil
    local headers = options.headers or {["Content-Type"] = "application/x-www-form-urlencoded", ["Accept"] = "*/*"}

    local data = {
        data = body,
        headers = headers
    }

    if callback then
        lua_thread.create(function () -- or Tasking.new(function ()
            callback(async_http_request(method, url, data))
        end)
    else
        return async_http_request(method, url, data)
    end
end

Пример для samp:
Lua:
local effil = require 'effil'

function main()
    while not isSampAvailable() do wait(0) end
    if not isSampfuncsLoaded() and not isCleoLoaded() then return end

    while true do wait(0)
        if isKeyJustPressed(0x31) then -- 1
            -- request GET
            local bool, response, statusCode, headers, status = wrapperHttpRequest('https://httpbin.org/get', {
                query = {
                    key = "123"
                }
            })
            print(bool, response)
        end

        if isKeyJustPressed(0x32) then -- 2
            -- standart GET request
            local bool, response, statusCode, headers, status = wrapperHttpRequest('https://httpbin.org/get')
            print(bool, response)
        end

        if isKeyJustPressed(0x33) then -- 3
            -- callback GET and User-Agent
            wrapperHttpRequest('https://httpbin.org/get', {
                query = {
                    unknown = "str"
                },
                headers = {
                    ['User-Agent'] = 'macintosh',
                    ["Content-Type"] = "application/x-www-form-urlencoded",
                    ["Accept"] = "*/*"
                }
            }, function (bool, response, statusCode, headers, status)
                print(bool, response)
            end)
        end

        if isKeyJustPressed(0x34) then -- 4
            -- callback POST
            wrapperHttpRequest('https://httpbin.org/post', {
                method = 'POST',
                body = {
                    param = 101
                }
            }, function (bool, response, statusCode, headers, status)
                print(bool, response)
            end)
        end
    end
end

function wrapperHttpRequest(url, options, callback) -- return bool, response, statusCode, headers, status
    local options = options or {}
 
    local method = options.method or "GET"
    local url = (options.query) and url .. "?" .. http_build_query(options.query) or url
    local body = (options.body) and http_build_query(options.body) or nil
    local headers = options.headers or {["Content-Type"] = "application/x-www-form-urlencoded", ["Accept"] = "*/*"}

    local data = {
        data = body,
        headers = headers
    }

    if callback then
        lua_thread.create(function ()
            callback(async_http_request(method, url, data))
        end)
    else
        return async_http_request(method, url, data)
    end
end

function url_encode(str)
    local str = string.gsub(str, "\\", "\\")
    str = string.gsub(str, "([^%w])", function(text)
        return string.format("%%%02X", string.byte(text))
    end)
    return str
end

function http_build_query(query)
    local buff = ""
    if type(query) == "table" then
        for k, v in pairs(query) do
            buff = buff .. string.format("%s=%s&", k, url_encode(v))
        end
        buff = string.reverse(string.gsub(string.reverse(buff), "&", "", 1))
    end
    return buff;
end

function async_http_request(method, url, args)
    local request_thread = effil.thread(function (method, url, args)
        local requests = require 'requests'
        local result, response = pcall(requests.request, method, url, args)
        if result then
            response.json, response.xml = nil, nil
            return true, response
        else
            return false, response
        end
    end)(method, url, args)

    -- проверка выполнения потока
    local runner = request_thread
    while true do
        local status, err = runner:status()
        if not err then
            if status == 'completed' then
                local result, response = runner:get()
                if result then
                    return true, response.text, response.status_code, response.headers, response.status
                else
                    return false
                end
            elseif status == 'canceled' then
                return false
            end
        else
            return false
        end
        wait(0)
    end
end

Важно! RakBot - худшая программа и флуд запросами его повешает. На RakLite с этим всё хорошо
Пример для RakBot и RakLite:
Lua:
if not getIP then
    -- только для RakBot
    package.path = getRakBotPath() .. "/scripts/libs/?.lua;" .. getRakBotPath() .. "/scripts/libs/?/init.lua;";
    package.cpath = getRakBotPath() .. "/scripts/libs/?.dll";
   
    require 'Tasking'
    onScriptUpdate = Tasking.tick -- RakBot
    print = printLog
else
    require 'Tasking'
    onUpdate = Tasking.tick -- RakLite
end

local effil = require 'effil'

function onRunCommand(cmd)
    if cmd == "!1" then
        -- get request
        Tasking.new(function() -- без потока крашнет, т.к мы не можем стопать событие
            local bool, response, statusCode, headers, status = wrapperHttpRequest('https://httpbin.org/get', {
                query = {
                    key = "123"
                }
            })
            print(response)
        end)
        return true
    end

    if cmd == "!2" then
        -- get standart request
        Tasking.new(function() -- без потока крашнет, т.к мы не можем стопать событие
            local bool, response, statusCode, headers, status = wrapperHttpRequest('https://httpbin.org/get')
            print(response)
        end)
        return true
    end

    if cmd == "!3" then
        -- callback get and User-Agent
        -- тут поток не нужен из-за callback
        wrapperHttpRequest('https://httpbin.org/get', {
            query = {
                unknown = "str"
            },
            headers = {
                ['User-Agent'] = 'macintosh',
                ["Content-Type"] = "application/x-www-form-urlencoded",
                ["Accept"] = "*/*"
            }
        }, function(bool, response, statusCode, headers, status)
            print(response)
        end)
        return true
    end

    if cmd == "!4" then
        -- callback post
        -- тут поток не нужен
        wrapperHttpRequest('https://httpbin.org/post', {
            method = 'POST',
            body = {
                param = 101
            }
        }, function(bool, response, statusCode, headers, status)
            print(response)
        end)
        return true
    end
end

function wrapperHttpRequest(url, options, callback) -- return bool, response, statusCode, headers, status
    local options = options or {}

    local method = options.method or "GET"
    local url = (options.query) and url .. "?" .. http_build_query(options.query) or url
    local body = (options.body) and http_build_query(options.body) or nil
    local headers = options.headers or { ["Content-Type"] = "application/x-www-form-urlencoded", ["Accept"] = "*/*" }

    local data = {
        data = body,
        headers = headers
    }

    if callback then
        Tasking.new(function()
            callback(async_http_request(method, url, data))
        end)
    else
        return async_http_request(method, url, data)
    end
end

function url_encode(str)
    local str = string.gsub(str, "\\", "\\")
    str = string.gsub(str, "([^%w])", function(text)
        return string.format("%%%02X", string.byte(text))
    end)
    return str
end

function http_build_query(query)
    local buff = ""
    if type(query) == "table" then
        for k, v in pairs(query) do
            buff = buff .. string.format("%s=%s&", k, url_encode(v))
        end
        buff = string.reverse(string.gsub(string.reverse(buff), "&", "", 1))
    end
    return buff;
end

function async_http_request(method, url, args)
    local request_thread = effil.thread(function(method, url, args)
        local requests = require 'requests'
        local result, response = pcall(requests.request, method, url, args)
        if result then
            response.json, response.xml = nil, nil
            return true, response
        else
            return false, response
        end
    end)(method, url, args)

    -- проверка выполнения потока
    local runner = request_thread
    while true do
        local status, err = runner:status()
        if not err then
            if status == 'completed' then
                local result, response = runner:get()
                if result then
                    return true, response.text, response.status_code, response.headers, response.status
                else
                    return false
                end
            elseif status == 'canceled' then
                return false
            end
        else
            return false
        end
        Tasking.wait(0)
    end
end
 
Последнее редактирование:

ARMOR

kjor32 is legend
Модератор
4,827
6,011
Описание: Изменяет цвета диалогам (вызвать функцию можно один раз, цвета сохранятся)
Thanks @Stickey
Lua:
function setDialogColor(l_up, r_up, l_low, r_bottom)
    local CDialog = memory.getuint32(getModuleHandle("samp.dll") + 0x21A0B8)
    local CDXUTDialog = memory.getuint32(CDialog + 0x1C)
    memory.setuint32(CDXUTDialog + 0x12A, l_up, true) -- Left corner
    memory.setuint32(CDXUTDialog + 0x12E, r_up, true) -- Right upper corner
    memory.setuint32(CDXUTDialog + 0x132, l_low, true) -- Lower left corner
    memory.setuint32(CDXUTDialog + 0x136, r_bottom, true) -- Right bottom corner
end
Пример использования:
Lua:
setDialogColor(0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFF00) -- AARRGGBB format
Посмотреть вложение 78597
Описание: Та же функция, только для разных версий SAMP

Lua:
function setDialogColor(l_up, r_up, l_low, r_bottom)
    local CDialog = memory.getuint32(getModuleHandle("samp.dll") + 0x21A0B8) -- Да, это тот же самый адрес что и для R1, просто нужно использовать этот плагин: https://www.blast.hk/threads/18815/
    local CDXUTDialog = memory.getuint32(CDialog + 0x1C)
    memory.setuint32(CDXUTDialog + 0x12A, l_up, true) -- Left corner
    memory.setuint32(CDXUTDialog + 0x12E, r_up, true) -- Right upper corner
    memory.setuint32(CDXUTDialog + 0x132, l_low, true) -- Lower left corner
    memory.setuint32(CDXUTDialog + 0x136, r_bottom, true) -- Right bottom corner
end

Lua:
function setDialogColor(l_up, r_up, l_low, r_bottom)
    local CDialog = memory.getuint32(getModuleHandle("samp.dll") + 0x26E898)
    local CDXUTDialog = memory.getuint32(CDialog + 0x1C)
    memory.setuint32(CDXUTDialog + 0x12A, l_up, true) -- Left corner
    memory.setuint32(CDXUTDialog + 0x12E, r_up, true) -- Right upper corner
    memory.setuint32(CDXUTDialog + 0x132, l_low, true) -- Lower left corner
    memory.setuint32(CDXUTDialog + 0x136, r_bottom, true) -- Right bottom corner
end

Lua:
function setDialogColor(l_up, r_up, l_low, r_bottom)
    local CDialog = memory.getuint32(getModuleHandle("samp.dll") + 0x26E9C8) -- Не ебу как вы будете это использовать без SAMPFUNCS, разве что напрямую менять значения в samp.dll
    local CDXUTDialog = memory.getuint32(CDialog + 0x1C)
    memory.setuint32(CDXUTDialog + 0x12A, l_up, true) -- Left corner
    memory.setuint32(CDXUTDialog + 0x12E, r_up, true) -- Right upper corner
    memory.setuint32(CDXUTDialog + 0x132, l_low, true) -- Lower left corner
    memory.setuint32(CDXUTDialog + 0x136, r_bottom, true) -- Right bottom corner
end

Lua:
function setDialogColor(l_up, r_up, l_low, r_bottom)
    local CDialog = memory.getuint32(getModuleHandle("samp.dll") + 0x2AC9E0)
    local CDXUTDialog = memory.getuint32(CDialog + 0x1C)
    memory.setuint32(CDXUTDialog + 0x12A, l_up, true) -- Left corner
    memory.setuint32(CDXUTDialog + 0x12E, r_up, true) -- Right upper corner
    memory.setuint32(CDXUTDialog + 0x132, l_low, true) -- Lower left corner
    memory.setuint32(CDXUTDialog + 0x136, r_bottom, true) -- Right bottom corner
end
 

Gorskin

I shit on you
Проверенный
1,237
1,002
Описание: Отключает следы от шин при торможении. Возможно кому-то пригодится для зимних сборок. Возможно прибавит 0.1% к фпс.
Lua:
writeMemory(0x720B22, 1, -1, true)

--[[

-1 - nop
100 - std

]]
 
  • Нравится
  • Влюблен
Реакции: Andrinall, Cosmo и ARMOR

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,747
11,157
Функции для работы со скроллом в InputTextMultiline (mimgui) (источник)
Описание: получает данные по скроллу imgui.InputTextMultiline (текущий скролл и максимальный), возвращает данные в imgui.ImVec2() (x, y)
Код:
Lua:
imgui.GetMultilineInputScroll = function(input_str_id)
    if imgui.BeginChildID(imgui.GetIDStr(input_str_id), imgui.ImVec2(100, 100), true) then
        Current, Max = imgui.ImVec2(imgui.GetScrollX(), imgui.GetScrollY()), imgui.ImVec2(imgui.GetScrollMaxX(), imgui.GetScrollMaxY())
        imgui.EndChild()
    end
    return Current or imgui.ImVec2(0, 0), Max or imgui.ImVec2(-1, -1)
end
Пример использования:
Lua:
imgui.InputTextMultiline('##my_input', buffer, 1024)
local current, max = imgui.GetMultilineInputScroll('##my_input')
imgui.Text('SCROLL:\nCurrent: '..tostring(current.x)..', '..tostring(current.y)..'\nMAX: '..tostring(max.x)..', '..tostring(max.y))
1658578367620.png


Описание: устанавливает скролл imgui.InputTextMultiline
Код:
Lua:
imgui.SetMultilineInputScroll = function(input_str_id, scrollX, scrollY)
    if imgui.BeginChildID(imgui.GetIDStr(input_str_id), imgui.ImVec2(100, 100), true) then
        if scrollX then imgui.SetScrollX(scrollX) end
        if scrollY then imgui.SetScrollY(scrollY) end
        imgui.EndChild()
    end
end
функция принимает 3 параметра:
1. название инпута
2. скролл по оси X (если не нужно менять, то используйте nil)
3. скролл по оси Y (если не нужно менять, то используйте nil)
Пример использования:
Lua:
imgui.InputTextMultiline('##my_input', buffer, 1024)
imgui.SetMultilineInputScroll('##my_input', nil, 0)
 

Gorskin

I shit on you
Проверенный
1,237
1,002
Описание: Теперь лопасти вертолёта не будут поднимать пыль и песок (FPS UP)
Lua:
writeMemory(0x6B06B8, 4, 0x90, true)

-- 0x90 - nop
-- 0x84C86D9 - std

Описание: Отключает дым и огонь при выстрелах из оружия.
Lua:
writeMemory(0x4A0F50, 4, 0x90, true) -- удаляет огонь с оружия при выстрелах std val 0x947BE8
writeMemory(0x4A0F7F, 4, 0x90, true) -- удаляет дым от выстрелов std val 0x944CE8
 
Последнее редактирование:

VRush

https://t.me/vrushscript
Проверенный
2,349
1,093
Описание: Прикольный способ переключатся между менюшками
2022-07-29-21-47-59_KZ28vacP.gif

Код:
Lua:
         for k, v in ipairs(functionbuttons) do
            imgui.SetCursorPosX(imgui.GetWindowSize().x / 2 - (70+25+70+25+70) / 2)
            if k == 0 then k = 1 end
            if k == funcn then
               imgui.SetCursorPosY(10)
               imgui.Button(k <= 1 and functionbuttons[#functionbuttons] or functionbuttons[k - 1], imgui.ImVec2(70, 20))
               imgui.SameLine()
               imgui.SetCursorPosY(10)
               if imgui.Button('<', imgui.ImVec2(25, 20)) then
                  funcn = funcn - 1
                  if funcn < 1 then funcn = #functionbuttons end
               end
               imgui.SameLine()
               imgui.SetCursorPosY(5)
               imgui.Button(v, imgui.ImVec2(70, 25))
               imgui.SameLine()
               imgui.SetCursorPosY(10)
               if imgui.Button('>', imgui.ImVec2(25, 20)) then
                  funcn = funcn + 1
                  if funcn > #functionbuttons then funcn = 1 end
               end
               imgui.SameLine()
               imgui.SetCursorPosY(10)
               imgui.Button(k >= #functionbuttons and functionbuttons[1] or functionbuttons[k + 1], imgui.ImVec2(70, 20))
            end
         end
Пример использования:
Lua:
local functionbuttons = {
   u8'Один',
   u8'Два',
   u8'Три',
}
funcn = 1
         for k, v in ipairs(functionbuttons) do
            imgui.SetCursorPosX(imgui.GetWindowSize().x / 2 - (70+25+70+25+70) / 2)
            if k == 0 then k = 1 end
            if k == funcn then
               imgui.SetCursorPosY(10)
               imgui.Button(k <= 1 and functionbuttons[#functionbuttons] or functionbuttons[k - 1], imgui.ImVec2(70, 20))
               imgui.SameLine()
               imgui.SetCursorPosY(10)
               if imgui.Button('<', imgui.ImVec2(25, 20)) then
                  funcn = funcn - 1
                  if funcn < 1 then funcn = #functionbuttons end
               end
               imgui.SameLine()
               imgui.SetCursorPosY(5)
               imgui.Button(v, imgui.ImVec2(70, 25))
               imgui.SameLine()
               imgui.SetCursorPosY(10)
               if imgui.Button('>', imgui.ImVec2(25, 20)) then
                  funcn = funcn + 1
                  if funcn > #functionbuttons then funcn = 1 end
               end
               imgui.SameLine()
               imgui.SetCursorPosY(10)
               imgui.Button(k >= #functionbuttons and functionbuttons[1] or functionbuttons[k + 1], imgui.ImVec2(70, 20))
            end
         end
 

ARMOR

kjor32 is legend
Модератор
4,827
6,011
Описание: Меняет цвета фона этого "меню":
2022-08-02 17-58-10-796.png


Примечание: Цвета подгружаются только один раз во время инициализации САМПа. Т.е Нужно менять их перед загрузкой игры.

Код:
Lua:
local memory = require("memory")

function set_class_selection_colors(lt, rt, lb, rb)
    local samp_module_base = sampGetBase()
    local class_selection_ptr = memory.getuint32(samp_module_base + 0x21A18C, true)
   
    memory.setuint32(class_selection_ptr + 0x12A, rb, true)
    memory.setuint32(class_selection_ptr + 0x12E, lb, true)
    memory.setuint32(class_selection_ptr + 0x132, rt, true)
    memory.setuint32(class_selection_ptr + 0x136, lt, true)
end

Lua:
local memory = require("memory")

function set_class_selection_colors(lt, rt, lb, rb)
    local samp_module_base = sampGetBase()
    local class_selection_ptr = memory.getuint32(samp_module_base + 0x21A194, true)
   
    memory.setuint32(class_selection_ptr + 0x12A, rb, true)
    memory.setuint32(class_selection_ptr + 0x12E, lb, true)
    memory.setuint32(class_selection_ptr + 0x132, rt, true)
    memory.setuint32(class_selection_ptr + 0x136, lt, true)
end

Lua:
local memory = require("memory")

function set_class_selection_colors(lt, rt, lb, rb)
    local samp_module_base = sampGetBase()
    local class_selection_ptr = memory.getuint32(samp_module_base + 0x26E974, true)
   
    memory.setuint32(class_selection_ptr + 0x12A, rb, true)
    memory.setuint32(class_selection_ptr + 0x12E, lb, true)
    memory.setuint32(class_selection_ptr + 0x132, rt, true)
    memory.setuint32(class_selection_ptr + 0x136, lt, true)
end

Lua:
local memory = require("memory")

function set_class_selection_colors(lt, rt, lb, rb)
    local samp_module_base = sampGetBase()
    local class_selection_ptr = memory.getuint32(samp_module_base + 0x26EAA4, true)
   
    memory.setuint32(class_selection_ptr + 0x12A, rb, true)
    memory.setuint32(class_selection_ptr + 0x12E, lb, true)
    memory.setuint32(class_selection_ptr + 0x132, rt, true)
    memory.setuint32(class_selection_ptr + 0x136, lt, true)
end

Lua:
local memory = require("memory")

function set_class_selection_colors(lt, rt, lb, rb)
    local samp_module_base = sampGetBase()
    local class_selection_ptr = memory.getuint32(samp_module_base + 0x2ACABC, true)
   
    memory.setuint32(class_selection_ptr + 0x12A, rb, true)
    memory.setuint32(class_selection_ptr + 0x12E, lb, true)
    memory.setuint32(class_selection_ptr + 0x132, rt, true)
    memory.setuint32(class_selection_ptr + 0x136, lt, true)
end

Спасибо @Musaigen за поправку кода.
 
Последнее редактирование:

Musaigen

abobusnik
Проверенный
1,581
1,300
Описание: Меняет цвета фона этого "меню": Посмотреть вложение 160749

Примечание: Цвета подгружаются только один раз во время инициализации САМПа. Т.е Нужно менять их перед загрузкой игры.

Код:
Lua:
local memory = require 'memory'

local samp = getModuleHandle("samp.dll")

memory.setuint32(samp + 0xB423F, argb, true) -- Left corner
memory.setuint32(samp + 0xB4255, argb, true) -- Right upper corner
memory.setuint32(samp + 0xB425A, argb, true) -- Lower left corner
memory.setuint32(samp + 0xB4279, argb, true) -- Right bottom corner

Lua:
local memory = require 'memory'

local samp = getModuleHandle("samp.dll")
  
memory.setuint32(samp + 0xB42B4, argb, true) -- Left corner
memory.setuint32(samp + 0xB42D3, argb, true) -- Right upper corner
memory.setuint32(samp + 0xB42D7, argb, true) -- Lower left corner
memory.setuint32(samp + 0xB42EE, argb, true) -- Right bottom corner

Lua:
local memory = require 'memory'

local samp = getModuleHandle("samp.dll")

memory.setuint32(samp + 0xC5FF4, argb, true) -- Left corner
memory.setuint32(samp + 0xC6012, argb, true) -- Right upper corner
memory.setuint32(samp + 0xC6017, argb, true) -- Lower left corner
memory.setuint32(samp + 0xC6020, argb, true) -- Right bottom corner

Lua:
local memory = require 'memory'

local samp = getModuleHandle("samp.dll")

memory.setuint32(samp + 0xC57A4, argb, true) -- Left corner
memory.setuint32(samp + 0xC57C2, argb, true) -- Right upper corner
memory.setuint32(samp + 0xC57C7, argb, true) -- Lower left corner
memory.setuint32(samp + 0xC57DE, argb, true) -- Right bottom corner

Lua:
local memory = require 'memory'

local samp = getModuleHandle("samp.dll")

memory.setuint32(samp + 0xC6E24, argb, true) -- Left corner
memory.setuint32(samp + 0xC6E42, argb, true) -- Right upper corner
memory.setuint32(samp + 0xC6E47, argb, true) -- Lower left corner
memory.setuint32(samp + 0xC6E5E, argb, true) -- Right bottom corner
Вроде в таком порядке:
local memory = require("memory")

function set_class_selection_colors(lt, rt, lb, rb)
    -- Get allocation base address of samp.dll module.
    local samp_module_base = sampGetBase()
    -- Read `pClassSelection` pointer.
    local class_selection_ptr = memory.getuint32(samp_module_base + 0x21A18C, true)
    
    -- Set colors.
    memory.setuint32(class_selection_ptr + 0x12A, rb, true)
    memory.setuint32(class_selection_ptr + 0x12E, lb, true)
    memory.setuint32(class_selection_ptr + 0x132, rt, true)
    memory.setuint32(class_selection_ptr + 0x136, lt, true)
end
 
  • Нравится
  • Вау
Реакции: Rice., paulohardy и ARMOR

Gorskin

I shit on you
Проверенный
1,237
1,002
Описание: Отключает дым из труб на заводах и прочие эффекты по типу факелов, горящих черепов.
Lua:
 memory.fill(0x4A125D, 0x90, 8, true) -- 8B 4E 08 E8 47 91 00 00  FxSystem_c::Play(void)
--вернуть обратно memory.hex2bin('8B4E08E88B900000', 0x4A125D, 8) --FxSystem_c::Play(void)
sa-mp-104.png
sa-mp-105.png
P.S Для обновления результата необходимо обновить зону прорисовки.
 
Последнее редактирование:

Gorskin

I shit on you
Проверенный
1,237
1,002
Описание: Отключает кровь на земле.
Lua:
memory.fill(0x49EB23, 0x90, 2, true) -- blood particle
--вернуть обратно memory.hex2bin('EB05', 0x49EB23, 2) -- blood particle
Описание: Отключает очки ночного видения и тепловизор.
Lua:
memory.fill(0x634F67, 0x90, 5, true) -- googles
--вернуть обратно memory.hex2bin('E874EBFAFF', 0x634F67, 5) -- googles
 

Hideme Flow

Известный
555
193
Описание: Регистрация команд, без отображения в chatcmds
Lua:
function comm(sendCmd, cmd, func)
    if sendCmd:match('(.+)/'..cmd) == nil and sendCmd:find('/'..cmd) then
        local argu = sendCmd:match('/'..cmd..'(.+)')
        if argu ~= nil and argu ~= " " then
            local a1, a2 = argu:match('(.)(.+)')
            if a1 ~= " " then
                return true
            end
        end
        func(argu ~= nil and select(2, argu:match('(.)(.+)')) or nil)
        return false
    else
        return true
    end
end
Пример использования:
Lua:
local sp = require('lib.samp.events')
function sp.onSendCommand(cmd)
    if not comm(cmd, 'act', function(arg)
        if arg ~= nil then
            sampAddChatMessage('Команда: act, с аргументами '..arg,-1)
        else
            sampAddChatMessage('Команда: arg',-1)
        end
    end) then return false end
end
 

imring

Ride the Lightning
Всефорумный модератор
2,353
2,512
Описание: Регистрация команд, без отображения в chatcmds
Lua:
function comm(sendCmd, cmd, func)
    if sendCmd:match('(.+)/'..cmd) == nil and sendCmd:find('/'..cmd) then
        local argu = sendCmd:match('/'..cmd..'(.+)')
        if argu ~= nil and argu ~= " " then
            local a1, a2 = argu:match('(.)(.+)')
            if a1 ~= " " then
                return true
            end
        end
        func(argu ~= nil and select(2, argu:match('(.)(.+)')) or nil)
        return false
    else
        return true
    end
end
Пример использования:
Lua:
local sp = require('lib.samp.events')
function sp.onSendCommand(cmd)
    if not comm(cmd, 'act', function(arg)
        if arg ~= nil then
            sampAddChatMessage('Команда: act, с аргументами '..arg,-1)
        else
            sampAddChatMessage('Команда: arg',-1)
        end
    end) then return false end
end
 
  • Нравится
  • Вау
Реакции: CaJlaT, Lolendor и ARMOR

Gorskin

I shit on you
Проверенный
1,237
1,002
Описание: Погружает в депрессию. А именно отключает инизиализацию таймцикла. Теперь можно собрать сборку Shadow Fight GTA.
Lua:
function onSystemInitialized()
    local memory = require("memory")
    memory.fill(0x5BFAE2, 0x90, 5, true) --CTimeCycle::Initialise(void)
end
sa-mp-111.png
P.S Память меняется в момент загрузки игры.
 

Gorskin

I shit on you
Проверенный
1,237
1,002
Описание: Отключает создание огня.
Lua:
writeMemory(0x539F00, 4, 0x0024C2, true)-- отключить огонь, вкл 0x6C8B5551
Описание: Отключает создание взрывов.
Lua:
writeMemory(0x736A50, 1, 0xC3, true) -- патч взрывов, вернуть 0x83
Описание: Отключает рендер всех эффектов в гта.
Lua:
memory.fill(0x53EAD3, 0x90, 5, true) -- nop all effects render E8 98 F6 FF FF

Описание: Создал функцию для редактирования дальности прорисовки объектов.
Покажу на примере столбов. Ид объекта 1290.
Lua:
function getMDO(id_obj)
    local mem_obj = callFunction(4210080, 1, 1, id_obj)
    return mem_obj + 24
end

memory.setfloat(getMDO(1290), 2.0, true) -- где 2.0 это дальность видимости.
sa-mp-118.png
sa-mp-119.png
Так же прикреплю сайт с айдишниками объектов: тык
P.S Чтобы узнать стандартное значение видимости объекта используйте:
print(memory.getfloat(getMDO(ид объекта), true))
 
Последнее редактирование: