Skip to main content

target_hud

Target HUD to show the draggables, rendering, player and some logic impls. Designed inspired by legit client

pro_hud.lua
lua
local health_animation = types.animation.new(250, enums.easings.ease_out_quint)
local font = types.font.new("nunito", enums.font_weight.bold)
-- unused but very good to make animations
local stopwatch = types.stopwatch.new()
local target
local previous_target
-- to use with health_animation
local old_health = 0
modules.register("Pro HUD", "Mode", {
on_render_2d = function(event)
if target == nil then
return
end
local name = target.get_name().get_string()
local pos_x = draggables.get_x("Pro HUD")
local pos_y = draggables.get_y("Pro HUD")
local texture
local pl = target.to_player();
texture = pl.get_skin_texture()
local width = font.get_width(name, 9) + 45
local height = 40
local health = target.get_health()
local max_health = target.get_max_health()
local max_health_width = font.get_width(name, 9)
local health_width = max_health_width * (health / max_health)
if old_health ~= health then
local previous_health_width = max_health_width * (old_health / max_health)
health_animation.start(previous_health_width, health_width)
end
if not health_animation.is_finished() then
health_width = health_animation.get_value()
end
local color1 = client.get_color(0)
local color2 = client.get_color(width)
draggables.set_width("Pro HUD", width)
draggables.set_height("Pro HUD", height)
render.rounded_rect(pos_x, pos_y, width, height, 5).color(0x141414).build()
render.rounded_rect(pos_x + 37.5, pos_y + 25, max_health_width, 6, 3).color(0x282828).build()
render.rounded_rect(pos_x + 37.5, pos_y + 25, health_width, 6, 3).horizontal_gradient(color1, color2).build()
render.text(name, pos_x + 37.5, pos_y + 9).font(font, 9).build()
render.texture(pos_x + 7.5, pos_y + 7.5, 25, 25, texture).radius(5).crop(8 / 64, 8 / 64, 16 / 64, 16 / 64).build()
render.render()
old_health = health
end,
on_motion = function(event)
local screen_name = client.get_screen_name()
local new_target = client.get_target()
-- if client is on screen, make it show with target the player, so we can visualize and drag it
if screen_name ~= nil and screen_name == "Chat screen" then
target = player
stopwatch.reset()
elseif target == nil or new_target ~= previous_target then
target = client.get_target()
stopwatch.reset()
end
previous_target = target
end
})
draggables.register("Pro HUD")