Модератор раздела "Создание скриптов для читов"
-
Автор темы
- #1
code_language.lua:
local resolver_data = {}
local function resolver(cmd)
if not checkbox:get() then
return
end
local localplayer = entity.get_local_player()
if not localplayer then
return
end
for _, player in pairs(entity.get_players(true)) do
if not player:is_alive() or player:is_bot() or player:get_index() == localplayer:get_index() then
goto continue
end
local player_id = player:get_index()
if not resolver_data[player_id] then
resolver_data[player_id] = {
previous_eye_angles = {
valid = false,
x = 0
},
last_pitch_delta = 0,
ticks_without_change = 0
}
end
local data = resolver_data[player_id]
local anim_state = player:get_anim_state()
local current_eye_angles = {
x = anim_state.eye_pitch
}
if data.previous_eye_angles.valid then
local delta_pitch = current_eye_angles.x - data.previous_eye_angles.x
local pitch_delta_change = math.abs(delta_pitch - data.last_pitch_delta)
data.last_pitch_delta = delta_pitch
if math.abs(delta_pitch) <= 1.0 then --@note: delta_pitch = -1 -> 1
data.ticks_without_change = data.ticks_without_change + 1
else
data.ticks_without_change = 0
end
if math.abs(delta_pitch) > 15 or (pitch_delta_change > 15 and data.ticks_without_change > 2) then
local new_pitch = data.previous_eye_angles.x + delta_pitch
--@note: you can use player.m_flPoseParameter[12] or animstate to force pitch setting
end
end
data.previous_eye_angles.valid = true
data.previous_eye_angles.x = current_eye_angles.x
::continue::
end
end
events.post_update_clientside_animation:set(function(cmd)
resolver(cmd)
end)
Последнее редактирование: