-
Notifications
You must be signed in to change notification settings - Fork 2
/
lc_indicator.lua
143 lines (106 loc) · 4.53 KB
/
lc_indicator.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
--[[
_
(_)
__ _ __ _ _ __ ___ ___ ___ ___ _ __ ___ ___ __ __ _ _ __
/ _` | / _` || '_ ` _ \ / _ \/ __| / _ \| '_ \ / __| / _ \ \ \ / /| || '_ \
| (_| || (_| || | | | | || __/\__ \| __/| | | |\__ \| __/ _ \ V / | || |_) |
\__, | \__,_||_| |_| |_| \___||___/ \___||_| |_||___/ \___|(_) \_/ |_|| .__/
__/ | | |
|___/ |_|
⋆ https://github.com/strawberrylua
⋆ https://www.youtube.com/c/StrawberryHvH
⋆ https://gamesense.vip/forums/profile.php?id=15
© StrawberryHvH 2022
--]]
local vector = require "vector"
local entity = require "vip/entity"
local images = require "vip/images"
local enable = ui.new_checkbox("Visuals", "Player ESP", "LC flag")
local color = ui.new_color_picker("Visuals", "Player ESP", "LC flag", 158, 74, 0)
local style = ui.new_multiselect("Visuals", "Player ESP", "\n", "Text", "Icon")
local raw_file_content = readfile("danger.svg") or error("Could not find the file 'danger.svg' in your CS:GO directory.")
local danger_image = images.load_svg(raw_file_content)
local ESP_TEXT = "BREAKING LC"
local esp_flag_set = false
local data = {}
local function time_to_ticks(t)
return math.floor(0.5 + (t / globals.tickinterval()))
end
local function contains(table, val)
for i=1,#table do
if table[i] == val then
return true
end
end
return false
end
local function on_net_update_end (c)
for _, player in ipairs(entity.get_players(true)) do
local sim_time = time_to_ticks(player:get_prop("m_flSimulationTime"))
local ent_index = player:get_entindex()
local origin = vector(player:get_origin())
local player_data = data[ent_index]
if player_data == nil then
data[ent_index] = {
last_sim_time = sim_time,
defensive_active_until = 0,
origin = origin
}
else
local delta = sim_time - player_data.last_sim_time
if delta < 0 then
player_data.defensive_active_until = globals.tickcount() + math.abs(delta)
elseif delta > 0 then
player_data.breaking_lc = (player_data.origin - origin):length2dsqr() > 4096
player_data.origin = origin
end
player_data.last_sim_time = sim_time
end
end
end
local function on_paint ()
local tickcount = globals.tickcount()
local draw_color = {ui.get(color)}
local styles = ui.get(style)
for _, player in ipairs(entity.get_players(true)) do
local player_data = data[player:get_entindex()]
if player_data and (player_data.breaking_lc or tickcount <= player_data.defensive_active_until) then
local x1, y1, x2, y2, alpha = player:get_bounding_box()
if alpha ~= 0 then
local draw_x, draw_y = x1 + ((x2 - x1) / 2), y1
if contains(styles, "Text") then
renderer.text(draw_x, draw_y - 20, draw_color[1], draw_color[2], draw_color[3], draw_color[4] * alpha, "dc", 0, ESP_TEXT)
end
if contains(styles, "Icon") then
local text_width, _ = renderer.measure_text("dc", player:get_player_name())
local size = 16
danger_image:draw(draw_x + text_width / 2 + 2, draw_y - size, size, size)
end
end
end
end
end
local function reset_data ()
data = {}
end
local function handle_esp_flag (idx)
if not ui.get(enable) or data[idx] == nil then return false end
local idx_data = data[idx]
return globals.tickcount() <= idx_data.defensive_active_until or idx_data.breaking_lc
end
ui.set_callback(enable, function(e)
local enabled = ui.get(e)
local callback = enabled and client.set_event_callback or client.unset_event_callback
callback("net_update_end", on_net_update_end)
callback("round_prestart", reset_data)
if not esp_flag_set then
client.register_esp_flag("LC", 158, 74, 0, handle_esp_flag)
esp_flag_set = true
end
ui.set_visible(style, enabled)
end)
ui.set_callback(style, function(e)
local styles = ui.get(e)
local callback = #styles == 0 and client.unset_event_callback or client.set_event_callback
callback("paint", on_paint)
end)