LUA Help get all server commands

malonex

Member
Joined
Nov 22, 2023
Messages
10
Solutions
1
Reaction score
0
I wanted to know if it is possible to get all commands from the server using lua
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
"COMMAND" should be your server commands
Code:
require 'lib.moonloader'


function get_commands()
    local version = getSampVersion()
    samp10 = getModuleHandle('samp.dll')
   
    if version == 1 -- r1
    then
        SAMP_CHAT_INPUT_INFO_OFFSET = samp10 + 0x21A0E8
        SAMP_CHAT_INPUT_INFO_POINTER = readMemory(SAMP_CHAT_INPUT_INFO_OFFSET, 4, true)
        SAMP_COMMANDS_COUNT_OFFSET = SAMP_CHAT_INPUT_INFO_POINTER + 0x14DC
        SAMP_COMMANDS_COUNT = readMemory(SAMP_COMMANDS_COUNT_OFFSET, 4, true)
        for i = 0, SAMP_COMMANDS_COUNT do
       
            if i == 0
            then
                SAMP_FIRST_COMMANDS_OFFSET = SAMP_CHAT_INPUT_INFO_POINTER + 0x24C
                COMMAND = readString(SAMP_FIRST_COMMANDS_OFFSET, 33, false)
            end
            if i > 0
            then
                SAMP_FIRST_COMMANDS_OFFSET = SAMP_CHAT_INPUT_INFO_POINTER + 0x24C
                SIZE_OF_EACH_COMMAND = 0x21 * i
                SAMP_EACH_COMMANDS_OFFSET = SIZE_OF_EACH_COMMAND + SAMP_FIRST_COMMANDS_OFFSET
                COMMAND = readString(SAMP_EACH_COMMANDS_OFFSET, 33, false)
            end
       
        end
    end
   
    if version == 7 -- r5
    then
        SAMP_CHAT_INPUT_INFO_OFFSET = samp10 + 0x26EB84
        SAMP_CHAT_INPUT_INFO_POINTER = readMemory(SAMP_CHAT_INPUT_INFO_OFFSET, 4, true)
        SAMP_COMMANDS_COUNT_OFFSET = SAMP_CHAT_INPUT_INFO_POINTER + 0x14DC
        SAMP_COMMANDS_COUNT = readMemory(SAMP_COMMANDS_COUNT_OFFSET, 4, true)
        for i = 0, SAMP_COMMANDS_COUNT do
       
            if i == 0
            then
                SAMP_FIRST_COMMANDS_OFFSET = SAMP_CHAT_INPUT_INFO_POINTER + 0x24C
                COMMAND = readString(SAMP_FIRST_COMMANDS_OFFSET, 33, false)
            end
            if i > 0
            then
                SAMP_FIRST_COMMANDS_OFFSET = SAMP_CHAT_INPUT_INFO_POINTER + 0x24C
                SIZE_OF_EACH_COMMAND = 0x21 * i
                SAMP_EACH_COMMANDS_OFFSET = SIZE_OF_EACH_COMMAND + SAMP_FIRST_COMMANDS_OFFSET
                COMMAND = readString(SAMP_EACH_COMMANDS_OFFSET, 33, false)
            end
       
        end
    end

end

local version = getSampVersion()

function get_samp_version_id()
    local versionid = 0
    samp10 = getModuleHandle('samp.dll')
    samp10 = samp10 + 0x128
    samp9 = readMemory(samp10, 4, true)
    if samp9 == 0x5542F47A then
        versionid = 1 -- r1
    end
    if samp9 == 0x59C30C94 then
        versionid = 2 -- r2
    end
    if samp9 == 0x5542F47A then
        versionid = 3 -- 0.3DL
    end

    samp10 = samp10 - 8
    samp9 = readMemory(samp10, 4, true)
    if samp9 == 0x5C0B4243 then
        versionid = 4 -- r3
    end
    if samp9 == 0x5DD606CD then
        versionid = 5 -- R4
    end
    if samp9 == 0x6094ACAB then
        versionid = 6 -- R4-2
   end
        if samp9 == 0x6372C39E then
            versionid = 7 --R5
        end
   return versionid
    end
   
function readString(address, size)
    local result = ''
    for i = address, address + size - 1 do
        local char = string.char(readMemory(i, 1))
        if char == '\0' then
            break
        end
        result = result .. char
    end
    return result
end
 
Top