local hooks = require("hooks")
local ffi = require("ffi")
local samp = getModuleHandle("samp.dll")
local str = ffi.string
local originalCChat__AddEntry
local messages = {}
local addEntryOffsets = {
R1 = 0x64010,
R3 = 0x67460
}
function getSampVersion()
local version = "unknown"
local versions = {
["3268371"] = "R1",
["3249629"] = "R2",
["836816"] = "R3",
["834736"] = "R4",
["1039200"] = "R5",
}
local handle = getModuleHandle("samp.dll")
if handle then
local ntHeader = (handle + cast("long*", (handle + 60))[0])
local pEntryPoint = tostring(cast("unsigned int*", (ntHeader + 40))[0])
if versions[pEntryPoint] then
version = versions[pEntryPoint]
end
end
return version
end
function CChat__AddEntry(this, nType, szText, szPrefix, textColor, prefixColor)
text = str(szText)
print("Message: ", text)
return originalCChat__AddEntry(this, nType, szText, szPrefix, textColor, prefixColor)
end
originalCChat__AddEntry = hooks.jmp.new(
"void(__thiscall*)(void*, int, const char*, const char*, unsigned long, unsigned long)",
CChat__AddEntry, (samp + addEntryOffsets[getSampVersion()])
)