-
Автор темы
- #1
я вроде не рукожоп вроде могу делать дефолт вещи но я не могу нормально получить кординаты бокса чтобы он был ровно как противник
Код:
local group_ref = ui.create("Group")
local enable = group_ref:button("LC flag")
local break_lc_positions = {}
local data = {}
local function time_to_ticks(t)
return math.floor(0.5 + (t / globals.tickinterval))
end
local function on_net_update_end()
for _, player in ipairs(entity.get_players(true)) do
local sim_time = time_to_ticks(player.m_flSimulationTime)
local ent_index = player:get_index()
local origin = player:get_origin()
local velocity = player.m_vecVelocity:length2d()
local player_data = data[ent_index]
if player_data == nil then
data[ent_index] = {
last_sim_time = sim_time,
last_origin = origin,
breaking_lc = false,
}
else
local delta_ticks = sim_time - player_data.last_sim_time
local delta_position = (origin - player_data.last_origin):length2dsqr()
local is_teleport = delta_position > (64 * 64)
local is_velocity_break = velocity > 400 and delta_position > (velocity * globals.tickinterval)^2
player_data.breaking_lc = is_teleport or is_velocity_break
if player_data.breaking_lc then
break_lc_positions[ent_index] = {
position = origin,
time = globals.tickcount
}
end
player_data.last_sim_time = sim_time
player_data.last_origin = origin
end
end
end
local function on_paint()
local tickcount = globals.tickcount
for ent_index, data in pairs(break_lc_positions) do
local position = data.position
local break_time = data.time
if tickcount - break_time > time_to_ticks(2) then
break_lc_positions[ent_index] = nil
else
local screen_pos = render.world_to_screen(position)
if screen_pos then
local size = 40
render.rect_outline(
vector(screen_pos.x - size / 2, screen_pos.y - size / 2, 0),
vector(screen_pos.x + size / 2, screen_pos.y + size / 2, 0),
color(255, 255, 255),
1
)
end
end
end
end
local function reset_data()
break_lc_positions = {}
data = {}
end
enable:set_callback(function(e)
local enabled = e:get()
if enabled then
events.net_update_end:set(on_net_update_end)
events.round_prestart:set(reset_data)
else
events.net_update_end:unset(on_net_update_end)
events.round_prestart:unset(reset_data)
end
end)
events.render:set(on_paint)