var screen_width = Math.round(Global.GetScreenSize()[0]);

function HSVtoRGB(h, s, v)
{
    var r, g, b, i, f, p, q, t;

    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) };
}

function onDrawEvent()
{
    var colors = HSVtoRGB(Global.Realtime() * UI.GetValue("MISC", "JAVASCRIPT", "Script Items", "Rainbow Line Speed"), 1, 1);

    Render.GradientRect(0, 0, screen_width/2, 4, 1, [colors.g, colors.b, colors.r, 255], [colors.r, colors.g, colors.b, 255]);
    Render.GradientRect(screen_width/2, 0, screen_width/2, 4, 1, [colors.r, colors.g, colors.b, 255], [colors.b, colors.r, colors.g, 255]);
}       
UI.AddSliderInt("", 0, 0);
Global.RegisterCallback("Draw", "onDrawEvent");
UI.AddSliderFloat("Rainbow Line Speed", 0.01, 1.0);
UI.SetValue("MISC", "JAVASCRIPT", "Script Items", "Rainbow Line Speed", 0.1);
UI.AddCheckbox("Display indicator")
UI.AddHotkey("Heavy Pistol Override")
UI.AddSliderInt("Heavy Pistol Mindmg", 0, 130)
UI.AddHotkey("Scout Override")
UI.AddSliderInt("Scout Mindmg", 0, 130)
UI.AddHotkey("AWP Override")
UI.AddSliderInt("AWP Mindmg", 0, 130)
UI.AddHotkey("Auto Override")
UI.AddSliderInt("Auto Mindmg", 0, 130)

var heavy_cache = UI.GetValue("Rage", "HEAVY PISTOL", "Targeting", "Minimum damage")
var scout_cache = UI.GetValue("Rage", "SCOUT", "Targeting", "Minimum damage")
var awp_cache = UI.GetValue("Rage", "AWP", "Targeting", "Minimum damage")
var auto_cache = UI.GetValue("Rage", "AUTOSNIPER", "Targeting", "Minimum damage")
function isActive(a)
{
    return UI.IsHotkeyActive("Script Items", a)
}
function setValue(cat, value)
{
    UI.SetValue("Rage", cat.toUpperCase(), "Targeting", "Minimum damage", value)
}
function isHeavyPistol(name)
{
    if (name == "r8 revolver" || name == "desert eagle")
    {
        return true
    }
}
function isAutoSniper(name)
{
    if(name == "scar 20" || weapon_name == "g3sg1")
    {
        return true
    }
}
function onCM()
{
    heavy_value = UI.GetValue("Script items", "Heavy Pistol Mindmg")
    scout_value = UI.GetValue("Script items", "Scout Mindmg")
    awp_value = UI.GetValue("Script items", "AWP Mindmg")
    auto_value = UI.GetValue("Script items", "Auto Mindmg")
    weapon_name = Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer()))
    
    if (isActive("Heavy Pistol Override") && isHeavyPistol(weapon_name))
    {
        setValue("HEAVY PISTOL", heavy_value)
    }
    else{
        setValue("HEAVY PISTOL", heavy_cache)
    }
    
    if (isActive("Scout Override") && weapon_name == "ssg 08")
    {
        setValue("SCOUT", scout_value)
    }
    else{
        setValue("SCOUT", scout_cache)
    }

    if (isActive("AWP Override") && weapon_name == "awp")
    {
        setValue("AWP", awp_value)
    }
    else{
        setValue("AWP", awp_cache)
    }

    if (isActive("Auto Override") && isAutoSniper(weapon_name))
    {
        
        setValue("AUTOSNIPER", auto_value)
    }
    else
    {
        setValue("AUTOSNIPER", auto_cache)
    }
    
}
function indicator()
{
    screen = Render.GetScreenSize()
    wep = Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer()))
    x = screen[0]/2
    y = screen[1]/2
    heavy = "DMG: " + UI.GetValue("Rage", "HEAVY PISTOL", "Targeting", "Minimum damage")
    scout = "DMG: " + UI.GetValue("Rage", "SCOUT", "Targeting", "Minimum damage")
    awp = "DMG: " + UI.GetValue("Rage", "AWP", "Targeting", "Minimum damage")
    auto = "DMG: " + UI.GetValue("Rage", "AUTOSNIPER", "Targeting", "Minimum damage")
    var str = ""
    if (UI.GetValue("Script items", "Display indicator") && Entity.IsValid(Entity.GetLocalPlayer()) && Entity.IsAlive(Entity.GetLocalPlayer()))
    {
        if (isHeavyPistol(wep))
        {
            str = heavy
        }
        else if(wep == "ssg 08")
        {
            str = scout
        }
        else if(wep == "awp")
        {
            str = awp
        }
        else if (isAutoSniper(wep))
        {
            str = auto
        }
    }
    Render.String(x, y, 0, str+"", [255,255,255,255])
}
Cheat.RegisterCallback("Draw", "indicator")
Cheat.RegisterCallback("CreateMove", "onCM")
UI.AddSliderInt("", 0, 0);
UI.AddLabel("             Low Delta          ");
UI.AddCheckbox("Low delta");
UI.AddDropdown( "Low delta type", [ "Custom", "On key" ] );
const lowdelta_modes = UI.AddMultiDropdown("Low delta modes", [ "Slow walk", "Low HP", "Standing" ]);
UI.AddHotkey("Low delta on key");

function SetEnabled()
{
    if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta"))
    {
       UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Low delta type", 1)
    }
    else
    {
       UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Low delta type", 0)
    }

    if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta type") == 0 && UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta"))
    {
       UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Low delta modes", 1)
       UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Low delta on key", 0)
    }
    else if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta type") == 1 && UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta"))
    {
       UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Low delta modes", 0)
       UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Low delta on key", 1)
    }
    else
    {
       UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Low delta modes", 0)
       UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Low delta on key", 0)
    }
}

function get_velocity(index)
{
    var velocity = Entity.GetProp(index, "CBasePlayer", "m_vecVelocity[0]");
    return Math.sqrt(velocity[0] * velocity[0] + velocity[1] * velocity[1]);
}

function get_health(index)
{
    health_override = Entity.GetProp(index, "CBasePlayer", "m_iHealth");
    return health_override;
}

function Low_delta()
{
    localplayer_index = Entity.GetLocalPlayer( );
    const lowdelta_dropdown_value = UI.GetValue.apply(null, lowdelta_modes);

    var velocity = get_velocity(localplayer_index)
    var health = get_health(localplayer_index)
    var LowHP = false
    var SlowWalk = false
    var Standing = false
    var Onkey = false

    if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta") && UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta type") == 0)
    {
       if (lowdelta_dropdown_value & (1 << 0) && UI.IsHotkeyActive("Anti-Aim", "Extra", "Slow walk"))
       SlowWalk = true
       else
       SlowWalk = false

       if (lowdelta_dropdown_value & (1 << 1) && health < 50)
       LowHP = true
       else
       LowHP = false

       if (lowdelta_dropdown_value & (1 << 2) && velocity < 3)
       Standing = true
       else
       Standing = false
    }
    else if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta") && UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta type") == 1)
    {
       if (UI.IsHotkeyActive("Misc", "JAVASCRIPT", "Script items", "Low delta on key"))
       Onkey = true
       else
       Onkey = false
    }

        if (Standing == true || LowHP == true || SlowWalk == true || Onkey == true && UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta"))
        {
            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 10);
            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset", 0);
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(0);
            AntiAim.SetRealOffset(-26);
	    AntiAim.SetLBYOffset(-60);
        }
        else
        {
            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 0);
            AntiAim.SetOverride(0);
        }
}

function drawString()
{
    localplayer_index = Entity.GetLocalPlayer( );
    localplayer_alive = Entity.IsAlive( localplayer_index );
    const fontpixel = Render.AddFont( "Verdana", 8, 100);
    const lowdelta_dropdown_value = UI.GetValue.apply(null, lowdelta_modes);
    var SFOnkey = false
    var screen_size = Global.GetScreenSize();
    var velocity = get_velocity(localplayer_index)
    var health = get_health(localplayer_index)

    SlowWalk = false
    LowHP = false
    Standing = false
    Onkey = false

    if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta") && UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta type") == 0)
    {
       if (lowdelta_dropdown_value & (1 << 0) && UI.IsHotkeyActive("Anti-Aim", "Extra", "Slow walk"))
       SlowWalk = true
       else
       SlowWalk = false

       if (lowdelta_dropdown_value & (1 << 1) && health < 50)
       LowHP = true
       else
       LowHP = false

       if (lowdelta_dropdown_value & (1 << 2) && velocity < 3)
       Standing = true
       else
       Standing = false
    }
    else if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta") && UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta type") == 1)
    {
       if (UI.IsHotkeyActive("Misc", "JAVASCRIPT", "Script items", "Low delta on key"))
       Onkey = true
       else
       Onkey = false
    }

    if (Standing == true || LowHP == true || SlowWalk == true || Onkey == true)
    {
        drawIND = true
    }
    else
    {
        drawIND = false
    }

    if (drawIND == true && localplayer_alive == true && UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Low delta") == true)
    {
       Render.StringCustom(screen_size[0] /2 , screen_size[1] /2 +25, 1, "Godmode", [ 255, 0, 0, 255 ], fontpixel );
    }
}
UI.AddSliderInt("", 0, 0);
Global.RegisterCallback("Draw", "drawString");
Global.RegisterCallback("Draw", "SetEnabled");
Cheat.RegisterCallback("CreateMove", "Low_delta");
const global_choked_commands = Globals.ChokedCommands, global_realtime = Globals.Realtime, global_frametime = Globals.Frametime, global_curtime = Globals.Curtime, global_tick_interval = Globals.TickInterval, global_tickrate = Globals.Tickrate, global_tickcount = Globals.Tickcount, global_frame_stage = Globals.FrameStage, ui_get_menu_position = UI.GetMenuPosition, ui_update_list = UI.UpdateList, ui_remove_item = UI.RemoveItem, ui_get_hotkey = UI.GetHotkey, ui_set_hotkey_state = UI.SetHotkeyState, ui_get_hotkey_state = UI.GetHotkeyState, ui_toggle_hotkey = UI.ToggleHotkey, ui_set_color = UI.SetColor, ui_add_sub_tab = UI.AddSubTab, ui_add_textbox = UI.AddTextbox, ui_add_color_picker = UI.AddColorPicker, ui_add_multi_dropdown = UI.AddMultiDropdown, ui_add_dropdown = UI.AddDropdown, ui_add_hotkey = UI.AddHotkey, ui_add_slider_float = UI.AddSliderFloat, ui_add_slider_int = UI.AddSliderInt, ui_add_checkbox = UI.AddCheckbox, ui_set_value = UI.SetValue, ui_get_children = UI.GetChildren, ui_get_value = UI.GetValue, ui_get_string = UI.GetString, ui_get_color = UI.GetColor, ui_is_menu_open = UI.IsMenuOpen, ui_set_enabled = UI.SetEnabled, entity_draw_flag = Entity.DrawFlag, entity_get_ccs_weapon_info = Entity.GetCCSWeaponInfo, entity_get_render_box = Entity.GetRenderBox, entity_get_weapons = Entity.GetWeapons, entity_get_entities_by_class_id = Entity.GetEntitiesByClassID, entity_get_hitbox_position = Entity.GetHitboxPosition, entity_get_eye_position = Entity.GeteyePosition, entity_get_game_rules_proxy = Entity.GetGameRulesProxy, entity_is_bot = Entity.IsBot, entity_get_weapon = Entity.GetWeapon, entity_set_prop = Entity.SetProp, entity_get_prop = Entity.GetProp, entity_get_render_origin = Entity.GetRenderOrigin, entity_get_name = Entity.GetName, entity_get_class_name = Entity.GetClassName, entity_get_class_id = Entity.GetClassID, entity_is_dormant = Entity.IsDormant, entity_is_alive = Entity.IsAlive, entity_is_valid = Entity.IsValid, entity_is_local_player = Entity.IsLocalPlayer, entity_is_enemy = Entity.IsEnemy, entity_is_teammate = Entity.IsTeammate, entity_get_entity_from_user_id = Entity.GetEntityFromUserID, entity_get_local_player = Entity.GetLocalPlayer, entity_get_teammates = Entity.GetTeammates, entity_get_enemies = Entity.GetEnemies, entity_get_players = Entity.GetPlayers, entity_get_entities = Entity.GetEntities, render_text_size = Render.TextSize, render_string = Render.String, render_filled_circle = Render.FilledCircle, render_textured_rect = Render.TexturedRect, render_add_texture = Render.AddTexture, render_find_font = Render.FindFont, render_add_font = Render.AddFont, render_polygon = Render.Polygon, render_gradient_rect = Render.GradientRect, render_get_screen_size = Render.GetScreenSize, render_world_to_screen = Render.WorldToScreen, render_circle = Render.Circle, render_filled_rect = Render.FilledRect, render_rect = Render.Rect, render_line = Render.Line, convar_set_string = Convar.SetString, convar_get_string = Convar.GetString, convar_set_float = Convar.SetFloat, convar_get_float = Convar.GetFloat, convar_set_int = Convar.SetInt, convar_get_int = Convar.GetInt, event_get_string = Event.GetString, event_get_float = Event.GetFloat, event_get_int = Event.GetInt, trace_raw_line = Trace.RawLine, trace_smoke = Trace.Smoke, trace_bullet = Trace.Bullet, trace_line = Trace.Line, usercmd_get_movement = UserCMD.GetMovement, usercmd_set_view_angles = UserCMD.SetViewAngles, usercmd_send = UserCMD.Send, usercmd_choke = UserCMD.Choke, usercmd_set_buttons = UserCMD.SetButtons, usercmd_get_buttons = UserCMD.GetButtons, usercmd_set_movement = UserCMD.SetMovement, sound_stop_microphone = Sound.StopMicrophone, sound_play_microphone = Sound.PlayMicrophone, sound_play = Sound.Play, local_get_inaccuracy = Local.GetInaccuracy, local_get_spread = Local.GetSpread, local_get_fake_yaw = Local.GetFakeYaw, local_get_real_yaw = Local.GetRealYaw, local_set_clan_tag = Local.SetClanTag, local_set_view_angles = Local.SetViewAngles, local_get_view_angles = Local.GetViewAngles, local_latency = Local.Latency, cheat_is_legit_config_active = Cheat.IsLegitConfigActive, cheat_is_rage_config_active = Cheat.IsRageConfigActive, cheat_get_username = Cheat.GetUsername, cheat_print_chat = Cheat.PrintChat, cheat_register_callback = Cheat.RegisterCallback, cheat_execute_command = Cheat.ExecuteCommand, cheat_print_color = Cheat.PrintColor, cheat_print = Cheat.Print, input_force_cursor = Input.ForceCursor, input_get_cursor_position = Input.GetCursorPosition, input_is_key_pressed = Input.IsKeyPressed, world_get_server_string = World.GetServerString, world_get_map_name = World.GetMapName, antiaim_set_lby_offset = AntiAim.SetLBYOffset, antiaim_set_real_offset = AntiAim.SetRealOffset, antiaim_set_fake_offset = AntiAim.SetFakeOffset, antiaim_get_override = AntiAim.GetOverride, antiaim_set_override = AntiAim.SetOverride, exploit_override_tolerance = Exploit.OverrideTolerance, exploit_override_shift = Exploit.OverrideShift, exploit_enable_recharge = Exploit.EnableRecharge, exploit_disable_recharge = Exploit.DisableRecharge, exploit_recharge = Exploit.Recharge, exploit_get_charge = Exploit.GetCharge, ragebot_get_targets = Ragebot.GetTargets, ragebot_ignore_target = Ragebot.IgnoreTarget, ragebot_force_hitbox_safety = Ragebot.ForceHitboxSafety, ragebot_force_target_minimum_damage = Ragebot.ForceTargetMinimumDamage, ragebot_force_target_hitchance = Ragebot.ForceTargetHitchance, ragebot_force_target_safety = Ragebot.ForceTargetSafety, ragebot_force_target = Ragebot.ForceTarget, ragebot_get_target = Ragebot.GetTarget, material_refresh = Material.Refresh, material_set_key_value = Material.SetKeyValue, material_get = Material.Get, material_destroy = Material.Destroy, material_create = Material.Create;

var screen_size = render_get_screen_size();
var sv_cheats_cache = 0;
var removals_cache = 0;
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 h = [];
     const fontpixel = Render.AddFont( "Verdana", 7, 100);

     if (UI.IsHotkeyActive("Anti-Aim", "Extra", "Slow walk")) {
       h.push("Slow motion")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Extra", "Fake duck")) {
       h.push("Duck peek assist")
     }
     if (UI.IsHotkeyActive("Misc", "General", "Movement", "Auto peek")) {
       h.push("Quick peek")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter")) {
       h.push("Anti-Aim invert")
     }
     if (UI.IsHotkeyActive("Rage", "General", "General", "Force safe point")) {
       h.push("Safe point")
     }
     if (UI.IsHotkeyActive("Rage", "General", "General", "Force body aim")) {
       h.push("Body aim")
     }
     if (UI.IsHotkeyActive("Rage", "Exploits", "Double tap")) {
       h.push("Double tap")
     }
     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 + 4) * 127 + 128),
         255
     ];
     

     Render.FilledRect(x, y, 170, 20, [15, 15, 15, 255]);
     Render.StringCustom(x + 60, y + 4, 0, "keybindings", [255, 255, 255, 255], fontpixel);
     Render.FilledRect(x, y, 170, 2, [224, 61, 61, 255]);
     Render.FilledRect(x, y + 20, 170, 20 + 15 * (h.length - 1), [15, 15, 15, 20]);
     for (i = 0; i < h.length; i++)
     {
        Render.StringCustom(x + 5, y + 23 + 15 * i, 0, h[i], [255, 255, 255, 255], fontpixel);
        Render.StringCustom(x + 123, y + 23 + 15 * i, 0, "[toggled]", [255, 255, 255, 255], fontpixel);
     }

     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");
var old_party_mode = false;

function on_draw( ) {
    var party_mode = UI.GetValue( "MISC", "JAVASCRIPT", "Script items", "party mode" );
    
    if ( old_party_mode != party_mode ) {
        old_party_mode = party_mode;

        Convar.SetString( "sv_party_mode", party_mode ? "1" : "0" );
    }
}

function on_game_newmap( ) {
    var party_mode = UI.GetValue( "MISC", "JAVASCRIPT", "Script items", "party mode" );
    
    Convar.SetString( "sv_party_mode", party_mode ? "1" : "0" );
}

function initialize( ) {
    UI.AddCheckbox( "party mode" );

    Global.RegisterCallback( "Draw", "on_draw" );
    Global.RegisterCallback( "game_newmap", "on_game_newmap" );
}

initialize( );
UI.AddSliderInt("", 0, 0);
var currentTick = 0;
var lastTick = 0;
var special = false
var speed = 22;
var ctag = 0

function Draw(){
    currentTick = parseInt(Globals.Curtime() * 1000);
    if (currentTick - (10000 / speed) >= lastTick){
        switch ((ctag) % 42){
            case 0:{
                Local.SetClanTag("             ");
                break;
            }
            case 1:{
                Local.SetClanTag("p          \n");
                break;
            }
            case 2:{
                Local.SetClanTag("pi         \n");
                break;
            }
            case 3:{
                Local.SetClanTag("pi$        \n");
                break;
            }
            case 4:{
                Local.SetClanTag("pi$t       \n");
                break;
            }
            case 5:{
                Local.SetClanTag("pi$to      \n");
                break;
            }
            case 6:{
                Local.SetClanTag("pi$ton     \n");
                break;
            }
            case 7:{
                Local.SetClanTag("pi$ton#    \n");
                break;
            }
            case 8:{
                Local.SetClanTag("pi$ton#    \n");
                break;
            }
            case 9:{
                Local.SetClanTag("pi$ton#0   \n");
                break;
            }
            case 10:{
                Local.SetClanTag("pi$ton#00  \n");
                break;
            }
            case 11:{
                Local.SetClanTag("pi$ton#000 \n");
                break;
            }
            case 12:{
                Local.SetClanTag("pi$ton#0001\n");
                break;
            }
            case 13:{
                Local.SetClanTag("pi$ton#0001\n");
                break;
            }
            case 14:{
                Local.SetClanTag("pi$ton#000 \n");
                break;
            }
            case 15:{
                Local.SetClanTag("pi$ton#00  \n");
                break;
            }
            case 16:{
                Local.SetClanTag("pi$ton#0   \n");
                break;
            }
            case 17:{
                Local.SetClanTag("pi$ton#    \n");
                break;
            }
            case 18:{
                Local.SetClanTag("pi$ton     \n");
                break;
            }
            case 19:{
                Local.SetClanTag("pi$to      \n");
                break;
            }
            case 20:{
                Local.SetClanTag("pi$t       \n");
                break;
            }
            case 21:{
                Local.SetClanTag("pi$        \n");
                break;
            }
            case 22:{
                Local.SetClanTag("pi         \n");
                break;
            }
            case 23:{
                Local.SetClanTag("p          \n");
                break;
            }
            case 24:{
                Local.SetClanTag("           \n");
                break;
            }
			case 25:{
                Local.SetClanTag("           \n");
                break;
            }
			case 26:{
                Local.SetClanTag("             ");
                break;
            }
        }
        if (ctag == 26){
            ctag = 0;
        }else{
            ctag = ctag+1;
        }
        lastTick = currentTick;
    }
}

Cheat.RegisterCallback("Draw", "Draw");
const enable = UI.AddCheckbox("Enable color enhancement");
const cc = UI.AddCheckbox("Color correction");
const cc_tint = UI.AddSliderInt("Tint", 0, 100);
const cc_intensity = UI.AddSliderInt("Intensity", 0, 100);

const fog = UI.AddCheckbox("Fog correction");
const fog_color = UI.AddColorPicker("Color");
const fog_distance = UI.AddSliderInt("Distance", 0, 2500);
const fog_density = UI.AddSliderInt("Density", 0, 100);
const handle_visibility = function()
{
    // Get booleans to make our life easier
    const main = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Enable color enhancement");
    const cc = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Color correction");
    const fog = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Fog correction");

    // Our main switch should always be visible
    UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Enable color enhancement", true);

    // Update other elements based on their parents
    UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Color correction", main);
    UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Tint", cc);
    UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Intensity", cc);

    UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Fog correction", main);
    UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Color", fog);
    UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Distance", fog);
    UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Density", fog);
};

const update_fog = function()
{
    
    if (!UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Fog correction"))
    {
        if (Convar.GetString("fog_override") !== "0")
        {
            Convar.SetString("fog_override", "0");
        }

        return;
    }

    if (Convar.GetString("fog_override") !== "1")
    {
        Convar.SetString("fog_override", "1");
    }


    // Get our fog properties
    const clr = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "Color");
    const clr_value = clr[0] + " " + clr[1] + " " + clr[2];

    const dist = UI.GetString("Misc", "JAVASCRIPT", "Script items", "Distance");
    const dens = (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Density") / 100).toString();

    // Check if the fog's color isn't the same as our desired color
    if (Convar.GetString("fog_color") !== clr_value)
    {
        // Update color
        Convar.SetString("fog_color", clr_value);
    }

    // Check if the fog's end distance isn't the same as our desired end distance
    if (Convar.GetString("fog_end") !== dist)
    {
        // Update distance
        Convar.SetString("fog_start", "0");
        Convar.SetString("fog_end", dist);
    }

    // Check if the fog's density isn't the same as our desired density
    if (Convar.GetString("fog_maxdensity") !== dens)
    {
        // Update density
        Convar.SetString("fog_maxdensity", dens);
    }

}

const draw_cc = function()
{
    // Check if Color correction isn't on
    if (!UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Color correction"))
        return;

    // Get our drawing properties
    const tint = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Tint");
    const intensity = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Intensity");

    const x = Global.GetScreenSize()[0], y = Global.GetScreenSize()[1];

    // Draw our color correction layer
    Render.FilledRect(
        0,
        0,
        x,
        y,
        [tint,
         0,
         255 - tint,
         intensity
        ]
    );

}

// Handles the visibility whenever the script is loaded
handle_visibility();

// Disables the 3D skybox for better looking fog
Convar.SetString("r_3dsky", "0");

function main()
{

    // Callback our functions
    handle_visibility();
    update_fog();
    draw_cc();

}

//endregion

//region callbacks

// Register our callbacks
Global.RegisterCallback("Draw", "main");

//endregion
var materials = []

function createMat(name){
    UI.AddColorPicker(name + " chams")
    UI.AddCheckbox("Hollow " + name.toLowerCase() + " chams")
    UI.AddCheckbox("Pulse " + name.toLowerCase() + " chams")
    UI.AddCheckbox("Rainbow " + name.toLowerCase() + " chams")
    UI.AddCheckbox("Wireframe " + name.toLowerCase() + " chams")
    Material.Create(name + " chams")
    materials.push([name,
         name + " chams",
         "Hollow " + name.toLowerCase() + " chams",
         "Pulse " + name.toLowerCase() + " chams",
         "Rainbow " + name.toLowerCase() + " chams",
         "Wireframe " + name.toLowerCase() + " chams"]);
}
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 [
        Math.round(r * 255),
        Math.round(g * 255),
        Math.round(b * 255),
        255
    ]
}
function materialUpdate(){   
    for(i in materials){
        var mat = materials[i]
        var mat_index = Material.Get(mat[0] + " chams")
        if ( mat_index > 0 )
        {
            
            Material.SetKeyValue(mat_index, "$baseTexture", "vgui/white")
            var additive = UI.GetValue("Script items", "Hollow " + mat[0] .toLowerCase() + " chams")
            Material.SetKeyValue(mat_index, "$additive", additive ? "1" : "0")
            Material.SetKeyValue(mat_index, "$envmap", "models/effects/cube_white")
            Material.SetKeyValue(mat_index, "$envmapfresnel", "1")
            
            var uicol = UI.GetColor("Script items", mat[0]  + " chams")
            var pulse = UI.GetValue("Script items", mat[3])
            var rainbow = UI.GetValue("Script items", mat[4])
            if(rainbow){
                uicol = HSVtoRGB(Globals.Realtime() / 5 % 1, 1, 1)
                uicol[0] /= 10
                uicol[1] /= 10
                uicol[2] /= 10
            }
            if(pulse){
                var speed = 7
                var additive = 5
                var intensity = 0.6
                var sine = (Math.sin(Globals.Realtime() * 7) + 5) * intensity
                uicol[0] *= sine
                uicol[1] *= sine
                uicol[2] *= sine
            }
            var wireframe = UI.GetValue("Script items", mat[5])
            Material.SetKeyValue(mat_index, "$wireframe", wireframe ? "1" : "0")
            Material.SetKeyValue(mat_index, "$envmapfresnelminmaxexp", wireframe ? "[0 2 4]" : "[0 1 2]")
            Material.SetKeyValue(mat_index, "$envmaptint", "[" + uicol[0]/255 + " " + uicol[1]/255 + " " + uicol[2]/255 + "]")
            Material.SetKeyValue(mat_index, "$alpha", "1")
            Material.Refresh(mat_index)       
        }
    }
}
createMat("Better glow")
Cheat.RegisterCallback("Material", "materialUpdate")
function onUnload()
{
    for(i in materials)
    {
        Material.Destroy(materials[i][0])
    }
}
Cheat.RegisterCallback("Unload", "onUnload")
// UI Stuff
UI.AddSliderInt("", 0, 0);
UI.AddLabel("MultiSay by MikiMiki");
UI.AddCheckbox("Enable Killsay");
UI.AddCheckbox("Use Enemy Name");
UI.AddTextbox("Say(s)");
UI.AddSliderInt("Killsay Delay", 0, 10);
UI.AddCheckbox("Enable Killsound");
UI.AddTextbox("Filename(s)");
UI.AddCheckbox("Hear Killsound");
UI.AddSliderFloat("Play Length", 0.0, 10.0);
UI.AddLabel("Note: Set length to longest sound");
UI.AddSliderInt("", 0, 0);

// Functions to return killsays and killsounds
function rand_chat() {
    string = UI.GetString("Misc", "JAVASCRIPT", "Script items", "Say(s)");
    killsays = string.split(", ");
    return killsays[randint(0, killsays.length)];
}

function rand_sound() {
    string = UI.GetString("Misc", "JAVASCRIPT", "Script items", "Filename(s)");
    sounds = string.split(", ");
    return sounds[randint(0, sounds.length)] + ".wav";
}

// Killsay Section

// Variables used by killsay functions
var kill_time = 0;
var say = "";
var state = false;

// Function to create killsay
function killsay() {
    if (!UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Enable Killsay")) return;
    if (Entity.GetEntityFromUserID(Event.GetInt("attacker")) == Entity.GetLocalPlayer()) {
        kill_time = Globals.Realtime();
        string = name_handler();
        if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Killsay Delay" == 0)) {
            display(string);
        }
        else {
            say = string;
            state = true;
        }
    }
}

function name_handler() {
    if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Use Enemy Name")) {
        return (Entity.GetName(Entity.GetEntityFromUserID(Event.GetInt("userid"))) + " " + rand_chat());
    }
    else {
        return (rand_chat());
    }
}

// Function that handles when to send chat via delay value
function delay_handler(string) {
    time = Globals.Realtime();
    if (time - kill_time == UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Killsay Delay") && state == true) {
        display(say);
        state = false;
        say = "";
    }
}

// Function used to send in chat
function display(string) {
    Global.ExecuteCommand("say " + string);
}

// Function that returns random ints (for indexes)
function randint(min, max) {
    return Math.floor(Math.random() * (max - min)) + min;
}

// Killsound Section

// Variables used by killsound functions
var playing = false;
var started = 0.0;

// Function that plays killsound
function killsound() {
    if (!UI.GetValue("Misc", "JAVASCRIPT", "Script Items", "Enable Killsound")) return;
    if (Entity.GetEntityFromUserID(Event.GetInt("attacker")) != Entity.GetLocalPlayer()) return;
    if (Entity.GetEntityFromUserID(Event.GetInt("userid")) == Entity.GetLocalPlayer()) return;
    started = Global.Realtime();
    playing = true;
    if (UI.GetValue("Misc", "JAVASCRIPT", "Script Items", "Hear Killsound")) {
        Global.ExecuteCommand("voice_loopback 1");
    }
    Sound.PlayMicrophone('..\\Counter-Strike Global Offensive\\' + rand_sound());
}

// Function to handle when to stop playing killsound
function soundreset() {
    if (playing && Math.abs(started + UI.GetValue("Misc", "JAVASCRIPT", "Script Items", "Play Length") - Global.Realtime()) < 0.05) {
        playing = false;
        Sound.StopMicrophone();
        Global.ExecuteCommand("voice_loopback 0");
    }
}

// Callbacks
Global.RegisterCallback("player_death", "killsay");
Global.RegisterCallback("player_death", "killsound");
Global.RegisterCallback("FrameStageNotify", "soundreset");
Global.RegisterCallback("FrameStageNotify", "delay_handler");

var cnt = 0
UI.AddSliderFloat("Length", 0, 100)
UI.AddSliderFloat("Speed", 0, 10)
UI.AddColorPicker("Crosshair Color")
UI.AddCheckbox("Rainbow Crosshair")
function rotateAroundPoint(center,point,angle){
    angle = angle / 180 * Math.PI
    var x = Math.cos(angle) * (point[0]-center[0])-Math.sin(angle)*(point[1]-center[1])+center[0]
    var y = Math.sin(angle) * (point[0]-center[0])+Math.cos(angle)*(point[1]-center[1])+center[1]
    return [x,y]
}
function hsv2rgb(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)
    };
}
function draw(){
    var scr = Render.GetScreenSize()
    scr[0]/=2
    scr[1]/=2
   
    var col = UI.GetColor("Script Items", "Crosshair Color")
    if(UI.GetValue("Script Items", "Rainbow Crosshair")){
        var coll = hsv2rgb(cnt * .002,1,1)
        col = [coll.r,coll.g,coll.b,col[3]]
    }
    var range = UI.GetValue("Script Items", "Length")
    // top
    var topx = scr[0]
    var topy = scr[1]+range
    var topxx = scr[0]-range
    var topyy = scr[1]+range
    var topp = rotateAroundPoint(scr,[topx,topy], cnt)
    var toppp = rotateAroundPoint(scr,[topxx,topyy], cnt)
    Render.Line(scr[0],scr[1],topp[0],topp[1],col)
    Render.Line(topp[0],topp[1],toppp[0],toppp[1],col)
    // bottom
    var botx = scr[0]
    var boty = scr[1]-range
    var botxx = scr[0]+range
    var botyy = scr[1]-range
    var bott = rotateAroundPoint(scr,[botx,boty], cnt)
    var bottt = rotateAroundPoint(scr,[botxx,botyy],cnt)
    Render.Line(scr[0],scr[1],bott[0],bott[1],col)
    Render.Line(bott[0],bott[1],bottt[0],bottt[1],col)
    // right
    var rightx = scr[0]+range
    var righty = scr[1]
    var rightxx = scr[0]+range
    var rightyy = scr[1]+range
    var rightt = rotateAroundPoint(scr,[rightx,righty],cnt)
    var righttt = rotateAroundPoint(scr,[rightxx,rightyy],cnt)
    Render.Line(scr[0],scr[1],rightt[0],rightt[1],col)
    Render.Line(rightt[0],rightt[1],righttt[0],righttt[1],col)
    // left
    var leftx = scr[0]-range
    var lefty = scr[1]
    var leftxx = scr[0]-range
    var leftyy = scr[1]-range
    var leftt = rotateAroundPoint(scr,[leftx,lefty],cnt)
    var lefttt = rotateAroundPoint(scr,[leftxx,leftyy],cnt)
    Render.Line(scr[0],scr[1],leftt[0],leftt[1],col)
    Render.Line(leftt[0],leftt[1],lefttt[0],lefttt[1],col)   
    cnt+= Globals.Frametime() * (UI.GetValue("Script Items", "Speed")*100)
}
Cheat.RegisterCallback("Draw","draw")