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