UI.AddMultiDropdown("Indicators", ["Keybinds", "Spectators", "Watermark", "FL Indicator","FPS Indicator","MS Indicator", "Fake Indicator"]);
UI.AddDropdown("Style Indicators", ["GameSense", "Standart"]);

UI.AddColorPicker("FPS Color");
UI.AddColorPicker("MS & HZ Color");
UI.AddColorPicker("FL Color");
const get = function(elm)
{
return UI.GetValue("Misc", "JAVASCRIPT", "Script items", elm);
}
const set = function(elm1, v)
{
return UI.SetValue("Misc", "JAVASCRIPT", "Script items", elm1, v);
}

const in_bounds = function(vec, x, y, x2, y2) {
return (vec[0] > x) && (vec[1] > y) && (vec[0] < x2) && (vec[1] < y2)
}

var stored = ![],
x_offs = 0,
y_offs = 0;

const move1 = function (x, y, width, height, name) {
if (UI.IsMenuOpen() && Input.IsKeyPressed(0x1)) {
  const mouse_pos = Global.GetCursorPosition();
  if (in_bounds(mouse_pos, x, y, x + width, y + height)) {
     if(!stored){
        x_offs = mouse_pos[0] - x;
        y_offs = mouse_pos[1] - y;
        stored = true;
     }
     UI.SetValue("Script items", name + "_x", mouse_pos[0] - x_offs);
     UI.SetValue("Script items", name + "_y", mouse_pos[1] - y_offs);
  }
} else if(stored) stored = false;
}

function skeetobvodka(x, y, w, h, color){
const style = UI.GetValue("Script items", "Style Indicators")
if (style !== 0){
Render.FilledRect(x, y + 2, w, h, [15, 15, 15, 150]);
}else{
Render.FilledRect(x, y - 1, w, h + 2, [15, 15, 15, color[3]]);
Render.Rect(x, y - 1, w, h + 3, [15, 15, 15, 200]);}

if (style == 0) {
Render.GradientRect(x + 1, y, w / 2 - 1, 1, 2, [55, 177, 218, 255], [203, 70, 205, 255]);
Render.GradientRect(x + w / 2, y, w / 2 - 1 + 1, 1, 2, [203, 70, 205, 255], [204, 227, 53, 255]);
}else if (style == 1){
Render.FilledRect(x, y + 1, w, 1, [color[0], color[1], color[2], 255]);
}
}

function HSVtoRGB(h, s, v) {
var r, g, b, i, f, p, q, t;
if (arguments.length === 1) {
    s = h.s, v = h.v, h = h.h;
}
i = Math.floor(h * 6);
f = h * 6 - i;
p = v * (1 - s);
q = v * (1 - f * s);
t = v * (1 - (1 - f) * s);
switch (i % 6) {
    case 0: r = v, g = t, b = p; break;
    case 1: r = q, g = v, b = p; break;
    case 2: r = p, g = v, b = t; break;
    case 3: r = p, g = q, b = v; break;
    case 4: r = t, g = p, b = v; break;
    case 5: r = v, g = p, b = q; break;
}
return {
    r: Math.round(r * 255),
    g: Math.round(g * 255),
    b: Math.round(b * 255)
};
}
var aspect_cache = 0;

function aspect(){
var aspect_slider = UI.GetValue("Aspect Ratio");
if (aspect_cache != aspect_slider) {
    aspect_cache = aspect_slider;
    UI.SetValue("Misc", "GENERAL", "Miscellaneous", "Hidden cvars", 1);
    Global.ExecuteCommand("r_aspectratio " + aspect_slider);
}
}


var fps_info = [];
var last_timee = Global.Curtime();

function draw_containe()
{
if (!(UI.GetValue("Indicators") & (1<<4))) return;

var text = "IO | "
var w = Render.TextSize(text, 8)[0] + 20;
var x = Global.GetScreenSize()[0];   
var y = Entity.IsAlive(Entity.GetLocalPlayer()) ? 75 : 50;
x = x - w - 99;
var avg = {'fps': 0};


Render.FilledRect(x - 20, y - 16, 55, 21, [15, 15, 15, fpsc[3]]);
Render.String(x - 17, y - 11, 0, "IO | ", [ 255, 255, 255, 255 ], 8 );

if (Global.Curtime() - last_timee > 0.5) {

    last_timee = Global.Curtime();


    fps_info.unshift(1 / Global.Frametime());
}
fpsc = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "FPS Color");
if (fps_info.length > 4)
    fps_info.pop();


var fps_max = Convar.GetInt("fps_max") || 400;
for (i = 0; i < fps_info.length; i++)
{
    avg.fps += fps_info[i]
    Render.GradientRect( x - i * 5 + 25, y + 1 - fps_info[i] / fps_max * 35, 5, fps_info[i] / fps_max * 35, 0, [35, 35, 95, 0], [fpsc[0], fpsc[1], fpsc[2], 255]
    );
}
}
function mainn()
{
draw_containe();
}

function Areset()
{
llast_time = Global.Curtime();
fps_info = [];
}

function main_mshz() {
if (!(UI.GetValue("Indicators") & (1<<5))) return;
const ping = Math.abs(Local.Latency() * 1000 - 16).toFixed(2);
var font = Render.AddFont("Verdana", 7, 100);
var text = +ping+ "ms / 60hz";
var w = Render.TextSizeCustom(text, font)[0] + 8;
var x = Global.GetScreenSize()[0];   
var y = Entity.IsAlive(Entity.GetLocalPlayer()) ? 55 : 30;
x = x - w - 10;
msc = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "MS & HZ Color");
Render.FilledRect(x, y + 4, w, 20, [17, 17, 17, msc[3]]);
Render.StringCustom(x + 4, y + 7, 0, text, [0, 0, 0, 180], font);
Render.StringCustom(x + 4, y + 7, 0, text, [255, 255, 255, 255], font);
var width = 75;
var stylee = UI.GetValue("Script items", "Style Indicators")
if (stylee == 0) {
    Render.GradientRect( x, y + 23, w / 2, 1, 2, [55, 177, 218/*55, 177, 218*/, 255], [203, 70, 205/*203, 70, 205*/, 255]);
    Render.GradientRect( x + w / 2, y + 23, w / 2, 1, 2, [203, 70, 205/*203, 70, 205*/, 255], [204, 227, 53/*204, 227, 53*/, 255]);				
} else if (stylee == 1) {
    Render.GradientRect( x, y + 23, w / 2, 1, 1, [ msc[0], msc[1], msc[2], 0 ], [ msc[0], msc[1], msc[2], 255 ]);
    Render.GradientRect( x + w / 2, y + 23, w / 2, 1, 1, [ msc[0], msc[1], msc[2], 255 ], [ msc[0], msc[1], msc[2], 0 ]);
    }
if (ping > 64 && stylee == 1) {
    Render.GradientRect( x, y + 23, w / 2, 1, 1, [ 255, 0, 0, 0 ], [ 255, 0, 0, 255 ]);
    Render.GradientRect( x + w / 2, y + 23, w / 2, 1, 1, [ 255, 0, 0, 255 ], [ 255, 0, 0, 0 ]);				
} else if (ping < 64 && stylee == 1 ) {
    Render.GradientRect( x, y + 23, w / 2, 1, 1, [ 0, 255, 0, 0 ], [ 0, 255, 0, 255 ]);
    Render.GradientRect( x + w / 2, y + 23, w / 2, 1, 1, [ 0, 255, 0, 255 ], [ 0, 255, 0, 0 ]);
    }
if (stylee == 0){
    Render.Rect(x, y + 4, w, 21, [17, 17, 17, 200]);
}
}
/// Fake


function main_fake() {
if (!(UI.GetValue("Indicators") & (1<<6))) return;
if (!World.GetServerString()) return;
if (!Entity.IsAlive(Entity.GetLocalPlayer())) return;
var font = Render.AddFont("Verdana", 7, 100);
const dt = UI.IsHotkeyActive("Rage", "GENERAL", "Exploits", "Doubletap");
var RealYaw = Local.GetRealYaw();
var FakeYaw = Local.GetFakeYaw();
var delta = Math.min(Math.abs(RealYaw - FakeYaw) / 2, 60).toFixed(1);
var text = "    FAKE (" + delta.toString() + "  ) ";
var w = Render.TextSizeCustom(text, font)[0] + 8;
var h = 22;
var x = Global.GetScreenSize()[0];   
var y = 30;
x = x - w - 110;
Render.GradientRect( x, y + 4, 45, 21, 1, [ 0, 0, 0, 0 ], [ 0, 0, 0, 100 ]);
Render.GradientRect( x + 45, y + 4, 45, 21, 1, [ 0, 0, 0, 100 ], [ 0, 0, 0, 0 ]);
Render.GradientRect(x + 5, y + 4, 2, h / 2, 0, [(255 - 255 * (delta / 100)), 255 * (delta / 100), 0, 100], [(255 - 255 * (delta / 100)), 255 * (delta / 100), 0, 255]);
Render.GradientRect(x + 5, y + h / 2 + 4, 2, h / 2, 0, [(255 - 255 * (delta / 100)), 255 * (delta / 100), 0, 255], [(255 - 255 * (delta / 100)), 255 * (delta / 100), 0, 100]);
Render.StringCustom(x, y + 9, 0, text, [0, 0, 0, 180], font);
Render.StringCustom(x - 1, y + 8, 0, text, [255, 255, 255, 255], font);
Render.Circle(x + 12 + Render.TextSizeCustom("FAKE (" + delta.toString(), font)[0], y + 9, 1, [255, 255, 255, 255]);
}



/// Fakelag
var charge_alpha = 0;
function fl_indicator(){
if (!Entity.IsAlive(Entity.GetLocalPlayer())) return;
if (!(UI.GetValue("Indicators") & (1<<3))) return;
const color = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "FL Color");    
const dt = UI.IsHotkeyActive("Rage", "GENERAL", "Exploits", "Doubletap");
const hs = UI.IsHotkeyActive("Rage", "GENERAL", "Exploits", "Hide shots");
const flag = UI.GetValue( "Anti-Aim", "Fake-Lag", "Limit");   
const font = Render.AddFont("Verdana", 7, 100);
const charge = Exploit.GetCharge();
const fl = (dt || hs) ? 0 : flag
var text = "FL:  "+fl;
if (dt) text += " | SHIFTING";
var w = Render.TextSizeCustom(text, font)[0] + 8; 
var x = Global.GetScreenSize()[0];   
var y = 30;
x = x - w - 10
Render.FilledRect(x, y + 4, w, 20, [17, 17, 17, color[3]]);
Render.StringCustom(x + 4, y + 7, 0, text, [0, 0, 0, 180], font);
Render.StringCustom(x + 4, y + 7, 0, text, [255, 255, 255, 255], font);

if (charge >= 1) {
    charge_alpha = Math.min(charge_alpha + (8 * Globals.Frametime()), 1);
} else {
    charge_alpha = charge_alpha - (8 * Globals.Frametime());
    if (charge_alpha < 0) charge_alpha = 0;
}

var stylee = UI.GetValue("Script items", "Style Indicators")

if (stylee == 0) {
    Render.GradientRect(x, y + 23, w / 2, 1, 2, [55, 177, 218, 255], [203, 70, 205, 255]);
    Render.GradientRect(x + w / 2, y + 23, w / 2, 1, 2, [203, 70, 205, 255], [204, 227, 53, 255]);           
} else if (stylee == 1) {
    if (dt){
    Render.GradientRect( x, y + 23, w / 2, 1, 1, [255, 145, 0, 0], [ 255, 145, 0, 255]);
    Render.GradientRect( x + w / 2, y + 23, w / 2, 1, 1, [255, 145, 0, 255], [ 255, 145, 0, 0]);

    Render.GradientRect( x, y + 23, w / 2, 1, 1, [0, 255, 0, 0], [0, 255, 0, charge_alpha * 255]);
    Render.GradientRect( x + w / 2, y + 23, w / 2, 1, 1, [0, 255, 0, charge_alpha * 255], [0, 255, 0, 0]);
    }else{
    Render.GradientRect( x, y + 23, w / 2, 1, 1, [color[0], color[1], color[2], 0], [color[0], color[1], color[2], 255]);
    Render.GradientRect( x + w / 2, y + 23, w / 2, 1, 1, [color[0], color[1], color[2], 255], [color[0], color[1], color[2], 0]);         
    }    
}
if (stylee == 0){
    Render.Rect(x, y + 4, w, 21, [17, 17, 17, 200]);
}
}
var msc = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "MS & HZ Color");
var flcol = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "FL Color");
var fpsc = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "FPS Color");
Cheat.RegisterCallback("Draw", "fl_indicator")
Cheat.RegisterCallback("Draw", "main_fake");
Cheat.RegisterCallback("Draw", "main_mshz");
Cheat.RegisterCallback("Draw", "mainn");