LUA [NL] Indicators example

  • 287
  • 42
Пример +/- нормальных анимированных индикаторов, по моему мнению)

1657828253012.png


Indicators:
--[[
    @region: script information
    * @ Indicators.
    * @ Created by shelzy#6665.
    * @ Version: 1.0.0
    @endregion
]]

local indicators = {}
local add = {x = 0, y = 0}




--- @region: font
local font = {}

font.verdana11 = {}
font.verdana11.size = 11
font.verdana11.init = Render.InitFont("Verdana", font.verdana11.size, {"r"})
--- @endregion




--- @region: ui reference
local ui_reference = {
    body_aim = Menu.FindVar("Aimbot","Ragebot","Misc","Body Aim"), --ui_reference.body_aim:Get() == 2
    safe_points = Menu.FindVar("Aimbot","Ragebot","Misc","Safe Points"), --ui_reference.safe_points:Get() == 2
    double_tap = Menu.FindVar("Aimbot","Ragebot","Exploits","Double Tap"),
    slow_walk = Menu.FindVar("Aimbot","Anti Aim","Misc","Slow Walk"),
    fake_duck = Menu.FindVar("Aimbot","Anti Aim","Misc","Fake Duck"),
    hide_shots = Menu.FindVar("Aimbot","Ragebot","Exploits","Hide Shots"),
}
--- @endregion




--- @region: menu elements
local ui = {
    enable = Menu.Switch("Main", "Indicators Under Crosshair", false),
    additional = Menu.MultiCombo("Main", "Indicators Additional", {"Lua name", "Anti-Aim line", "Anti-Aim state", "Keybinds"}, 1),
    color = Menu.ColorEdit("Main", "Indicators Color", Color.new(0.4, 0.4, 1, 1))
}
--- @endregion




--- @region: render helpers
Render.Indicators = function(data, x, y)
    local total_width = 0
    local width = 0

    for _, v in pairs(data) do
        local text_width = Render.CalcTextSize(v[1], font.verdana11.size, font.verdana11.init).x
        total_width = total_width + text_width
    end

    for _, v in ipairs(data) do
        local text_width = Render.CalcTextSize(v[1], font.verdana11.size, font.verdana11.init).x
        local x2 = (x - total_width / 2 + width)


        Render.Text(v[1], Vector2.new(x2, y), v[2], font.verdana11.size, font.verdana11.init, true)
        width = width + text_width
    end
end

Color.UpdateAlpha = function(color, alpha)
    return Color.new(color.r, color.g, color.b, alpha)
end
--- @endregion




--- @region: animation helpers
local anim = {}
local animation_handler = {data = {}}
animation_handler.lerp = function(start, end_pos, time)
    time = GlobalVars.frametime * (time * 175)
    if time < 0 then
        time = 0.01
    elseif time > 1 then
        time = 1
    end

    if type(start) == "userdata" then
        local color_data = {0, 0, 0, 0}

        for v, k in ipairs({"r", "g", "b", "a"}) do
            color_data[v] = animation_handler.lerp(start[k], end_pos[k], time)
        end

        return Color.new(unpack(color_data))
    end

    if (math.abs(start-end_pos) < (delta or 0.01)) then return end_pos end

    return ((end_pos - start)*time +start)
end

animation_handler.new = function(name, value, time)
    if animation_handler.data[name] == nil then
        animation_handler.data[name] = value
    end

    animation_handler.data[name] = animation_handler.lerp(animation_handler.data[name], value, time)

    return animation_handler.data[name]
end
--- @endregion




--- @region: anti-aim helpers
local jumping = false

AntiAim.GetState = function()
    local local_player = EntityList.GetLocalPlayer()
    if not local_player then
        return "nil"
    end

    if (bit.band(local_player:GetProp("m_fFlags"), 1) == 0 or jumping) and local_player:GetProp("m_flDuckAmount") > 0.8 then
        return "air+crouch"
    end

    if (bit.band(local_player:GetProp("m_fFlags"), 1) == 0 or jumping) then
        return "air"
    end

    if (local_player:GetProp("m_flDuckAmount") > 0.8 or ui_reference.fake_duck:Get()) then
        return "crouch"
    end

    if (local_player:GetProp("m_vecVelocity"):Length2D() > 3 and ui_reference.slow_walk:Get()) then
        return "slow walk"
    end

    if (local_player:GetProp("m_vecVelocity"):Length2D() > 3) then
        return "moving"
    end

    if (local_player:GetProp("m_vecVelocity"):Length2D() <= 3) then
        return "standing"
    end
end

Cheat.RegisterCallback("pre_prediction", function(cmd)
    jumping = bit.band(cmd.buttons, bit.lshift(1,1)) ~= 0
end)
--- @endregion




--- @region: draw
indicators.on_draw = function()
    local r, g, b = ui.color:Get().r, ui.color:Get().g, ui.color:Get().b
    local sc = EngineClient.GetScreenSize()
    local x, y = sc.x/2, sc.y/2
    add.y = 20

    anim.enable = animation_handler.new("anim.enable", ui.enable:Get() and 1 or 0, 0.095)
    if anim.enable < 0.01 then return end

    anim.left_text = animation_handler.new("anim.left_text", AntiAim.GetInverterState() and Color.new(r, g, b, 1) or Color.new(1, 1, 1, 1), 0.05)
    anim.right_text = animation_handler.new("anim.right_text", AntiAim.GetInverterState() and Color.new(1, 1, 1, 1) or Color.new(r, g, b, 1), 0.05)

    anim.lua_name = animation_handler.new("anim.lua_name", ui.enable:Get() and ui.additional:Get(1) and 1 or 0, 0.095)
    if anim.lua_name > 0 then
        Render.Indicators(
            {
                {"broken", Color.UpdateAlpha(anim.left_text, anim.lua_name)},
                {"core", Color.UpdateAlpha(anim.right_text, anim.lua_name)}
            },
            x, y + add.y
        )
    end
    add.y = add.y + anim.lua_name*12

    anim.antiaim_state = animation_handler.new("anim.antiaim_state", ui.enable:Get() and ui.additional:Get(3) and 1 or 0, 0.095)
    if anim.antiaim_state > 0 then
        Render.Indicators(
            {
                {AntiAim.GetState(), Color.new(1, 1, 1, anim.antiaim_state)},
            },
            x, y + add.y
        )
    end
    add.y = add.y + anim.antiaim_state*12



    local binds = {
        {("double-tap"), ui_reference.double_tap:Get(), Exploits.GetCharge() == 1 and Color.new(r, g, b, 1) or Color.new(1, 0, 0, 1)},
        {("hide-shots"), ui_reference.hide_shots:Get()},
        {("safe"), ui_reference.safe_points:Get() == 2},
        {("body"), ui_reference.body_aim:Get() == 2},
        {("duck"), ui_reference.fake_duck:Get()},
    }

    anim.binds = {}
    for k, v in ipairs(binds) do
        if anim.binds[v[1]] == nil then
            anim.binds[v[1]] = 0
        end

        anim.binds[v[1]] = animation_handler.new("anim."..v[1], ui.enable:Get() and ui.additional:Get(4) and v[2] and 1 or 0, 0.095)


        if v[3] == nil then
            v[3] = Color.new(r, g, b, anim.binds[v[1]])
        else
            v[3] = Color.UpdateAlpha(v[3], anim.binds[v[1]])
        end

        
        local name = (v[1]):sub(0, (v[1]):len()*anim.binds[v[1]])

        Render.Indicators(
            {
                {name, v[3]},
            },
            x, y + add.y
        )

        add.y = add.y + anim.binds[v[1]]*12
    end
end
--- @endregion




--- @region: callbacks
Cheat.RegisterCallback("draw", indicators.on_draw)
--- @endregion
 
  • LauX
  • Заблокирован
  • 676
  • 12
  • 233
Контакты для связи отсутствуют.
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код написан хорошо. Я бы не сказал, что он идеально оптимизирован, но кого это вообще волнует:pepeexhausted:
 
Сверху Снизу