const keybinds_x = UI.AddSliderInt("keybinds_x", 0, Global.GetScreenSize()[0])
const keybinds_y = UI.AddSliderInt("keybinds_y", 0, Global.GetScreenSize()[1])

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

 function xy()
 {
     UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "keybinds_x", false)
     UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "keybinds_y", false)
 }
 xy();

function keybinds()
 {

     
     var watermark_name = Entity.GetName(Entity.GetLocalPlayer( ));
     var today = new Date();
     var hours1 = today.getHours();
     var minutes1 = today.getMinutes();
     var seconds1 = today.getSeconds();
     var localplayer_index = Entity.GetLocalPlayer();
     var velocity = Entity.GetProp(localplayer_index, "CBasePlayer", "m_vecVelocity[0]");
     var speed = Math.sqrt(velocity[0] * velocity[0] + velocity[1] * velocity[1]);
     var finalspeed = Math.min( 9999, speed ) + 0.2
     var hours = hours1 <= 9 ? "0" + today.getHours() + ":" : today.getHours() + ":";
     var minutes = minutes1 <= 9 ? "0" + today.getMinutes() + ":" : today.getMinutes() + ":";
     var seconds = seconds1 <= 9 ? "0" + today.getSeconds() : today.getSeconds()    ;
     const tickrate = Globals.Tickrate();
     const ping = Math.floor(Global.Latency() * 1000 / 1.5);
     const fps = Math.floor( 1 / Global.Frametime() );
     var h = [];
     const fontpixel = Render.AddFont( "Segoe UI", 10, 100);
     const fontpixel1 = Render.AddFont( "Segoe UI", 8, 100);
     
     if (UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction")) {                 
       h.push("Freestand")
     }
     if (UI.IsHotkeyActive("Misc", "JAVASCRIPT", "Script items", "Dormant Aimbot")) {
       h.push("Dormant Aimbot")
     }
     if (UI.IsHotkeyActive("Rage", "General", "Resolver override")) {
       h.push("Resolver override")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Extra", "Slow walk")) {
       h.push("Slow walk")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Extra", "Fake duck")) {
       h.push("Fake duck")
     }
     if (UI.IsHotkeyActive("Misc", "General", "Movement", "Auto peek")) {
       h.push("Auto peek")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter")) {
       h.push("AA Inverter")
     }
     if (UI.IsHotkeyActive("Rage", "General", "General", "Force safe point")) {
       h.push("Force safe point")
     }
     if (UI.IsHotkeyActive("Misc", "JAVASCRIPT", "Script items", "Minimum damage override")) {
       h.push("Damage override")
     }
     if (UI.IsHotkeyActive("Rage", "General", "General", "Force body aim")) {
       h.push("Force body aim")
     }
     if (UI.IsHotkeyActive("Rage", "Exploits", "Double tap")) {
       h.push("Doubletap")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Desync on shot")) {
       h.push("On shot anti-aim")
     }
     if (UI.IsHotkeyActive("Rage", "Exploits", "Hide shots")) {
       h.push("Hide shots")
     }
     if (UI.IsHotkeyActive("Legit", "GENERAL", "Triggerbot", "Enabled")) {
       h.push("Triggerbot")
     }

     const x = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "keybinds_x"),
           y = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "keybinds_y");

     const rainbow = [
         Math.floor(Math.sin(Global.Realtime() * 2) * 127 + 128),
         Math.floor(Math.sin(Global.Realtime() * 2 + 2) * 127 + 128),
         Math.floor(Math.sin(Global.Realtime() * 2 + 2) * 127 + 128),
         255
     ];

     
     
     Render.GradientRect(x, y, 200, 24, 500, [ 0, 0, 0, 100 ], [ 0, 0, 0, 0 ]);
     for (i = 0; i < h.length; i++)
     {
        Render.StringCustom(x + 30, y + 26 + 22 * i, 0, h[i], [255, 255, 255, 255], fontpixel1);
        Render.FilledCircle(x + 10, y + 33 + 22 * i, 6, [255, 255, 255, 255]);
        Render.FilledCircle(x + 18, y + 33 + 22 * i, 6, [255, 255, 255, 255]);
        Render.FilledRect(x + 12, y + 28 + 22 * i, 4,11, [255, 255, 255, 255]);
        Render.FilledCircle(x + 18, y + 33 + 22 * i, 5, [0, 0, 0, 255]);
     }

     if (Global.IsKeyPressed(1)) {
         const mouse_pos = Global.GetCursorPosition();
         if (in_bounds(mouse_pos, x, y, x + 200, y + 30)) {
          if (UI.IsMenuOpen( ) == false)
            return;
             UI.SetValue("Misc", "JAVASCRIPT", "Script items", "keybinds_x", mouse_pos[0] - 100);
             UI.SetValue("Misc", "JAVASCRIPT", "Script items", "keybinds_y", mouse_pos[1] - 20);
         }
     }

 }

Global.RegisterCallback("Draw", "keybinds");

