script_author('chapo and edit by YarikVL')
local ffi = require('ffi')
local hook = require("hooks")
local Count = { Full = 0, Respond = 0 }
local Address = { r1 = 0x64010, r3 = 0x679F0 }
function get_samp_version()
if samp_base == nil or samp_base == 0 then
samp_base = getModuleHandle("samp.dll")
end
if samp_base ~= 0 then
local e_lfanew = ffi.cast("long*", samp_base + 60)[0]
local nt_header = samp_base + e_lfanew
local entry_point_addr = ffi.cast("unsigned int*", nt_header + 40)[0]
if entry_point_addr == 0x31DF13 then
return "r1"
elseif entry_point_addr == 0xCC4D0 then
return "r3"
end
end
return "unknown"
end
function main()
local samp = get_samp_version()
if Address[samp] then
sampChatHook = hook.jmp.new("void(__thiscall *)(uintptr_t this, uint32_t type, const char* text, const char* prefix, uint32_t color, uint32_t pcolor)", sampChatHook, getModuleHandle('samp.dll') + Address[samp])
else
sampAddChatMessage('[ConnectionRepeatCounter]: Error, use SA:MP R1 or R3', -1)
error('dolbaeb, unsupported SAMP version')
end
wait(-1)
end
function sampChatHook(this, type, text, prefix, color, pcolor)
local text = ffi.string(text)
if text:find('^ScreenshotTaken') then
Count.Full = Count.Full + 1
return sampChatHook(this, type, ffi.cast('char*', "ScreenshotTaken %- sa%-mp"..tostring(Count.Full).."%.png"), prefix, color, pcolor)
end
sampChatHook(this, type, text, prefix, color, pcolor)
end