UI.AddCheckbox("Custom scope lines");
UI.AddColorPicker("Scope color gradient 1");
UI.AddColorPicker("Scope color gradient 2");
UI.AddSliderInt("Scope lines width", 0, 500);
UI.AddSliderInt("Scope lines offset", 0, 500);

//#endregion

//#region draw
function draw()
{
    var local = Entity.GetLocalPlayer();

    if (!Entity.IsAlive(local) || !World.GetServerString()) {
        Convar.SetFloat("r_drawvgui", 1);
        Convar.SetInt("fov_cs_debug", 0);
        return;
    }
    local = Entity.GetLocalPlayer();
    thirdperson = UI.GetValue("Visual", "WORLD", "View", "Thirdperson");
    offset = UI.GetValue("Script items", "Scope lines offset");
    leng = UI.GetValue("Script items", "Scope lines width");
    accent1 = UI.GetColor("Script items", "Scope color gradient 1");
    accent2 = UI.GetColor("Script items", "Scope color gradient 2");
    scoped = Entity.GetProp(local, "CCSPlayer", "m_bIsScoped");
    screen_size = Render.GetScreenSize();

    if (!UI.GetValue("Script items", "Custom scope lines")) 
        return;
    
    if (scoped) {
        Convar.SetFloat("r_drawvgui", 0);
        if (!UI.IsHotkeyActive("Visual", "WORLD", "View", "Thirdperson")) {
            Cheat.ExecuteCommand("fov_cs_debug 90");
            UI.SetValue("Visual", "WORLD", "View", "FOV while scoped", 0);
        }
        UI.SetValue("Visual", "WORLD", "Entities", "Removals", 59);
        Render.GradientRect(screen_size[0] / 2 + offset, screen_size[1] / 2, leng, 1, 1, [accent1[0], accent1[1], accent1[2], accent1[3]], [accent2[0], accent2[1], accent2[2], accent2[3]]);
        Render.GradientRect(screen_size[0] / 2 - leng - offset, screen_size[1] / 2, leng, 1, 1, [accent2[0], accent2[1], accent2[2], accent2[3]], [accent1[0], accent1[1], accent1[2], accent1[3]]);
        Render.GradientRect(screen_size[0] / 2, screen_size[1] / 2 + offset, 1, leng, 0, [accent1[0], accent1[1], accent1[2], accent1[3]], [accent2[0], accent2[1], accent2[2], accent2[3]]);
        Render.GradientRect(screen_size[0] / 2, screen_size[1] / 2 - leng - offset, 1, leng, 0, [accent2[0], accent2[1], accent2[2], accent2[3]], [accent1[0], accent1[1], accent1[2], accent1[3]]);
    } else {
        Convar.SetFloat("r_drawvgui", 1);
        Convar.SetInt("fov_cs_debug", 0);
        UI.SetValue("Visual", "WORLD", "Entities", "Removals", 63);
    }
}

function unload() {
	Cheat.ExecuteCommand("fov_cs_debug 0");
}
Cheat.RegisterCallback("Unload", "unload")
Cheat.RegisterCallback("Draw", "draw");