evasivedocs
CS2 scriptingLua 5.4.9 · 25 guides · 292 API entries
Examples

Skeleton

Bone lines for every enemy, with a dot on the head. It pairs well with the Custom box ESP.

Needs: Allow game scripting.

Lua
-- @name Skeleton
-- @description Bone lines and a head dot for every enemy.

local col = ui.color("Colour", color(255, 255, 255, 200))
local thick = ui.slider("Thickness", 1, 3, 1)
local head_dot = ui.checkbox("Head dot", true)
local teammates = ui.checkbox("Teammates", false)

events.on("paint", function()
    if not game or not game.connected() then return end
    local c, t = col:get(), thick:get()
    for _, p in ipairs(entities.players(teammates:get() and "alive" or "enemies")) do
        if p.alive and not p.is_local then
            for i = 1, #skeleton_pairs, 2 do
                local ax, ay = p:bone_screen(skeleton_pairs[i])
                local bx, by = p:bone_screen(skeleton_pairs[i + 1])
                if ax and bx then draw.line(ax, ay, bx, by, c, t) end
            end
            if head_dot:get() then
                local hx, hy = p:bone_screen(bone.head)
                if hx then draw.circle_filled(hx, hy, 3, c) end
            end
        end
    end
end)

How it works

  • skeleton_pairs is a flat list of bone ids, two per line: parent, then child. The loop steps through it two at a time.
  • p:bone_screen(id) gives a bone's screen position, or nil when it is off screen. A line is drawn only when both ends are on screen.
  • ui.color is the first control here, so it gets a row of its own instead of sitting next to another control.

Try this

  • Fade the colour with distance: color.alpha(c, math.floor(math.clamp(255 - p.distance / 10, 60, 255))).
  • Draw the skeleton in the world instead. p:bone(id) gives x, y and z, so build a point with vec3(x, y, z) and pass two of them to draw.world_line.