Пользователь
- Статус
- Оффлайн
- Регистрация
- 6 Янв 2018
- Сообщения
- 252
- Реакции
- 124
Ruby:
local enabled = Menu.Switch('General', 'Enable', false)
local colored = Menu.Switch('General', 'Auto color', false)
local custom_color = Menu.Switch('Customization', 'Custom static color', false)
local custom_color_c = Menu.ColorEdit('Customization', 'Color', Color.new(0, 0, 1, 1))
--1
local hearts = {}
local get_color = function (element, alpha)
local clr = element:Get()
return { clr:r() * 255, clr:g() * 255, clr:b() * 255, alpha }
end
local tocolor = function (r, g, b, a)
return Color.new(r / 255, g / 255, b / 255, (a or 255) / 255)
end
local rectangle = function (x, y, w, h, color)
Render.BoxFilled(Vector2.new(x, y), Vector2.new(x + w, y + h), tocolor(color[1], color[2], color[3], color[4]))
end
local draw_heart = function (x, y, color)
rectangle(x + 2, y + 14, 2, 2, { 0, 0, 0, color[4] })
rectangle(x, y + 12, 2, 2, { 0, 0, 0, color[4] })
rectangle(x - 2, y + 10, 2, 2, { 0, 0, 0, color[4] })
rectangle(x - 4, y + 4, 2, 6, { 0, 0, 0, color[4] })
rectangle(x - 2, y + 2, 2, 2, { 0, 0, 0, color[4] })
rectangle(x, y, 2, 2, { 0, 0, 0, color[4] })
rectangle(x + 2, y, 2, 2, { 0, 0, 0, color[4] })
rectangle(x + 4, y + 2, 2, 2, { 0, 0, 0, color[4] })
rectangle(x + 6, y, 2, 2, { 0, 0, 0, color[4] })
rectangle(x + 8, y, 2, 2, { 0, 0, 0, color[4] })
rectangle(x + 10, y + 2, 2, 2, { 0, 0, 0, color[4] })
rectangle(x + 12, y + 4, 2, 6, { 0, 0, 0, color[4] })
rectangle(x + 10, y + 10, 2, 2, { 0, 0, 0, color[4] })
rectangle(x + 8, y + 12, 2, 2, { 0, 0, 0, color[4] })
rectangle(x + 6, y + 14, 2, 2, { 0, 0, 0, color[4] })
rectangle(x + 4, y + 16, 2, 2, { 0, 0, 0, color[4] })
rectangle(x - 2, y + 4, 2, 6, { color[1], color[2], color[3], color[4] })
rectangle(x, y + 2, 4, 2, { color[1], color[2], color[3], color[4] })
rectangle(x, y + 6, 4, 6, { color[1], color[2], color[3], color[4] })
rectangle(x + 2, y + 4, 2, 2, { color[1], color[2], color[3], color[4] })
rectangle(x + 2, y + 12, 2, 2, { color[1], color[2], color[3], color[4] })
rectangle(x + 4, y + 4, 2, 12, { color[1], color[2], color[3], color[4] })
rectangle(x + 6, y + 2, 4, 10, { color[1], color[2], color[3], color[4] })
rectangle(x + 6, y + 12, 2, 2, { color[1], color[2], color[3], color[4] })
rectangle(x + 10, y + 4, 2, 6, { color[1], color[2], color[3], color[4] })
rectangle(x, y + 4, 2, 2, { 254, 199, 199, color[4] })
end
local function on_draw()
if not enabled:Get() then return end
local realtime = GlobalVars.realtime
local is_colored = colored:Get()
for i = 1, #hearts do
if hearts[i] == nil then return end
local heart = hearts[i]
local vec = Render.WorldToScreen(Vector.new(heart.position.x, heart.position.y, heart.position.z))
local x = vec.x
local y = vec.y
local alpha = math.floor(255 - 255 * (realtime - heart.start_time))
if realtime - heart.start_time >= 1 then
alpha = 0
end
if x ~= nil and y ~= nil then
if is_colored then
if heart.damage <= 15 then
draw_heart(x - 5, y - 5, { 60, 255, 0, alpha })
elseif heart.damage <= 30 then
draw_heart(x - 5, y - 5, { 255, 251, 0, alpha })
elseif heart.damage <= 60 then
draw_heart(x - 5, y - 5, { 255, 140, 0, alpha })
else
draw_heart(x - 5, y - 5, { 254, 19, 19, alpha })
end
else
local clr = custom_color:Get() and get_color(custom_color_c, alpha) or { 254, 19, 19, alpha }
draw_heart(x - 5, y - 5, clr)
end
end
heart.position.z = heart.position.z + (realtime - heart.frame_time) * 50
heart.frame_time = realtime
if realtime - heart.start_time >= 1 then
table.remove(hearts, i)
end
end
end
local function on_events(event)
if event:GetName() == 'player_hurt' then
if not enabled:Get() then return end
local ent_target = EntityList.GetPlayerForUserID(event:GetInt('userid', 0))
local ent_attacker = EntityList.GetPlayerForUserID(event:GetInt('attacker', 0))
local ent_lplayer = EngineClient.GetLocalPlayer()
if ent_attacker:EntIndex() ~= ent_lplayer or event:GetInt('userid', 0) == event:GetInt('attacker', 0) then
return
end
local vec3 = ent_target:GetProp('m_vecOrigin')
local time = GlobalVars.realtime
table.insert(hearts, {
position = { x = vec3.x, y = vec3.y, z = vec3.z + 50 },
damage = event:GetInt('dmg_health', 0),
start_time = time,
frame_time = time
})
end
end
Cheat.RegisterCallback('events', on_events)
Cheat.RegisterCallback('draw', on_draw)