Dania_gg
Customer
- Регистрация
- 17 Авг 2024
- Сообщения
- 80
- Тема Автор
- #1
local ffi = require("ffi")
ffi.cdef[[
typedef struct {
int nPlayerTickCount;
float flPlayerTickFraction;
} InputHistoryEntry;
typedef struct {
void* pArena;
int nCurrentSize;
int nTotalSize;
void* pRep;
} RepeatedPtrField;
typedef struct {
RepeatedPtrField inputHistoryField;
int nAttack1StartHistoryIndex;
} CSGOUserCmd;
typedef struct {
CSGOUserCmd csgoUserCmd;
uint64_t nButtons;
} CUserCmd;
]]
local bDoubleTap = true
local shot_count = 0
local function double_tap()
if not bDoubleTap then return end
local pCmd = ffi.cast("CUserCmd*", get_user_cmd())
if not pCmd then return end
local pLocal = entitylist.get_local_player()
if not pLocal then return end
local pWeapon = pLocal:get_active_weapon()
if not pWeapon then return end
local next_attack = pWeapon:get_next_primary_attack()
local tick_count = globalvars.get_tick_count()
local tick_interval = globalvars.get_interval_per_tick()
local shoot_tick = math.floor(next_attack / tick_interval)
local f = shot_count % 2 == 1
if pCmd.csgoUserCmd.nAttack1StartHistoryIndex > -1 then
shot_count = shot_count + 1
end
if pCmd.csgoUserCmd.inputHistoryField.pRep then
for i = 0, 1 do
local entry = ffi.cast("InputHistoryEntry*",
ffi.cast("char*", pCmd.csgoUserCmd.inputHistoryField.pRep) + i * ffi.sizeof("InputHistoryEntry"))
if entry then
entry.nPlayerTickCount = f and (shoot_tick - 1) or 0
entry.flPlayerTickFraction = 0.0
end
end
end
pCmd.csgoUserCmd.nAttack1StartHistoryIndex = -1
pWeapon:set_next_primary_attack(tick_count * tick_interval)
end
local function simple_double_tap(cmd)
if not cmd then return end
local local_player = entitylist.get_local_player()
if not local_player or not local_player:is_alive() then return end
local weapon = local_player:get_active_weapon()
if not weapon then return end
if bit.band(cmd.buttons, 1) ~= 0 then
weapon:set_next_primary_attack(0)
end
end
local function run_double_tap()
if pcall(ffi.cast, "CUserCmd*", get_user_cmd()) then
pcall(double_tap)
else
local cmd = get_user_cmd()
simple_double_tap(cmd)
end
end
register_callback("create_move", run_double_tap)
print("1")
Is it possible to make this lua work?
ffi.cdef[[
typedef struct {
int nPlayerTickCount;
float flPlayerTickFraction;
} InputHistoryEntry;
typedef struct {
void* pArena;
int nCurrentSize;
int nTotalSize;
void* pRep;
} RepeatedPtrField;
typedef struct {
RepeatedPtrField inputHistoryField;
int nAttack1StartHistoryIndex;
} CSGOUserCmd;
typedef struct {
CSGOUserCmd csgoUserCmd;
uint64_t nButtons;
} CUserCmd;
]]
local bDoubleTap = true
local shot_count = 0
local function double_tap()
if not bDoubleTap then return end
local pCmd = ffi.cast("CUserCmd*", get_user_cmd())
if not pCmd then return end
local pLocal = entitylist.get_local_player()
if not pLocal then return end
local pWeapon = pLocal:get_active_weapon()
if not pWeapon then return end
local next_attack = pWeapon:get_next_primary_attack()
local tick_count = globalvars.get_tick_count()
local tick_interval = globalvars.get_interval_per_tick()
local shoot_tick = math.floor(next_attack / tick_interval)
local f = shot_count % 2 == 1
if pCmd.csgoUserCmd.nAttack1StartHistoryIndex > -1 then
shot_count = shot_count + 1
end
if pCmd.csgoUserCmd.inputHistoryField.pRep then
for i = 0, 1 do
local entry = ffi.cast("InputHistoryEntry*",
ffi.cast("char*", pCmd.csgoUserCmd.inputHistoryField.pRep) + i * ffi.sizeof("InputHistoryEntry"))
if entry then
entry.nPlayerTickCount = f and (shoot_tick - 1) or 0
entry.flPlayerTickFraction = 0.0
end
end
end
pCmd.csgoUserCmd.nAttack1StartHistoryIndex = -1
pWeapon:set_next_primary_attack(tick_count * tick_interval)
end
local function simple_double_tap(cmd)
if not cmd then return end
local local_player = entitylist.get_local_player()
if not local_player or not local_player:is_alive() then return end
local weapon = local_player:get_active_weapon()
if not weapon then return end
if bit.band(cmd.buttons, 1) ~= 0 then
weapon:set_next_primary_attack(0)
end
end
local function run_double_tap()
if pcall(ffi.cast, "CUserCmd*", get_user_cmd()) then
pcall(double_tap)
else
local cmd = get_user_cmd()
simple_double_tap(cmd)
end
end
register_callback("create_move", run_double_tap)
print("1")
Is it possible to make this lua work?