-- https://github.com/DK22Pac/plugin-sdk
-- https://github.com/gta-reversed/gta-reversed-modern
local ffi = require('ffi')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF
-- 0xB7CD98 - CPed
local wep_ch = {
getWeaponRadius = ffi.cast("float (__thiscall*)(int cped)", 0x609CD0)
}
-- D8 3D 8C8B8500
-- D8 3D A06C8500
-- определяем переменную множителя прицела в памяти
ffi.cast("float*", 0x856CA0)[0] = 0.5
-- патчим функцию getWeaponRadiusOnScreen
-- чтобы она работала с новым значением
ffi.cast("unsigned long*", 0x609CFD)[0] = 0x856ca0
-- ^ зачем? чтобы игру не распидорасило, если будешь менять оригинальное значение по адресу 0x856CA0
-- const float rangeProg = std::min(1.0f, 15.0f / wepInfo.m_fWeaponRange);
ffi.cast("float*", 0x856CA8)[0] = 15.0
ffi.cast("unsigned long*", 0x609D22)[0] = 0x856ca8
-- const float rangeProg = std::min(1.0f, 15.0f / wepInfo.m_fWeaponRange);
ffi.cast("float*", 0x856CAC)[0] = 1.0
ffi.cast("unsigned long*", 0x609D28)[0] = 0x856CAC
--x
-- ffi.cast("float*", 0x856CB0)[0] = 1.0
-- ffi.cast("unsigned long*", 0x609D39)[0] = 0x856CB0
-- тоже мульт радиус штоле
-- ffi.cast("float*", 0x856CB0)[0] = 0.5 --0.5
-- ffi.cast("unsigned long*", 0x609D45)[0] = 0x856CB0
-- множитель размера прицела
ffi.cast("float*", 0x856CB4)[0] = 0.25 --0.5
ffi.cast("unsigned long*", 0x609D59)[0] = 0x856CB4
ffi.cast("float*", 0x8D24E4)[0] = 0.05
-- if ( result < 0.2 ) return 0.2;
ffi.cast("float*", 0x856CB8)[0] = 0.2 --0.20
ffi.cast("unsigned long*", 0x609D77)[0] = 0x856CB8
-- хуй знает похоже на базовое значение прицела
-- ffi.cast("float*", 0x856CBC)[0] = 0.2 --0.20
-- ffi.cast("unsigned long*", 0x609D86)[0] = 0x856CBC
ffi.cast("float*", 0x856CB8)[0] = 0.2 --0.20
ffi.cast("unsigned long*", 0x609D77)[0] = 0x856CB8
ffi.cast("float*", 0x856CBC)[0] = 64.0 --0.20
ffi.cast("unsigned long*", 0x58E307)[0] = 0x856CBC
-- CPed + mPlayerData + m_fAttackButtonCounter
-- 0xB7CD98 + 0x480 + 0x2c
function wep_ch:radius_get()
return wep_ch.getWeaponRadius(ffi.cast("int32_t*", 0xb7cd98)[0])
end
function wep_ch:radius_max_get()
return ffi.cast("float*", 0x8D24E4)[0]
end
function wep_ch:radius_max_set(max_radius)
ffi.cast("float*", 0x8D24E4)[0] = tonumber(max_radius)
end
function wep_ch:radius_mult_get()
return ffi.cast("float*", 0x856CA0)[0]
end
function wep_ch:radius_mult_set(mult)
ffi.cast("float*", 0x856CA0)[0] = tonumber(mult)
end
local cped = ffi.cast("int32_t*", 0xB7CD98)
local mPlayerData = ffi.cast("int32_t*", cped[0] + 0x480)
function main()
repeat wait(0) until isSampAvailable()
sampRegisterChatCommand("ch_rad_max", function (max_radius)
if #max_radius ~= 0 then
wep_ch:radius_max_set(max_radius)
else
sampAddChatMessage("current max radius: " .. wep_ch:radius_max_get(), -1)
end
end)
sampRegisterChatCommand("ch_rad_mult", function (mult)
if #mult ~= 0 then
wep_ch:radius_mult_set(mult)
else
sampAddChatMessage("current radius multiplier: " .. wep_ch:radius_mult_get(), -1)
end
end)
sampAddChatMessage("123", -1)
-- ffi.cast("float*", mPlayerData[0] + 0x2C)[0] = 120.0
while true do wait(0)
local m_fAttackButtonCounter = ffi.cast("float*", mPlayerData[0] + 0x2C)
end
end