Вопрос Помощь в коде

Начинающий
Статус
Оффлайн
Регистрация
4 Июл 2021
Сообщения
54
Реакции[?]
2
Поинты[?]
0
кому нечего делать, или кто занимается благотворительностью, помогите спасить миндмг с этого корда:
JavaScript:
//OTC3 CORD MADE BY @ZXSLEEBU
//UKRAINE THE BEST BLYAT
//SALO SALO SALO UKRAINSKE SALO

//pls, if you have the source code and seeing this comment,
//don't remove any comments, cuz i wanna to be in a history
//if you will obfuscate it pls specify me in comment before a code
//huge thanks
//i think this cord will be popular asf
//but rn it's only my dreams

//yes, i pasted, but many features were created and modded by me
//when i created it, i thought, would it be free, or paid

//if you paid me even 1$, very big thanks to you
//i wanna buy a new pc
//
//@zxsleebu
//29.01.2020

//didn't buy new pc tho
//where are my money???

var name_text = "otc3 cord";
var last_upd = "02.05.21";
var version = "0.3.0";
var width = 494;
var height = 330;

//Set to true, if you want to get debug logs
var debug = false;

//Positioning and UI look
var subtabs_width = width - (14 * 2);
const tab_margin = 5;
const tab_width = 76;
const header_radius = 3;
const element_margin_bottom = 11;
const checkbox_height = 13;
const checkbox_width = 12;
const box_margin_top = 22;
const box_margin_bottom = 3;
const box_margin_x = 8;
const box_text_margin_x = 29;
const slider_height = 8;
const slider_text_margin = 9;
const list_height = 18;

//Colors
const line_color = [55, 59, 66, 255];
const bright_line_color = [227, 186, 105, 255];
const subtab_text_color = [78, 81, 88, 255];
const background_color = [44, 48, 55, 255];
const tab_active_color = [34, 37, 42, 255];
const text_color = [220, 223, 230, 255];
const element_color = [31, 33, 37, 255];
const element_border_color = [37, 39, 44, 255];
const element_border_color2 = [56, 60, 67, 255];
const element_active_color = [217, 157, 86, 255];
const hintbox_color = [32, 34, 39, 255];
const white_color = [255, 255, 255, 255];
const list_text_color = [239, 239, 239, 255];
const shadow_color = [0, 0, 0, 150];

//Fonts
var menu_font = 0;
var icon_font = 0;
var subtabs_font = 0;
var text_icon_font = 0;
var list_font = 0;

//Predefining variables
var screen_size = Render.GetScreenSize();
var cursor_pos = Input.GetCursorPosition();
var selected_tab = 0;
var tab_start = 0;
var box_offsets = [0, 0];
var box_width = 0;
var subtab_start = 0;
var subtab_text_pos = 0;
var tab_colors = [0, 0, 0, 0];
var old_cursor = [0, 0];
var is_pressed = false;
var is_moving = false;
var click_block = false;
var subtabs_names = {};
var checkboxes = [];
var selected_subtabs = {};
var checkbox_alpha = {};
var hint_text = "";
var hint_x = 0;
var hint_y = 0;
var hint_size = 0;
var show_items = false;
var slider_changing = false;
var settingsAreLoaded = false;
var player_list = [];
var force_lethal = false;
function log(string){(debug) && Cheat.Print("[DEBUG] "+string+"\n")}
(debug) && Cheat.ExecuteCommand("showconsole");
Cheat.ExecuteCommand("-attack2");
log("Initialized log function");


//To-Do list
//Rage: Safe after x miss, Autoscope fix (don't scope if cannot shoot)
//Anti-Aim:
//Local Player:
//World: Nade tracer on all nades
//Visual Other: Custom out of fov, Custom autopeek color, Global position for hitmarker if impact didn't hit the wall
//Misc Other: Clantag with custom animation, Killsay, Custom Theme Color, Meme Mode, Tetris
var menu_elements = {
    "Rage": {
        "General": {
            "General": [
                {"type": "checkbox", "name": "Dormant Aimbot", "id": "dormant_aim", "hint": "Cheat will shoot at the Dormant ESP when pressing a hotkey"},
                {"type": "checkbox", "name": "Auto peek helper", "id": "auto_peek", "hint": "It will automatically turn on doubletap,\nfreestanding, mindamage and force baim\nwhen auto peek keybind is activated.\nBind \"Force body aim\" to toggle on any key\nto make this function work"},
                {"type": "checkbox", "name": "Safe AWP", "id": "safe_awp", "hint": "Bind \"Force safe point\" to toggle on any key\nto make this function work"},
                //{"type": "checkbox", "name": "Safe point on limbs", "id": "safe_limbs", "hint": "Forces safe points on legs, feet and arms"},
                {"type": "checkbox", "name": "Jumpscout", "id": "jumpscout", "hint": "Sets scout hitchance to 40 in air"},
                {"type": "checkbox", "name": "Adaptive noscope", "id": "adaptive_noscope", "hint": "No auto scope on auto and scout\nif target is less than 7 meters away"},
                {"type": "checkbox", "name": "Predictive autoscope", "id": "predictive_autoscope", "hint": "Scopes faster than otc3 does"},
                //{"type": "checkbox", "name": "Lethal safety", "id": "lethal_safety", "hint": "Forces baim or safe points when target is lethal.\nBind \"Force body aim\" to toggle on any key\nto make this function work"},
            ],
            "Min-DMG bind": [
                {"type": "checkbox", "name": "Enabled", "id": "mindamage"},
                {"type": "checkbox", "name": "Advanced", "id": "mindamage_advanced", "master": "mindamage"},
                {"type": "slider", "name": "Min damage override", "id": "mindamage_hp", "min": 1, "max": 130, "default": 5, "master": "mindamage"},
                {"type": "slider", "name": "Min damage pistol", "id": "mindamage_hp_pistol", "min": 1, "max": 130, "default": 5, "master": "mindamage_advanced"},
                {"type": "slider", "name": "Min damage revolver", "id": "mindamage_hp_revolver", "min": 1, "max": 130, "default": 10, "master": "mindamage_advanced"},
                {"type": "slider", "name": "Min damage scout", "id": "mindamage_hp_scout", "min": 1, "max": 130, "default": 5, "master": "mindamage_advanced"},
                {"type": "slider", "name": "Min damage AWP", "id": "mindamage_hp_awp", "min": 1, "max": 130, "default": 15, "master": "mindamage_advanced"},
                {"type": "slider", "name": "Min damage auto", "id": "mindamage_hp_auto", "min": 1, "max": 130, "default": 5, "master": "mindamage_advanced"},
            ],
            "Other": [
                {"type": "checkbox", "name": "Force backshoot bind", "id": "force_backshoot"},
                {"type": "checkbox", "name": "Ping spike bind", "id": "ping_spike"},
                {"type": "checkbox", "name": "Custom zeus hitchance", "id": "zeus_hitchance_enabled"},
                {"type": "slider", "name": "Hitchance", "id": "zeus_hitchance", "min": 0, "max": 100, "append": "%", "default": 70, "master": "zeus_hitchance_enabled"}
            ],
            "Doubletap": [
                {"type": "checkbox", "name": "DT recharge boost", "id": "doubletap_boost"},
                {"type": "checkbox", "name": "Safe point on DT", "id": "dt_safepoint", "hint": "Force safe point on enemies when DT is on"},
                {"type": "checkbox", "name": "Prefer baim on DT", "id": "prefer_baim_on_dt", "hint": "Will turn on \"Prefer body aim\"\nif doubletap is active and charged"},
            ]
        },
        "Safety system": {},
        "Player list": {}
    },
    "Anti-Aim": {
        "General": {
            "General": [
                {"type": "checkbox", "name": "Lowdelta", "id": "lowdelta", "hint": "Makes your head harder to hit"},
                {"type": "checkbox", "name": "Opposite on exploits", "id": "opposite_on_exploits", "hint": "Makes opposite AA type works on active exploits.\nMakes DT register a bit worse"},
                /*{"type": "checkbox", "name": "Pitch 0 on land", "id": "pitch_zero_on_land"},*/
                {"type": "checkbox", "name": "Legit AA on knife", "id": "antiaim_fix"},
                {"type": "checkbox", "name": "Legit AA on key", "id": "legit_aa"},
                {"type": "checkbox", "name": "Freestanding on key", "id": "freestanding", "hint": "Puts your head in a safe place"}
            ],
            "Fake-Lag": [
                {"type": "checkbox", "name": "Alternative fake-lag", "id": "alternative_fakelag", "hint": "Makes your fake-lag less predictable"},
                {"type": "slider", "name": "Alternative limit", "id": "alternative_limit", "min": 1, "max": 16, "default": 16, "master": "alternative_fakelag"},
                {"type": "checkbox", "name": "No revolver fake-lag", "id": "fakelag_fix", "hint": "Helps to prevent R8 shooting at floor"}
            ],
            "Auto invert": [
                {"type": "checkbox", "name": "Invert on shot", "id": "invert_on_shot"},
                {"type": "checkbox", "name": "Ideal yaw", "id": "ideal_yaw", "hint": "Ideal yaw makes you peek\nwith your desync turned to enemy.\nIf \"Anti bruteforce\" is on, ideal yaw will be turned off\nafter 1st enemy miss for 3 seconds"},
                {"type": "checkbox", "name": "Standing auto inverter", "id": "standing_auto_invert"},
                {"type": "checkbox", "name": "Anti bruteforce", "id": "anti_brute", "hint": "Inverts your AA when enemy miss a shot"}
            ],
            "Animations": [
                {"type": "checkbox", "name": "Matchmaking FD", "id": "mm_fd", "hint": "Fakeduck created from a sketch.\nYou can use opposite LBY,\nbut your body will jitter and stop sometimes.\nThe best preset for MM is Lower Rage"},
                {"type": "checkbox", "name": "Slowmotion", "id": "slowmotion", "hint": "Makes your legs being slow and sliding on slowwalk"},
                {"type": "checkbox", "name": "Slowmotion legbreaker", "id": "slowmotion_legbreaker", "hint": "Jitters your legs and body on slowmotion.\nBreaks enemy's animfix.\nLess speed = more jitter", "master": "slowmotion"},
                {"type": "slider", "name": "Slowmotion speed", "id": "slowmotion_speed", "min": 5, "max": 70, "default": 45, "master": "slowmotion"},
                {"type": "checkbox", "name": "Legbreaker", "id": "legbreaker", "hint": "Spams \"Slide walk\" to make your legs unpredictable\nWorks better with alternative fake-lag"}
            ]
        },
        /*"Custom AA": {

        }*/
    },
    "Visual": {
        "World": {
            "General": [
                {"type": "checkbox", "name": "Skeleton on hit", "id": "skeleton_on_hit"},
                {"type": "checkbox", "name": "Damage marker", "id": "damage_marker"},
                {"type": "checkbox", "name": "Enemy eye tracers", "id": "eye_tracers"}
            ],
            "Local player": [
                {"type": "checkbox", "name": "Bullet tracer", "id": "bullet_tracer"},
                {"type": "checkbox", "name": "Trail", "id": "trail"}
            ],
            "Bloom & FX": [
                {"type": "checkbox", "name": "World color", "id": "world_color"},
                {"type": "slider", "name": "World brightness", "id": "world_brightness", "min": -50, "max": 25},
                {"type": "slider", "name": "Model brightness", "id": "model_brightness", "min": 0, "max": 100, "append": "%"},
                {"type": "slider", "name": "Bloom scale", "id": "bloom_scale", "min": 0, "max": 100, "append": "%"}
            ],
            "Custom fog": [
                {"type": "checkbox", "name": "Enabled", "id": "custom_fog"},
                {"type": "slider", "name": "Distance", "id": "fog_distance", "min": 0, "max": 3000, "master": "custom_fog"},
                {"type": "slider", "name": "Distance third person", "id": "fog_distance_3rd", "min": 0, "max": 2500, "visible": false, "master": "custom_fog"},
                {"type": "slider", "name": "Density", "id": "fog_density", "min": 0, "max": 100, "master": "custom_fog"}
            ]
        },
        "Models": {
            "Better Glow Chams": [
                {"type": "checkbox", "name": "Enabled", "id": "better_glow_chams"},
                {"type": "checkbox", "name": "Hollow", "id": "better_glow_chams_hollow", "master": "better_glow_chams"},
                {"type": "checkbox", "name": "Pulse", "id": "better_glow_chams_pulse", "master": "better_glow_chams"},
                {"type": "checkbox", "name": "Rainbow", "id": "better_glow_chams_rainbow", "master": "better_glow_chams"},
                {"type": "checkbox", "name": "Wireframe", "id": "better_glow_chams_wireframe", "master": "better_glow_chams"},
                {"type": "slider", "name": "Vibrancy", "id": "better_glow_chams_vibrancy", "min": 0, "max": 100, "append": "%", "default": 85, "master": "better_glow_chams"}
            ],
            "Model changer": [
                {"type": "checkbox", "name": "Agent changer", "id": "agent_changer", "hint": "Team-based agent changer.\nAPI issue to add new agents, sorry"},
                {"type": "checkbox", "name": "Arms color", "id": "arms_color"}
            ]
        },
        "Other": {
            "General": [
                {"type": "checkbox", "name": "Effect on kill", "id": "effect_on_kill"},
                {"type": "checkbox", "name": "Rainbow bar", "id": "rainbow_bar"},
                //{"type": "checkbox", "name": "Custom out of FOV", "id": "custom_out_of_fov"}
            ],
            "Crosshair": [
                {"type": "checkbox", "name": "Better scope", "id": "better_scope"},
                {"type": "checkbox", "name": "Better crosshair", "id": "better_crosshair"},
                {"type": "checkbox", "name": "Better hitmarker", "id": "hitmarker"}
            ],
            "Nades": [
                {"type": "checkbox", "name": "Nade circle", "id": "nade_circle", "hint": "Draws molotov and smoke radius,\nHE grenade explosion visualisation"},
                {"type": "checkbox", "name": "Nade tracer", "id": "nade_tracer"},
                {"type": "checkbox", "name": "Nade warning", "id": "nade_warning"},
                {"type": "checkbox", "name": "Molotov timer", "id": "molotov_timer"},
                {"type": "checkbox", "name": "Transparency on nade", "id": "transparency_on_nade", "hint": "Wall and prop transparency\nwhen throwing nade"},
            ],
            "Miscellaneous": [
                {"type": "slider", "name": "Aspect ratio", "id": "aspect_ratio", "min": 0, "max": 300, "append": "%"},
                {"type": "checkbox", "name": "Dark menu background", "id": "dark_menu"}
            ]
        }
    },
    "Misc": {
        "General": {
            "Miscellaneous": [
                {"type": "checkbox", "name": "FPS boost", "id": "fps_boost"},
                {"type": "checkbox", "name": "Autostrafe fix", "id": "autostrafe_fix"},
                {"type": "checkbox", "name": "Zoom fix", "id": "zoom_fix"},
                {"type": "checkbox", "name": "Location spammer", "id": "enemy_location", "hint": "Sends enemy location in team chat"},
                {"type": "checkbox", "name": "Party mode", "id": "party_mode", "hint": "Make your zeus happy!"},
                {"type": "checkbox", "name": "Custom music kit", "id": "music_kit"},
                {"type": "checkbox", "name": "Clantag on peek", "id": "clantag_on_peek", "hint": "Turns on clantag when enemy is peeking"},
                {"type": "checkbox", "name": "Clantag", "id": "clantag"},
                {"type": "checkbox", "name": "Killsay", "id": "killsay"},
                {"type": "checkbox", "name": "Show useless features", "id": "useless_features", "hint": "elleqt ne trap"},
                {"type": "checkbox", "name": "No buybot in MM", "id": "anti_buybot"}
            ],
            "Information": [
                {"type": "checkbox", "name": "Buy list", "id": "buy_list"},
                {"type": "checkbox", "name": "Vote revealer", "id": "vote_revealer"},
                {"type": "checkbox", "name": "Watermark", "id": "watermark"},
                {"type": "checkbox", "name": "Indicators", "id": "indicators"},
            ],
        }
    }
};
var subtabs_icons = {
    "Rage": {
        "General": "A",
        "Safety system": "J",
        "Player list": "D"
    },
    "Anti-Aim": {
        "General": "H",
        "Custom AA": "B"
    },
    "Visual": {
        "World": "C",
        "Models": "D",
        "Other": "E"
    },
    "Misc": {
        "General": "F"
    }
};
var subtabs_text_icons = {
    "Rage": {
        "General": "",
        "Safety system": "",
        "Player list": ""
    },
    "Anti-Aim": {
        "General": "",
        "Custom AA": ""
    },
    "Visual": {
        "World": "",
        "Models": "",
        "Other": "",
    },
    "Misc": {
        "General": ""
    }
};

//Calculating variables
UI.AddSliderInt(name_text + "_x", -width, screen_size[0]);
UI.AddSliderInt(name_text + "_y", -28, screen_size[1]);
UI.SetEnabled("Script items", name_text + "_x", false);
UI.SetEnabled("Script items", name_text + "_y", false);
var x = UI.GetValue("Script items", name_text + "_x");
var y = UI.GetValue("Script items", name_text + "_y");
UI.AddCheckbox("Show " + name_text + " items");
UI.SetValue("Script items", "Show " + name_text + " items", true);
//UI.AddLabel("Reload " + name_text + " after first load");


//Lowdelta
var jitter_bak = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset");
var yaw_bak = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset");
var block_set = false;
var lowdelta_active = false;
var mmFDActive = false;
function lowdelta(){
    if(!GetVal("lowdelta")) return;
    var FDState = (GetValue("Lowdelta on FD") && (UI.IsHotkeyActive("Anti-Aim", "Extra", "Fake duck") || UI.IsHotkeyActive("Script items", "Matchmaking FD")));
    if(legitAAactive) return;
    if(GetValue("Lowdelta") == 1){
        block_set = false;
        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);
        lowdelta_active = true;
        return;
    }
    if (isSlowwalking() || FDState){
        block_set = false;
        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);
        lowdelta_active = true;
    }
    if(!isSlowwalking() && !mmFDActive && !FDState){
        lowdelta_active = false;
        if(!block_set){
            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", yaw_bak);
            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset", jitter_bak);
            AntiAim.SetOverride(0);
            block_set = true;
        }
        yaw_bak = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset");
        jitter_bak = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset");
    }
}

//Safe AWP
var safePbak = false;
function safeAWP(){
    if(!GetVal("safe_awp")) return;
    weapon = getWeaponName();

    if(weapon == "awp"){
        forceSafePoint = UI.IsHotkeyActive('Rage', 'GENERAL', 'General', 'Force safe point');
        if (!forceSafePoint){
            UI.ToggleHotkey('Rage', 'GENERAL', 'General', 'Force safe point');
            safePbak = true;
        }
    }
    else if (safePbak){
        UI.ToggleHotkey('Rage', 'GENERAL', 'General', 'Force safe point');
        safePbak = false;
    }
}

//Jumpscout
var hitchanceBak = UI.GetValue("Rage", "SCOUT", "Accuracy", "Hitchance");
var block_set2 = false;
var scoutInAir = 40;
function jumpscout(){
    if(!GetVal("jumpscout")) return;
    if(getWeaponName() !== "ssg08"){
        if(UI.GetValue("Rage", "SCOUT", "Accuracy", "Hitchance") !== scoutInAir){
            hitchanceBak = UI.GetValue("Rage", "SCOUT", "Accuracy", "Hitchance");
        }
        if(block_set2) return;
        UI.SetValue("Rage", "SCOUT", "Accuracy", "Hitchance", hitchanceBak);
        block_set2 = true;
        return;
    }

    if (isInAir()){
        block_set2 = false;
        UI.SetValue("Rage", "SCOUT", "Accuracy", "Hitchance", scoutInAir);
    }
    else{
        if(UI.GetValue("Rage", "SCOUT", "Accuracy", "Hitchance") !== scoutInAir){
            hitchanceBak = UI.GetValue("Rage", "SCOUT", "Accuracy", "Hitchance");
        }
        if(block_set2) return;
        UI.SetValue("Rage", "SCOUT", "Accuracy", "Hitchance", hitchanceBak);
        block_set2 = true;
    }
}

//Opposite LBY on Exploits
var block_set3 = false;
function oppositeOnExploits(){
    if(GetVal("lowdelta") && isSlowwalking()) return;
    if(!GetVal("opposite_on_exploits") || !exploitsActive("all")){
        if(block_set3) return;
        AntiAim.SetOverride(0);
        block_set3 = true;
        return;
    }
    if(UI.GetValue("Anti-Aim", "Fake angles", "LBY mode") == 1){
        AntiAim.SetOverride(1);
        block_set3 = false;
        var fake_direction = UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter") == 1 ? 1 : -1;
        if(UI.GetValue("Anti-Aim", "Fake angles", "Fake desync")){
            fake_direction = fake_direction * -1;
        }
        var real_yaw_offset = 60 * fake_direction;
        var lower_body_offset = -60 * fake_direction;
        var current_fake_yaw = Local.GetFakeYaw();
        var current_real_yaw = Local.GetRealYaw();
        if(Math.abs(angle_diff(current_fake_yaw, current_real_yaw)) > 100)
        {
            lower_body_offset = 180;
        }
        AntiAim.SetFakeOffset(0);
        AntiAim.SetRealOffset(real_yaw_offset);
        AntiAim.SetLBYOffset(lower_body_offset);
    }
    else{   
        if(block_set3) return;
        AntiAim.SetOverride(0);
        block_set3 = true;
    }
}

//Adaptive noscope and predictive autoscope
var noscope_target = -1;
var noscope_dist = {
    "ssg08": 4,
    "scar20": 7,
    "g3sg1" : 7
};
var stop_attack2 = false;
function autoscope(){
    if(stop_attack2){
        stop_attack2 = false;
        Cheat.ExecuteCommand("-attack2");
    }
    local = Entity.GetLocalPlayer();
    if(GetVal("adaptive_noscope")){
        if((getWeaponName() !== "ssg08" && getWeaponName() !== "scar20" && getWeaponName() !== "g3sg1") || isInAir()){
            UI.SetValue("Rage", "GENERAL", "General", "Auto scope", true);
            return;
        };
        if(!Ragebot.GetTarget())
            noscope_target = closestTarget();
        else
            noscope_target = Ragebot.GetTarget();
        if(!Entity.IsAlive(noscope_target)){
            UI.SetValue("Rage", "GENERAL", "General", "Auto scope", true);
            return;
        }
        if(get_metric_distance(Entity.GetRenderOrigin(local), Entity.GetRenderOrigin(noscope_target)) < noscope_dist[getWeaponName()]){
            UI.SetValue("Rage", "GENERAL", "General", "Auto scope", false);
        }
        else{
            UI.SetValue("Rage", "GENERAL", "General", "Auto scope", true);
        }
    }
    if(GetVal("predictive_autoscope")){
        switch(getWeaponName()){
            case "ssg08":
            case "scar20":
            case "g3sg1":
            case "awp":
                break;
            default:
                return;
        }
        var enemies = Entity.GetEnemies();
        var local_pos = ExtrapolateTick(15);
        var auto_scope = false;
        var is_scoped = Entity.GetProp(local, "CCSPlayer", "m_bIsScoped");
        for(var i = 0; i < enemies.length;i++){
            var enemy = enemies[i];
            if (!Entity.IsAlive(enemy) || Entity.IsDormant(enemy) || !Entity.IsValid(enemy)) continue;
            var pos = Entity.GetHitboxPosition(enemy, 2)
            var result = Trace.Bullet(local, enemy, local_pos, pos);
            if(result[1] > 1){ // aka damage
                if(get_metric_distance(Entity.GetRenderOrigin(local), Entity.GetRenderOrigin(enemy)) > noscope_dist[getWeaponName()]){
                    auto_scope = true;
                    break;
                }
            }
        }
        if(!is_scoped && auto_scope && !stop_attack2 && canShoot(local)){
            Cheat.ExecuteCommand("+attack2");
            stop_attack2 = true;
        }
    }
}

//Bullet tracer
var bullets = [];
function bulletTracer() {
    if(!GetVal("bullet_tracer")) return;
    if(!World.GetServerString()) return;
    var player = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    if (Entity.GetLocalPlayer() !== player) return;
    if (bullets.length > 20) bullets.shift();
    var eyePos = Entity.GetEyePosition(Entity.GetLocalPlayer());
    var vector = VectorSubtract([Event.GetFloat("x"), Event.GetFloat("y"), Event.GetFloat("z")], eyePos);
    eyePos[0] += vector[0] * 0.01;
    eyePos[1] += vector[1] * 0.01;
    eyePos[2] += vector[2] * 0.01;
    bullets.push({
        "impact": [Event.GetFloat("x"), Event.GetFloat("y"), Event.GetFloat("z")],
        "origin": eyePos,
        "time": Globals.Curtime()
    });
}
function bulletTracer2() {
    if(!GetVal("bullet_tracer")) return;
    if(!World.GetServerString()) return;
    if (bullets.length < 1) return;
    for (i = 0; i < bullets.length; i++) {
        if (bullets[i] != undefined) {
            if (bullets[i]["time"] + 10 < Globals.Curtime()) {
                delete bullets[i];
            } else {
                function getDistance(A, B) {
                    return Math.sqrt(Math.pow(A[0] - B[0], 2) + Math.pow(A[1] - B[1], 2) + Math.pow(A[2] - B[2], 2));
                }
                var impact = Render.WorldToScreen(bullets[i]["impact"]);
                var origin = Render.WorldToScreen(bullets[i]["origin"]);
                var color = UI.GetColor("Script items", "Bullet tracer");
                var thickness = GetValue("Bullet tracer thickness");
                if (origin != undefined && impact != undefined) {
                    if (origin[2] == 0 && !UI.IsHotkeyActive("Visual", "WORLD", "View", "Thirdperson")) {
                        var vector = VectorSubtract(bullets[i]["impact"], bullets[i]["origin"]);
                        var newOrigin = duplicate(bullets[i]["origin"]);
                        var length = getDistance(bullets[i]["impact"], newOrigin) - getDistance(bullets[i]["impact"], Entity.GetEyePosition(Entity.GetLocalPlayer()));
                        newOrigin[0] += vector[0] * (length / getDistance(bullets[i]["impact"], newOrigin) + 0.05);
                        newOrigin[1] += vector[1] * (length / getDistance(bullets[i]["impact"], newOrigin) + 0.05);
                        newOrigin[2] += vector[2] * (length / getDistance(bullets[i]["impact"], newOrigin) + 0.05);
                        origin = Render.WorldToScreen(newOrigin);
                    }
                    if (impact[2] != 0 /*&& origin[1] < screen_size[1] && origin[0] < screen_size[0]*/ && origin[0] > 0) {
                        var step = clamp(Math.floor((color[3] / thickness) * ((Globals.Curtime() - bullets[i]["time"]) / 1.5)), 0, 255);
                        Render.Line(impact[0], impact[1], origin[0], origin[1], [color[0], color[1], color[2], clamp(color[3] - step, 0, 255)]);
                        for (c = 1; c < thickness; c++) {
                            var val = clamp(color[3] - (c * step), 0, 255);
                            Render.Line(impact[0] + (c - 1), impact[1], origin[0] + c, origin[1], [color[0], color[1], color[2], val]);
                            Render.Line(impact[0], impact[1] + (c - 1), origin[0], origin[1] + c, [color[0], color[1], color[2], val]);
                            Render.Line(impact[0] - (c - 1), impact[1], origin[0] - c, origin[1], [color[0], color[1], color[2], val]);
                            Render.Line(impact[0], impact[1] - (c - 1), origin[0], origin[1] - c, [color[0], color[1], color[2], val]);
                        }
                    }
                }
            }
        }
    }
}

//Force backshoot
var enemies = Entity.GetEnemies();
var last_shot_time = []
function forceBackshoot(){
    if(!GetVal("force_backshoot") || !UI.IsHotkeyActive("Script items", "Force backshoot")) return;
    if(!World.GetServerString()) return;
    local = Entity.GetLocalPlayer();
    if(!Entity.IsAlive(Entity.GetLocalPlayer())) return;
    enemies = Entity.GetEnemies();

    for(var i = 0; i < enemies.length; i++){
        var enemy = enemies[i];
        var dif = Globals.Tickcount() - last_shot_time[enemy]
        var has_shot = dif >= 0 && dif <= 12;
        if(!has_shot)
            Ragebot.IgnoreTarget(enemy)
    }
}

var baim_state_bak = UI.IsHotkeyActive('Rage', 'GENERAL', 'Force body aim');
var block_set13 = false;
var block_set14 = false;
var forcedBaim = false;
//Baim or safe points on lethal
function lethalSafety(){
    if(!GetVal("lethal_safety")) return;
    enemies = Entity.GetEnemies();
    for (i = 0; i < enemies.length; i++) {
        if (!Entity.IsValid(enemies[i])) continue;
        if (!Entity.IsAlive(enemies[i])) continue;
        if (Entity.IsDormant(enemies[i])) continue;
        var target = Ragebot.GetTarget();
        if (IsLethal(enemies[i])) {
            if(GetValue("Lethal safety") & (1 << 0)){
                Ragebot.ForceTargetSafety(enemies[i]);
            }
            if(GetValue("Lethal safety") & (1 << 1)){
                if (target == enemies[i]) forceBaim(enemies[i]);
                block_set13 = false;
                block_set14 = false;
            }
            continue;
        }
        if(!baim_state_bak && GetValue("Lethal safety") & (1 << 1)){
            if(!block_set14){
                DisableBaim();
                block_set14 = true;
            }
            forcedBaim = false;
        }
    }
    if(!forcedBaim && GetValue("Lethal safety") & (1 << 1)){
        if(!block_set13){
            if(UI.IsHotkeyActive('Rage', 'GENERAL', 'Force body aim') !== baim_state_bak) UI.ToggleHotkey('Rage', 'GENERAL', 'Force body aim');
            block_set13 = true;
        }
        baim_state_bak = UI.IsHotkeyActive('Rage', 'GENERAL', 'Force body aim');
    }
}

//Pitch 0 on land
var block_set4 = 0;
var block_set17 = false;
var groundCounter = 0;
function pitchZeroOnLand(){
    if(!GetVal("pitch_zero_on_land")) return;
    if(legitAAactive) return;

    local = Entity.GetLocalPlayer();
    var localPlayerFlags = Entity.GetProp(local, "CBasePlayer", "m_fFlags");
    if(localPlayerFlags == 256){
        block_set4 = 0;
        groundCounter = 25;
    }
    if(groundCounter > 0 && localPlayerFlags === 257){
        UI.SetValue("Misc", "PERFORMANCE & INFORMATION", "Information", "Restrictions", 0);
        UI.SetValue("Anti-Aim", "Extra", "Pitch", 0);
        block_set17 = false;
        groundCounter--;
    }
    if(groundCounter === 0){
        if(block_set4 >= 5){
            if(!block_set17){
                UI.SetValue("Misc", "PERFORMANCE & INFORMATION", "Information", "Restrictions", restrictions_bak);
                UI.SetValue("Anti Aim", "Extra", "Pitch", pitch_bak);
                block_set17 = true;
            }
            if(UI.IsMenuOpen()){
                pitch_bak = UI.GetValue("Anti-Aim", "Extra", "Pitch");
                restrictions_bak = UI.GetValue("Misc", "PERFORMANCE & INFORMATION", "Information", "Restrictions");
            }
            return;
        }
        block_set4++;
    }
}

//Better scope
var scope_animation = 0;
var scope_animation_step = 22;
var block_set17 = false;
var block_set18 = false;
var betterScopeActive = false;
var penetration_dot_bak = UI.GetValue("Visuals", "World", "Entities", "Penetration dot");
var penetration_crosshair_bak = UI.GetValue("Visuals", "World", "Entities", "Penetration crosshair");
function betterScope(){
    if(!GetVal("better_scope")) return;
    local = Entity.GetLocalPlayer();
    var scoped = Entity.GetProp(local, 'DT_CSPlayer', 'm_bIsScoped');
    if (!Entity.IsAlive(local) || !World.GetServerString()) {
        return;
    }
    if(Entity.IsAlive(local) && scoped){
        scope_animation += scope_animation_step;
        scope_animation = clamp(scope_animation, 0, 255);
        if(GetValue("Better scope hide GUI")){
            Convar.SetString('cl_draw_only_deathnotices', '1');
        }
        var startX = screen_size[0] / 2 + 1;
        var startY = screen_size[1] / 2 + 1;
        var sizeX = GetValue("Better scope width");
        var sizeY = GetValue("Better scope thickness");
        var off = sizeX / 2 + GetValue("Better scope start");
        var c2 = UI.GetColor("Script items", "Better scope color 1"); //[150, 200, 255, scope_animation]
        var c1 = UI.GetColor("Script items", "Better scope color 2"); //[150,0, 200, 0]
        c2[3] = scope_animation;
        c1[3] = 0;
        renderScopeLine(startX - off, startY, sizeX, sizeY, 1, c1, c2);
        renderScopeLine(startX + off, startY, sizeX, sizeY, 1, c2, c1);
        renderScopeLine(startX, startY - off, sizeY, sizeX, 0, c1, c2);
        renderScopeLine(startX, startY + off, sizeY, sizeX, 0, c2, c1);
    }
    else{
        scope_animation = 0;
        Convar.SetString('cl_draw_only_deathnotices', '0');
    }
}
function renderScopeLine(x, y, w, h, dir, color1, color2){
    return Render.GradientRect(x - Math.round(w/2), y - Math.round(h/2), w, h, dir, color1, color2);
}
function betterScope2(){
    if(!GetVal("better_scope")) return;
    if(Cheat.FrameStage() != 5) return;
    local = Entity.GetLocalPlayer();
    var scoped = Entity.GetProp(local, 'DT_CSPlayer', 'm_bIsScoped');
    if (!Entity.IsAlive(local) || !World.GetServerString()) {
        Convar.SetFloat("r_drawvgui", 1);
        Convar.SetInt("fov_cs_debug", 0);
        block_set18 = false;
        return;
    }
    if(!GetValue("Better scope viewmodel")){
        Convar.SetString("r_drawvgui", "1");
    }
    if(Entity.IsAlive(local) && scoped){
        betterScopeActive = true;
        if(GetValue("Better scope viewmodel")){
            Convar.SetString("r_drawvgui", "0");
            if (!UI.IsHotkeyActive("Visual", "WORLD", "View", "Thirdperson") && !block_set18) {
                Cheat.ExecuteCommand("fov_cs_debug 90");
                //UI.SetValue("Visual", "WORLD", "View", "FOV while scoped", 0);
                block_set18 = true;
            }
        }
    }
    else{
        //if(!block_set17){
        //    UI.SetValue("Visuals", "World", "Entities", "Penetration dot", penetration_dot_bak);
        //    UI.GetValue("Visuals", "World", "Entities", "Penetration crosshair", penetration_crosshair_bak);
        //}
        //penetration_dot_bak = UI.GetValue("Visuals", "World", "Entities", "Penetration dot");
         //penetration_crosshair_bak = UI.GetValue("Visuals", "World", "Entities", "Penetration crosshair");
        betterScopeActive = false;
        block_set18 = false;
        Convar.SetString("r_drawvgui", "1");
        Convar.SetString("fov_cs_debug", "0");
        Convar.SetInt("fov_cs_debug", 0);
    }
}

//Legbreaker
var legbreaker_speed = 2;
var legbreaker_old_tick_count = Globals.Tickcount();
var fakelag_leg = false;
function legBreaker(){
    if(!GetVal("legbreaker")) return;
    if(!World.GetServerString()) return;
    var leghider = GetVal("alternative_fakelag") && !exploitsActive("all") && UI.GetValue("Anti-Aim", "Fake-Lag", "Enabled");
    if((Globals.Tickcount() - legbreaker_old_tick_count) > legbreaker_speed && !leghider){
        if (UI.GetValue("Misc", "GENERAL", "Movement", "Slide walk"))
            UI.SetValue("Misc", "GENERAL", "Movement", "Slide walk", 0);
        else
            UI.SetValue("Misc", "GENERAL", "Movement", "Slide walk", 1);
        legbreaker_old_tick_count = Globals.Tickcount();
    }
    if(leghider){
        if(!fakelag_leg && fakelag_flip){
            UI.SetValue("Misc", "GENERAL", "Movement", "Slide walk", 1);
            fakelag_leg = true;
        }
        else{
            UI.SetValue("Misc", "GENERAL", "Movement", "Slide walk", 0);
        }
        if(fakelag_flip){
            fakelag_leg = false;
        }
    }
}

var accurate_walk_bak = UI.GetValue("Misc", "GENERAL", "Movement", "Accurate walk");
var block_set7 = false;
function slowmotion(){
    if(!GetVal("slowmotion")) return;
    if(!World.GetServerString()) return;
    if(!isSlowwalking()){
        if(!block_set7){
            UI.SetValue("Misc", "GENERAL", "Movement", "Accurate walk", accurate_walk_bak);
            block_set7 = true;
        }
        if(UI.IsMenuOpen()){
            accurate_walk_bak = UI.GetValue("Misc", "GENERAL", "Movement", "Accurate walk");
        }
        return;
    }
    if(UI.IsHotkeyActive("Visual", "SELF", "Freecam", "Enable")) return;
    block_set7 = false;
    UI.SetValue("Misc", "GENERAL", "Movement", "Accurate walk", false);
    var slowmotion_speed = GetVal("slowmotion_speed");
    if(GetVal("slowmotion_legbreaker")){
        slowmotion_speed += 10;
    }
    var sSpeed = (slowmotion_speed * (((getVelocity(Entity.GetLocalPlayer()) >= slowmotion_speed) && GetVal("slowmotion_legbreaker")) ? -1 : 1));
    var dir = [0, 0, 0];
    if(Input.IsKeyPressed(0x57)){
        dir[0] += sSpeed;
    }
    if(Input.IsKeyPressed(0x44)){
        dir[1] += sSpeed;
    }
    if(Input.IsKeyPressed(0x41)){
        dir[1] -= sSpeed
    }
    if(Input.IsKeyPressed(0x53)){
        dir[0] -= sSpeed;
    }
    UserCMD.SetMovement(dir);
}

//Standing auto invert
var standingAutoInvert_wait = 0;
var standingAutoInvert_speed = 2;
function standingAutoInvert(){
    if(!GetVal("standing_auto_invert")) return;
    if(!World.GetServerString()) return;
    if(getVelocity(Entity.GetLocalPlayer()) > 3) return;
    if(standingAutoInvert_wait++ === standingAutoInvert_speed){
        UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter");
        standingAutoInvert_wait = 0;
    }
}

//Skeleton on hit and kill
var skeleton_draw_time = 4;
var hitlist = [[], [], []];
function skeletonOnHit(){
    if(!GetVal("skeleton_on_hit")) return;
    var attackerplayer = Entity.GetEntityFromUserID(Event.GetString("attacker"));
    if (attackerplayer == Entity.GetLocalPlayer()){
        var victimplayer = Entity.GetEntityFromUserID(Event.GetString("userid"))
        var color = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "Skeleton Hit Color");
        if (Event.GetInt("health") < 1) {
            color = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "Skeleton Kill Color");
        }
        var hitboxPos = [];
        for (var i = 0; i < 19; i++) {
            var p = Entity.GetHitboxPosition(victimplayer, i);
            hitboxPos.push(p);
        }
        hitlist[0].push(Global.Curtime() + skeleton_draw_time);
        hitlist[1].push(hitboxPos);
        hitlist[2].push(color);
    }
}
function skeletonOnHit2(){
    if (!GetVal("skeleton_on_hit") || hitlist[0].length == 0) return;
    for(var i = 0; i < hitlist[0].length; i++){
        if(Global.Curtime() < hitlist[0][i]){
            skeletonOnHit3(hitlist[1][i], hitlist[2][i]);
        }
        else{
            hitlist[0].splice(i, 1);
            hitlist[1].splice(i, 1);
            hitlist[2].splice(i, 1);
        }
    }
}
function skeletonOnHit3(hitboxPos, color){
    var skelMesh = [
        [0, 1],
        [1, 6],
        [6, 5],
        [5, 4],
        [4, 3],
        [3, 2],
        [2, 7],
        [2, 8],
        [8, 10],
        [10, 12],
        [7, 9],
        [9, 11],
        [6, 15],
        [15, 16],
        [16, 13],
        [6, 17],
        [17, 18],
        [18, 14]
    ];
    for (var i = 0; i < skelMesh.length; i++){
        var p1 = Render.WorldToScreen(hitboxPos[skelMesh[i][0]]);
        var p2 = Render.WorldToScreen(hitboxPos[skelMesh[i][1]]);
        Render.Line(p1[0], p1[1], p2[0], p2[1], color);
    }
}

var mindamage_bak = [0, 0, 0, 0, 0, 0];
var mindamage_override = [0, 0, 0, 0, 0, 0];
var weapon_categories = ["GENERAL", "PISTOL", "HEAVY PISTOL", "SCOUT", "AWP", "AUTOSNIPER"];
for(category in weapon_categories){
    mindamage_bak[category] = UI.GetValue("Rage", weapon_categories[category], "Targeting", "Minimum damage");
}
var block_set20 = false;

//Min damage override on key
function minDamageOverride(){
    if(!GetVal("mindamage")) return;
    if(UI.IsMenuOpen()){
        if(!GetVal("mindamage_advanced")){
            for(mindamage in mindamage_override){
                mindamage_override[mindamage] = GetVal("mindamage_hp");
            }
        }
        else{
            mindamage_override[0] = GetVal("mindamage_hp");
            mindamage_override[1] = GetVal("mindamage_hp_pistol");
            mindamage_override[2] = GetVal("mindamage_hp_revolver");
            mindamage_override[3] = GetVal("mindamage_hp_scout");
            mindamage_override[4] = GetVal("mindamage_hp_awp");
            mindamage_override[5] = GetVal("mindamage_hp_auto");
        }
    }
    if(UI.IsHotkeyActive('Script items', 'Min damage override') || autopeek_active){
        block_set20 = false;
        for(category in weapon_categories){
            UI.SetValue("Rage", weapon_categories[category], "Targeting", "Minimum damage", mindamage_override[category]);
        }
    }
    else{
        if(!block_set20){
            for(category in weapon_categories){
                UI.SetValue("Rage", weapon_categories[category], "Targeting", "Minimum damage", mindamage_bak[category]);
            }
            block_set20 = true;
        }
        if(UI.IsMenuOpen()){
            for(category in weapon_categories){
                mindamage_bak[category] = UI.GetValue("Rage", weapon_categories[category], "Targeting", "Minimum damage");
            }
        }
    }
}

//Trail
var trails = [];
var trail_rgb_speed = 15;
var trail_timer = 200;
function trail(){
    if(!GetVal("trail")) return;
    local = Entity.GetLocalPlayer();
    if (Entity.IsValid(local)){
        var position = Entity.GetHitboxPosition(local, 6);
        if(Array.isArray(position)){
            trails.push({remove:Global.Tickcount() + trail_timer, location: position});

            trails.forEach(function(x, y){
                var location = trails[y]["location"];
                var rainbow = rgb(trail_rgb_speed / 500);
                rainbow[3] = 50;
                if (!GetValue("Trail rainbow")) {
                    var color = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "Trail");
                    rainbow = color;
                }
                var position = Render.WorldToScreen([location[0], location[1], location[2]-50.0]);
                Render.FilledRect(position[0], position[1], 15, 15, rainbow);

                var time = Global.Tickcount();
                if (trails[y]["remove"] <= time){
                    trails.splice(y, 1);
                }
            });
        }
    }
}

function rgb(speed) {
    var timer = Global.Tickcount();
    var result = [0, 0, 0, 255];

    result[0] = Math.floor(Math.sin(timer * speed + 0) * 127 + 128);
    result[1] = Math.floor(Math.sin(timer * speed + 2) * 127 + 128);
    result[2] = Math.floor(Math.sin(timer * speed + 4) * 127 + 128);
    return result;
}

function fps_boost(){
    if (GetVal("fps_boost")){
        UI.SetValue("Misc", "GENERAL", "Misc", "Force sv_cheats", true);
        UI.SetValue("Misc", "GENERAL", "Misc", "Hidden cvars", true);
        Convar.SetString("r_shadows", "0");
        Convar.SetString("cl_csm_static_prop_shadows", "0");
        Convar.SetString("cl_csm_shadows", "0");
        Convar.SetString("cl_csm_world_shadows", "0");
        Convar.SetString("cl_foot_contact_shadows", "0");
        Convar.SetString("cl_csm_viewmodel_shadows", "0");
        Convar.SetString("cl_csm_rope_shadows", "0");
        Convar.SetString("cl_csm_sprite_shadows", "0");
        Convar.SetString("cl_csm_world_shadows_in_viewmodelcascade", "0");
        Convar.SetString("cl_csm_translucent_shadows", "0");
        Convar.SetString("cl_csm_entity_shadows", "0");
        Convar.SetString("violence_hblood", "0");
        Convar.SetString("r_3dsky", "0");
        Convar.SetString("r_drawdecals", "0");
        Convar.SetString("r_drawrain", "0");
        Convar.SetString("r_drawropes", "0");
        Convar.SetString("r_drawsprites", "0");
        Convar.SetString("fog_enable_water_fog", "0");
        Convar.SetString("@panorama_disable_blur", "1");
        Convar.SetString("dsp_slow_cpu", "1");
        Convar.SetString("cl_disable_ragdolls", "1");
        Convar.SetString("mat_disable_bloom", "1");
    }
    else{
        Convar.SetString("r_shadows", "1");
        Convar.SetString("cl_csm_static_prop_shadows", "1");
        Convar.SetString("cl_csm_shadows", "1");
        Convar.SetString("cl_csm_world_shadows", "1");
        Convar.SetString("cl_foot_contact_shadows", "1");
        Convar.SetString("cl_csm_viewmodel_shadows", "1");
        Convar.SetString("cl_csm_rope_shadows", "1");
        Convar.SetString("cl_csm_sprite_shadows", "1");
        Convar.SetString("cl_csm_world_shadows_in_viewmodelcascade", "1");
        Convar.SetString("cl_csm_translucent_shadows", "1");
        Convar.SetString("cl_csm_entity_shadows", "1");
        Convar.SetString("violence_hblood", "1");
        Convar.SetString("r_3dsky", "1");
        Convar.SetString("r_drawdecals", "1");
        Convar.SetString("r_drawrain", "1");
        Convar.SetString("r_drawropes", "1");
        Convar.SetString("r_drawsprites", "1");
        Convar.SetString("fog_enable_water_fog", "1");
        Convar.SetString("@panorama_disable_blur", "0");
        Convar.SetString("dsp_slow_cpu", "0");
        Convar.SetString("cl_disable_ragdolls", "0");
        Convar.SetString("mat_disable_bloom", "0");
    }
}

//Transparent walls and props when nading
var block_set5 = 0;
var wallTransparencyBak = UI.GetValue("Visual", "Map", "Wall transparency");
var propTransparencyBak = UI.GetValue("Visual", "Map", "Prop transparency");
function transparencyOnNade(){
    if(!GetVal("transparency_on_nade")) return;
    var weapon = getWeaponName();
    local = Entity.GetLocalPlayer();
    if((weapon.indexOf("nade") !== -1 /*|| weapon === "flashbang"*/  || weapon === "molotov") && weapon !== "decoy" && Entity.IsAlive(local) && Input.IsKeyPressed(0x01)){
        block_set5 = 0;
        UI.SetValue("Visual", "Map", "Wall transparency", (GetValue("Wall transparency") / 100));
        UI.SetValue("Visual", "Map", "Prop transparency", (GetValue("Prop transparency") / 100));
    }
    else{
        if(block_set5 < 3){
            UI.SetValue("Visual", "Map", "Wall transparency", wallTransparencyBak);
            UI.SetValue("Visual", "Map", "Prop transparency", propTransparencyBak);
            block_set5++;
        }
        if(UI.IsMenuOpen()){
            propTransparencyBak = UI.GetValue("Visual", "Map", "Prop transparency");
            wallTransparencyBak = UI.GetValue("Visual", "Map", "Wall transparency");
        }
    }
}

//Force safe point on DT
function safePointOnDT(){
    if(!GetVal("dt_safepoint")) return;
    if(!exploitsActive("dt")) return;
    enemies = Entity.GetEnemies();
    for(i = 0; i < enemies.length; i++) {
        if (!Entity.IsValid(enemies[i])) continue;
        if (!Entity.IsAlive(enemies[i])) continue;
        Ragebot.ForceTargetSafety(enemies[i]);
    }
}

//Svastica crosshair
//The best function in otc3 cord
var cnt = 0;
function betterCrosshair(){
    if(!GetVal("better_crosshair")) return;
    local = Entity.GetLocalPlayer();
    if(!local || !Entity.IsValid(local)) return;
    if(betterScopeActive) return;
    var scr = Render.GetScreenSize();
    scr[0]/=2;
    scr[1]/=2;
  
    var col = UI.GetColor("Script Items", "Better crosshair");
    if(GetValue("Better crosshair rainbow")){
        var coll = hsv2rgb(cnt * .002,1,1);
        col = [coll.r,coll.g,coll.b,col[3]];
    }
    var range = GetValue("Better crosshair length");
    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);
    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);
    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);
    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() * ((GetValue("Better crosshair speed") / 3)*100);
}

//Hitmarker
var hitShots = [];
const hitgroup_to_hitbox = {1: 0, 2: 5, 3: 2, 4: 13, 5: 14, 6: 12, 7: 11};
function hitShotsHandle(){
    if (!Entity.IsAlive(Entity.GetLocalPlayer())) return;
    var size = 7;
    var disableTime = 250;
    for(shot in hitShots){
        var w2s = Render.WorldToScreen(hitShots[shot][1]);
        var time = hitShots[shot][2];
        if(time > disableTime){
            hitShots.splice(shot, 1);
            continue;
        }
        var screenX = w2s[0];
        var screenY = w2s[1];
        var alpha = 255 * (1 - (time / disableTime));
        if(GetVal("hitmarker")){
            var color = UI.GetColor("Script items", "Hitmarker");
            color[3] = alpha;
            if(GetValue("Hitmarker in screen center")){
                var screenX = screen_size[0] / 2;
                var screenY = screen_size[1] / 2;
            }
            Render.Line(screenX + size, screenY + size, screenX + (size / 3), screenY + (size / 3), color);
            Render.Line(screenX + size, screenY - size, screenX + (size / 3), screenY - (size / 3), color);
            Render.Line(screenX - size, screenY - size, screenX - (size / 3), screenY - (size / 3), color);
            Render.Line(screenX - size, screenY + size, screenX - (size / 3), screenY + (size / 3), color);
        }
        if(GetVal("damage_marker")){
            var color = UI.GetColor("Script items", "Damage marker");
            screenY = screenY - 16 - (time);
            screenX = screenX - 15 + hitShots[shot][3];
            color[3] = alpha;
            var font = Render.AddFont("Verdana", 8, 600);
            var damage = hitShots[shot][0].toString();
            if(GetValue("Damage marker outline")){
                Render.StringCustom(screenX + 1, screenY, 0, damage, [0, 0, 0, alpha], font);
                Render.StringCustom(screenX - 1, screenY, 0, damage, [0, 0, 0, alpha], font);
                Render.StringCustom(screenX, screenY + 1, 0, damage, [0, 0, 0, alpha], font);
                Render.StringCustom(screenX, screenY - 1, 0, damage, [0, 0, 0, alpha], font);
            }
            Render.StringCustom(screenX, screenY, 0, damage, color, font);
        }
        hitShots[shot][2]++;
    }
}
function addHitShot(){
    if(!GetVal("hitmarker") && !GetVal("damage_marker")) return;
    var uid = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    if (Entity.GetEntityFromUserID(Event.GetString("attacker")) == Entity.GetLocalPlayer()) {
        hitShots.push([Event.GetInt("dmg_health"), Entity.GetHitboxPosition(uid, hitgroup_to_hitbox[Event.GetInt("hitgroup")] != undefined ? hitgroup_to_hitbox[Event.GetInt("hitgroup")] : 3), 0, Math.floor(Math.random() * Math.floor(30))]);
    }
}

//Aspect ratio
function aspectRatio(){
    Convar.SetString("r_aspectratio", (GetVal("aspect_ratio") / 100).toString());
}

//Autostrafe fix
function autostrafeFix(){
    if(!GetVal("autostrafe_fix")) return;
    var speed = 2;
    var velocity = parseFloat(getVelocity(Entity.GetLocalPlayer()));
    UI.SetValue("Misc", "GENERAL", "Movement", "Turn speed", (velocity / 1.5) / speed);
}

//World color, bloom and FX
var nightmode_value = 0.1;
var nightmode_modelBrightness = 1.5;
function worldColor(){
    var props = 0;
    if(!Entity.GetLocalPlayer()) return;
    if(GetVal("world_color")){
        var worldColor = UI.GetColor("Script items", "World color");
        Convar.SetFloat('mat_ambient_light_r', worldColor[0] / 100);
        Convar.SetFloat('mat_ambient_light_g', worldColor[1] / 100);
        Convar.SetFloat('mat_ambient_light_b', worldColor[2] / 100);
    }
    else{
        Convar.SetFloat('mat_ambient_light_r', 0);
        Convar.SetFloat('mat_ambient_light_g', 0);
        Convar.SetFloat('mat_ambient_light_b', 0);   
    }
    var worldBrightness = GetVal("world_brightness");
    if(worldBrightness < 0){
        worldBrightness = 1 / Math.abs(worldBrightness / 2);
    }
    if(Convar.GetString("mat_force_tonemap_scale") != worldBrightness){
        Convar.SetString("mat_force_tonemap_scale", worldBrightness + "");
    }
}
function worldColor2(entity){
    var custom_bloom = /*(GetVal("bloom_scale") !== 0)*/true;
    var props = 0;
    if(props == 0){
        Entity.SetProp(entity, 'CEnvTonemapController', 'm_bUseCustomAutoExposureMin', custom_bloom);
        Entity.SetProp(entity, 'CEnvTonemapController', 'm_bUseCustomAutoExposureMax', custom_bloom);
        Entity.SetProp(entity, 'CEnvTonemapController', 'm_bUseCustomBloomScale', custom_bloom);
        props = 1;
    }
    if(props == 1){
        //Entity.SetProp(entity, 'CEnvTonemapController', 'm_flCustomAutoExposureMin', GetVal("world_brightness"));
        //Entity.SetProp(entity, 'CEnvTonemapController', 'm_flCustomAutoExposureMax', GetVal("world_brightness"));
        if(custom_bloom){
            Entity.SetProp(entity, 'CEnvTonemapController', 'm_flCustomBloomScale', GetVal("bloom_scale") / 10);
        }
    }
    var nightmodeAddition = (GetVal("darker_nightmode")) ? nightmode_modelBrightness : 0;
    Convar.SetFloat("r_modelAmbientMin", GetVal("model_brightness") / 10 + nightmodeAddition);
}

//Matchmaking FD
var fd_choke = [7, 4, 11, 12];
var fd_min_amount = [86, 92, 86, 100];
var fd_max_amount = [48, 52, 14, 0];
var fd_precision = [12, 12, 18, 20];
var doubletap_bak = false;
var hideshots_bak = false;
var duck_bak = false;
var fakelag_state_bak = UI.GetValue("Anti-Aim", "Fake-Lag", "Enabled");
var fakelag_limit_bak = UI.GetValue("Anti-Aim", "Fake-Lag", "Limit");
var fakelag_jitter_bak = UI.GetValue("Anti-Aim", "Fake-Lag", "Jitter");
var fakelag_triggers_bak = UI.GetValue("Anti-Aim", "Fake-Lag", "Triggers");
var fakelag_trigger_limit_bak = UI.GetValue("Anti-Aim", "Fake-Lag", "Trigger limit");
//var legitaa_state_bak = UI.GetValue("Anti-Aim", "Legit Anti-Aim", "Enabled");
//var fakeangles_state_bak = UI.GetValue("Anti-Aim", "Fake angles", "Enabled");
var fake_desync_bak = UI.GetValue("Anti-Aim", "Fake angles", "Fake desync");
var lby_bak = UI.GetValue("Anti-Aim", "Fake angles", "LBY mode");
var extend_angle_bak = UI.GetValue("Anti-Aim", "Legit Anti-Aim", "Extend angle");
var block_set6 = false;
var set_lock_camera = false;
function mmFD(){
    if(!GetVal("mm_fd")) return;
    UI.SetValue("Misc", "GENERAL", "Movement", "Fast crouch", true);
    local = Entity.GetLocalPlayer();
    var amount = Entity.GetProp(local, "CBasePlayer", "m_flDuckAmount") * 100;
    var fd_type = GetValue("Matchmaking FD type");
    if(UI.IsHotkeyActive("Script items", "Matchmaking FD")){
        var precision = /*Math.round(2 + clamp(10 - (fd_max_amount[fd_type] / 10), 0, 12))*/ fd_precision[fd_type];
        mmFDActive = true;
        var lock_camera = UI.IsHotkeyActive("Visual", "WORLD", "Thirdperson") && getVelocity(local) < 10 && GetValue("Matchmaking FD lock camera");
        var opposite_lby = GetValue("Matchmaking FD opposite LBY") && !GetValue("Lowdelta on FD");
        /*var weapons = Entity.GetProp(local, "CBasePlayer", "m_hMyWeapons");
        Cheat.Print(typeof weapons + "\n");
        var clip = weapon = Entity.GetProp(local, "CBaseEntity", "m_iAmmo");
        Cheat.Print(clip + "\n");*/
        block_set6 = false;
        duck_bak = true;
        if(exploitsActive("dt")){
            doubletap_bak = true;
            UI.ToggleHotkey("Rage", "GENERAL", "Exploits", "Doubletap");
        }
        if(exploitsActive("hs")){
            hideshots_bak = true;
            UI.ToggleHotkey("Rage", "GENERAL", "Exploits", "Hide shots");
        }

        //UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset", 0);
        UI.SetValue("Anti-Aim", "Fake-Lag", "Limit", fd_choke[fd_type] + ((opposite_lby) ? 1 : 0));
        UI.SetValue("Anti-Aim", "Fake-Lag", "Jitter", 0);
        UI.SetValue("Anti-Aim", "Fake-Lag", "Triggers", /*(1 << 2) + (1 << 7) + */0);
        UI.SetValue("Anti-Aim", "Fake-Lag", "Trigger limit", 0);
        UI.SetValue("Anti-Aim", "Fake angles", "Fake desync", false);
        UI.SetValue("Anti-Aim", "Fake angles", "LBY mode", opposite_lby);
        UI.GetValue("Anti-Aim", "Legit Anti-Aim", "Extend angle", opposite_lby);
        UI.SetValue("Anti-Aim", "Fake-Lag", "Trigger limit", 0);
        //UI.SetValue("Anti-Aim", "Legit Anti-Aim", "Enabled", false);
        //UI.SetValue("Anti-Aim", "Fake angles", "Enabled", false);
        
        if(amount >= fd_min_amount[fd_type] - precision){
            Convar.SetString('cl_lock_camera', '1');
            var fl_st = UI.GetValue("Anti-Aim", "Fake-Lag", "Enabled");
            //UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 21);
            fakelag(false);

            if(fl_st == false){
                if(!Input.IsKeyPressed(17)) Cheat.ExecuteCommand("-duck");
            }
            else{
                return;
            }
        }
        if(amount > fd_min_amount[fd_type] - precision && amount < fd_max_amount[fd_type] + precision){
            if(lock_camera)
                Convar.SetString('cl_lock_camera', '1');
            //UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 0);
            fakelag(true);
        }
        if(amount <= fd_max_amount[fd_type] + precision){
            if(lock_camera){
                if(!set_lock_camera){
                    Convar.SetString('cl_lock_camera', '0');
                    set_lock_camera = true;
                }
                else{
                    Convar.SetString('cl_lock_camera', '1');
                    set_lock_camera = false;
                }
            }
            //UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 0);
            fakelag(true);
            Cheat.ExecuteCommand("+duck");
        }
        else{
            if(lock_camera){
                if(fd_max_amount[fd_type] - amount <= 42){
                    if(!set_lock_camera){
                        //Convar.SetString('cl_lock_camera', '0');
                        set_lock_camera = true;
                    }
                    else{
                        Convar.SetString('cl_lock_camera', '1');
                        set_lock_camera = false;
                    }
                }
            }
            else{
                Convar.SetString('cl_lock_camera', '0');
            }
        }
    }
    else{
        mmFDActive = false;
        if(!block_set6 && !legitAAactive){
            Convar.SetString('cl_lock_camera', '0');
            fakelag(fakelag_state_bak);
            //UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", yaw_bak);
            //UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset", jitter_bak);
            UI.SetValue("Anti-Aim", "Fake-Lag", "Limit", fakelag_limit_bak);
            UI.SetValue("Anti-Aim", "Fake-Lag", "Jitter", fakelag_jitter_bak);
            UI.SetValue("Anti-Aim", "Fake-Lag", "Triggers", fakelag_triggers_bak);
            UI.SetValue("Anti-Aim", "Fake-Lag", "Trigger limit", fakelag_trigger_limit_bak);
            UI.SetValue("Anti-Aim", "Fake angles", "Fake desync", fake_desync_bak);
            UI.SetValue("Anti-Aim", "Fake angles", "LBY mode", lby_bak);
            UI.SetValue("Anti-Aim", "Legit Anti-Aim", "Extend angle", extend_angle_bak);
            //UI.SetValue("Anti-Aim", "Legit Anti-Aim", "Enabled", legitaa_state_bak);
            //UI.SetValue("Anti-Aim", "Fake angles", "Enabled", fakeangles_state_bak);
            Convar.SetString('cl_lock_camera', '0');
            block_set6 = true;
        }
        if(!lowdelta_active && !legitAAactive && UI.IsMenuOpen()){
            //yaw_bak = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset");
            //jitter_bak = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset");
            if(!noFakeLagOnRevolver){
                fakelag_state_bak = UI.GetValue("Anti-Aim", "Fake-Lag", "Enabled");
            }
            fake_desync_bak = UI.GetValue("Anti-Aim", "Fake angles", "Fake desync");
            lby_bak = UI.GetValue("Anti-Aim", "Fake angles", "LBY mode");
            extend_angle_bak = UI.GetValue("Anti-Aim", "Legit Anti-Aim", "Extend angle");
            fakelag_limit_bak = UI.GetValue("Anti-Aim", "Fake-Lag", "Limit");
            fakelag_jitter_bak = UI.GetValue("Anti-Aim", "Fake-Lag", "Jitter");
            fakelag_triggers_bak = UI.GetValue("Anti-Aim", "Fake-Lag", "Triggers");
            fakelag_trigger_limit_bak = UI.GetValue("Anti-Aim", "Fake-Lag", "Trigger limit");
            //legitaa_state_bak = UI.GetValue("Anti-Aim", "Legit Anti-Aim", "Enabled");
            //fakeangles_state_bak = UI.GetValue("Anti-Aim", "Fake angles", "Enabled");
        }
        if(doubletap_bak == true){
            UI.ToggleHotkey("Rage", "GENERAL", "Exploits", "Doubletap");
            doubletap_bak = false;
        }
        if(hideshots_bak == true){
            UI.ToggleHotkey("Rage", "GENERAL", "Exploits", "Hide shots");
            hideshots_bak = false;
        }
        if(duck_bak == true){
            if(!Input.IsKeyPressed(17)) Cheat.ExecuteCommand("-duck");
            duck_bak = false;
        }
    }
}

//Effect on kill
var effect_alpha = 0;
var effect_size = 0;
var effect_duration = 3;
function effectOnKill(){
    if(!GetVal("effect_on_kill")) return;
    if (effect_alpha === 0)
        return;

    const inc_alpha = ((1 / effect_duration) * Global.Frametime()) * 255
    const inc_size = ((1 / effect_duration) * Global.Frametime()) * 360

    effect_alpha = clamp(effect_alpha - inc_alpha, 0, 255);
    effect_size = clamp(effect_size - inc_size, 0, 360);

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

    Render.GradientRect(0, 0, x, effect_size, 0, [128, 195, 255, effect_alpha], [128, 195, 255, 0]);
    Render.GradientRect(0, y - effect_size, x, effect_size, 0, [128, 195, 255, 0], [128, 195, 255, effect_alpha]);
    Render.GradientRect(x - effect_size, 0, effect_size, y, 1, [128, 195, 255, 0], [128, 195, 255, effect_alpha]);
    Render.GradientRect(0, 0, effect_size, y, 1, [128, 195, 255, effect_alpha], [128, 195, 255, 0]);
}
function effectOnKill2(){
    if(!GetVal("effect_on_kill")) return;
    const attacker = Entity.GetEntityFromUserID(Event.GetInt("attacker"));
    const userid = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    local = Entity.GetLocalPlayer();
    if(attacker === local && userid != local){
        effect_alpha = 100;
        effect_size = 150;
    }
}

//Alternative fakelag
var fakelag_tickcount = 0;
var fakelag_flip = false;
function alternativeFakelag() {
    if(!GetVal("alternative_fakelag")) return;
    if(GetVal("mm_fd") && UI.IsHotkeyActive("Script items", "Matchmaking FD")) return;
    UI.SetValue("Anti-Aim", "Fake-Lag", "Jitter", 0);
    //UI.SetValue("Anti-Aim", "Fake-Lag", "Triggers", (1 << 2) + (1 << 7));
    //UI.SetValue("Anti-Aim", "Fake-Lag", "Trigger limit", 7);
    var fakelag_1 = 3;
    var fakelag_2 = GetVal("alternative_limit");
    if (fakelag_tickcount >= fakelag_2 && !fakelag_flip) {
        fakelag_flip = true;
        fakelag_tickcount = 0
    };
    if (fakelag_tickcount >= fakelag_1 && fakelag_flip) {
        fakelag_flip = false;
        fakelag_tickcount = 0
    };
    UI.SetValue('Anti-Aim', 'Fake-Lag', 'Limit', !fakelag_flip ? fakelag_2 : 0);
    fakelag_tickcount++
}
function alternativeFakelag2(){
    fakelag_tickcount = 0;
}

//Prefer baim on DT
function preferBaimOnDT(){
    if(!GetVal("prefer_baim_on_dt")) return;
    if(exploitsActive("dt") && Exploit.GetCharge() === 1){
        UI.SetValue("Rage", "AUTO", "Accuracy", "Prefer body aim", true);
    }
    else{
        UI.SetValue("Rage", "AUTO", "Accuracy", "Prefer body aim", false);
    }   
}

//Doubletap boost
function doubletapBoost(){
    if(!GetVal("doubletap_boost")){
        Exploit.EnableRecharge();
        return;
    };
    var gamerules = Entity.GetGameRulesProxy();
    var is_scoped = Entity.GetProp(Entity.GetLocalPlayer(), 'CCSPlayer', 'm_bIsScoped');
    var boost_type = GetValue("Doubletap boost");
    var charge = Exploit.GetCharge();
    (charge != 1) ? Exploit.EnableRecharge() : Exploit.DisableRecharge();
    if(!Entity.GetProp(gamerules, "CCSGameRulesProxy", "m_bIsValveDS") && GetVal("doubletap_boost")){
        switch(boost_type){
            case 0:
                if(can_shift_shot(14) && charge != 1){
                    Exploit.DisableRecharge();
                    Exploit.Recharge();
                }
                break;
            case 1:
                if(can_shift_shot(5) && charge != 1){
                    Exploit.DisableRecharge();
                    Exploit.Recharge();
                }
                break;
            case 2:
                if(getWeaponName() === "ssg08"){
                    Exploit.DisableRecharge();
                    if(can_shift_shot(16) && charge != 1){
                        Exploit.DisableRecharge();
                        Exploit.Recharge();
                    }
                    break;
                }
                if(can_shift_shot(12) && charge != 1){
                    Exploit.DisableRecharge();
                    Exploit.Recharge();
                }
                if(isSlowwalking()){
                    if (can_shift_shot(10) && charge != 1){
                        Exploit.DisableRecharge();
                        Exploit.Recharge();
                    }
                }
                break;
            case 3:
                if(getWeaponName() === "ssg08"){
                    Exploit.DisableRecharge();
                    if(can_shift_shot(16) && charge != 1){
                        Exploit.DisableRecharge();
                        Exploit.Recharge();
                    }
                    break;
                }
                if(can_shift_shot(10) && charge != 1){
                    Exploit.DisableRecharge();
                    Exploit.Recharge();
                }
                if(isSlowwalking()){
                    if (can_shift_shot(10) && charge != 1){
                        Exploit.DisableRecharge();
                        Exploit.Recharge();
                    }
                }
                break;
        }
    }
}

//Zoom fix
function zoomFix(){
    if (Cheat.FrameStage() == 5) {
        var zoom_sens = Convar.GetFloat("zoom_sensitivity_ratio_mouse");
        if (GetVal("zoom_fix")) {
            var zoom_current_sens = Convar.GetFloat("sensitivity");
            var zoom_fov = UI.GetValue("Visual", "WORLD", "View", "Field of view");
            var fixed_zoom_sens = zoom_fov / 100 * zoom_current_sens;
            if (zoom_sens != fixed_zoom_sens) {
                Cheat.ExecuteCommand("zoom_sensitivity_ratio_mouse " + fixed_zoom_sens);
                Cheat.ExecuteCommand("zoom_sensitivity_ratio_joystick " + fixed_zoom_sens);
            }
        }
        else{
            if(zoom_sens != 1.0){
                Cheat.ExecuteCommand("zoom_sensitivity_ratio_mouse 1");
                Cheat.ExecuteCommand("zoom_sensitivity_ratio_joystick 1");
            }
        }
    }
}

//Rainbow bar
var rainbow_bar_speed = 0.1;
function rainbowBar(){
    if(!GetVal("rainbow_bar")) return;
    local = Entity.GetLocalPlayer();
    if(!local || !Entity.IsValid(local)) return;

    var screen_width = Math.round(Global.GetScreenSize()[0]);
    var bar_type = GetValue("Rainbow bar");

    var rgb = hsv2rgb(Global.Realtime() * rainbow_bar_speed, 1, 1);
    switch(bar_type){
        case 0:
            Render.FilledRect(0, 0, screen_width, 4, [rgb.r, rgb.g, rgb.b, 255]);
            break;
        case 1:
            Render.GradientRect(0, 0, screen_width / 2, 4, 1, [rgb.g, rgb.b, rgb.r, 255], [rgb.r, rgb.g, rgb.b, 255]);
            Render.GradientRect(screen_width / 2, 0, screen_width / 2, 4, 1, [rgb.r, rgb.g, rgb.b, 255], [rgb.b, rgb.r, rgb.g, 255]);
            break;
    }
}

//Ideal yaw
function idealYaw(){
    if(!GetVal("ideal_yaw")) return;
    if(lastHitTime + idealYawDelay > Global.Curtime()){
        return;
    }
    UI.SetValue("Anti-Aim", "Fake angles", "Hide real angle", true);
    const mode = 0;
    local = Entity.GetLocalPlayer();
    const origin = VectorNew(Entity.GetRenderOrigin(local));
    var yaw = Local.GetViewAngles()[1];
    var data = {left: 0, right: 0};
    for (var r = yaw - 90; r <= yaw + 90; r += 30){
        if (r === yaw)
            continue;
        const rad = degree_to_radian(r);
        const point = VectorOperate(
            origin,
            VectorNew([
                256 * Math.cos(rad),
                256 * Math.sin(rad),
                0
            ]),
            "+"
        );
        const line = Trace.Line(local, VectorToArray(origin), VectorToArray(point));
        const side = r < yaw ? "left" : "right";
        data[side] += line[1];
    }
    data.left /= 3;
    data.right /= 3;
    if (data.left > data.right){
        update_anti_aim_state(_mode === 0 ? 0 : 1);
        return;
    }
    update_anti_aim_state(_mode === 0 ? 1 : 0)
}

//Nade circle
var he_positions = [];
var grenadeData = [];
var fadeOutSpeed = 5;
var sizeSpeed = 7;
function nadeCircle(){
    if(!GetVal("nade_circle")) return;
    for (var i = 0; i < he_positions.length; i++) {
        var circleColor = UI.GetColor("Script items", "HE circle");
        var wordLoc = he_positions[i]; 
        var renderOrigin = Entity.GetRenderOrigin(Entity.GetLocalPlayer());
        var screenLoc = Render.WorldToScreen(wordLoc);
      
        var currentGrenadeData = grenadeData[i];

        var a = wordLoc[0] - renderOrigin[0];
        var b = wordLoc[1] - renderOrigin[1];
        var c = wordLoc[2] - renderOrigin[2];
      
        currentGrenadeData[0] += (sizeSpeed / 4) * 3 + ((sizeSpeed / 4) * (Math.sqrt(a * a + b * b + c * c) / 500)); //i know im genius :)
        currentGrenadeData[1] -= fadeOutSpeed * (Math.sqrt(a * a + b * b + c * c) / 250); //auto size mmmm

        //Fixing past braindead dev mistakes
        if(currentGrenadeData[1] < 0) currentGrenadeData[1] = 0;

        grenadeData[i] = currentGrenadeData;

        if (currentGrenadeData[1] < 1) {
            grenadeData.shift(i, 1);
            he_positions.shift(i, 1);
        }

        if (screenLoc[2] == 0) {
            return;
        }
      
        Render.Circle(screenLoc[0], screenLoc[1], currentGrenadeData[0], [circleColor[0], circleColor[1], circleColor[2], currentGrenadeData[1]]);
        Render.Circle(screenLoc[0], screenLoc[1], currentGrenadeData[0] + 1, [circleColor[0], circleColor[1], circleColor[2], currentGrenadeData[1]]);
    }
}

//Clantag on peek
function clantagOnPeek(){
    if(!GetVal("clantag_on_peek")) return;
    if(exploitsActive("all")) return;
    var enemies = Entity.GetEnemies();
    var local_pos = ExtrapolateTick(15);
    for(var i = 0; i < enemies.length;i++){
        var enemy = enemies[i];
        if (!Entity.IsAlive(enemy) || Entity.IsDormant(enemy) || !Entity.IsValid(enemy)) continue;
        var pos = Entity.GetHitboxPosition(enemy, 2);
        var result = Trace.Bullet(Entity.GetLocalPlayer(), enemy, local_pos, pos);
        if(result[1] > 1){ // aka damage
            Local.SetClanTag("otc3 cord");
            return;
        }
    }
}

//Buy list made by @zxsleebu btw
var buy_list_width = 200;
var buy_list_hide = Globals.Curtime() + 20;
UI.AddSliderInt(name_text + "_buy_list_x", 0,screen_size[0]);
UI.AddSliderInt(name_text + "_buy_list_y", 0,screen_size[1]);
UI.SetEnabled("Script items", name_text + "_buy_list_x", false);
UI.SetEnabled("Script items", name_text + "_buy_list_y", false);
var buy_list_x = UI.GetValue("Script items", name_text + "_buy_list_x") || screen_size[0] - buy_list_width;
var buy_list_y = UI.GetValue("Script items", name_text + "_buy_list_y") || (screen_size[1] / 2) - (list_height / 2);
var buys = {};
var weapon_icons = {
    "weapon_deagle": "a",
    "weapon_elite": "b",
    "weapon_fiveseven": "c",
    "weapon_glock": "d",
    "weapon_ak47": "e",
    "weapon_aug": "f",
    "weapon_awp": "g",
    "weapon_famas": "h",
    "weapon_m249": "i",
    "weapon_g3sg1": "j",
    "weapon_galilar": "k",
    "weapon_m4a1": "l",
    "weapon_m4a1_silencer": "m",
    "weapon_mac10": "n",
    "weapon_hkp2000": "o",
    "weapon_mp5sd": "p",
    "weapon_ump45": "q",
    "weapon_xm1014": "r",
    "weapon_bizon": "s",
    "weapon_mag7": "t",
    "weapon_negev": "u",
    "weapon_sawedoff": "v",
    "weapon_tec9": "w",
    "weapon_taser": "x",
    "weapon_p250": "y",
    "weapon_mp7": "z",
    "weapon_mp9": "A",
    "weapon_nova": "B",
    "weapon_p90": "C",
    "weapon_scar20": "D",
    "weapon_sg556": "E",
    "weapon_ssg08": "F",
    "weapon_flashbang": "H",
    "weapon_hegrenade": "I",
    "weapon_smokegrenade": "J",
    "weapon_molotov": "K",
    "weapon_decoy": "L",
    "weapon_incgrenade": "M",
    "weapon_usp_silencer": "P",
    "weapon_cz75a": "Q",
    "weapon_revolver": "R",
    "item_assaultsuit": "S",
    "item_kevlar": "T",
    "item_defuser": "U",
};
var needToClearBuylist = false;
var buy_list_hide = 0;
function buyList(){
    if(!GetVal("buy_list")) return;
    local = Entity.GetLocalPlayer();
    var gamerules = Entity.GetGameRulesProxy();
    if(!local || !Entity.IsValid(local) && !UI.IsMenuOpen()) return;
    if(Globals.Curtime() >= buy_list_hide && needToClearBuylist){
        clearBuyList();
    }
    var add_height = 0;
    Render.GradientRect(buy_list_x, buy_list_y, buy_list_width / 2, 2, 1, [218, 160, 87, 255], [255, 223, 150, 255]);
    Render.GradientRect(buy_list_x + buy_list_width / 2, buy_list_y, buy_list_width / 2, 2, 1, [255, 223, 150, 255], [218, 160, 87, 255]);
    Render.FilledRect(buy_list_x, buy_list_y + 2, buy_list_width, list_height - 2, [38, 40, 52, 90]);
    list_font = Render.AddFont("Segoe UI", 8, 900);
    var text_size = Render.TextSizeCustom("buy list", list_font);
    renderShadowText(buy_list_x + (buy_list_width / 2) - (text_size[0] / 2), buy_list_y + 2, "buy list", list_text_color, list_font);
    //Cheat.Print(Entity.GetProp(gamerules, "CCSGameRulesProxy", "m_bWarmupPeriod") + "\n");
    //if(Entity.GetProp(gamerules, "CCSGameRulesProxy", "m_bWarmupPeriod") == "true") return;
    var players = Object.keys(buys);
    for(i = 0; i < players.length; i++){
        var add_width = 0;
        var name = Entity.GetName(Entity.GetEntityFromUserID(players[i]));
        var name_size = Render.TextSizeCustom(name, list_font);
        renderShadowText(buy_list_x + 3, buy_list_y + list_height + add_height, name, list_text_color, list_font);
        for(a = 0; a < buys[players[i]].length; a++){
            var weapon = buys[players[i]][a];
            Render.String(buy_list_x + 2 + add_width, buy_list_y + list_height + add_height + 15, 0, weapon_icons[weapon], [0, 0, 0, 100], 5);
            Render.String(buy_list_x + 1 + add_width, buy_list_y + list_height + add_height + 14, 0, weapon_icons[weapon], list_text_color, 5);
            add_width += Render.TextSize(weapon_icons[weapon], 5)[0] - 1;
        }
        add_height += 32;
    }
}
function moveBuyList(){
    if(!GetVal("buy_list")) return;
    if(!UI.IsMenuOpen()) return;
    if(is_moving) return;
    cursor_pos = Input.GetCursorPosition();
    if(!Input.IsKeyPressed(0x01)){
        buy_list_is_moving = false;
        buy_list_old_cursor = cursor_pos;
    }
    if((cursor_pos[0] >= buy_list_x && cursor_pos[0] <= buy_list_x + buy_list_width && cursor_pos[1] >= buy_list_y && cursor_pos[1] <= buy_list_y + list_height) || (buy_list_is_moving)){
        buy_list_is_moving = true;
        buy_list_x = clamp(cursor_pos[0] - buy_list_old_cursor[0] + buy_list_x, 0, screen_size[0] - buy_list_width);
        buy_list_y = clamp(cursor_pos[1] - buy_list_old_cursor[1] + buy_list_y, 0, screen_size[1] - list_height);
        buy_list_old_cursor = cursor_pos;
        UI.SetValue("Script items", name_text + "_buy_list_x", buy_list_x);
        UI.SetValue("Script items", name_text + "_buy_list_y", buy_list_y);
    }
}
function addWeaponInBuyList(){
    if(!GetVal("buy_list")) return;

    if(Event.GetInt("team") === Entity.GetProp(Entity.GetLocalPlayer(), "CBaseEntity", "m_iTeamNum")) return;
    var weapon = Event.GetString("weapon");
    var player = Event.GetInt("userid");
    if(player in buys){
        buys[player].push(weapon);
    }
    else{
        buys[player] = [weapon];
    }
}
function clearBuyList(){
    buys = {};
    needToClearBuylist = false;
}
function hideBuyList(){
    needToClearBuylist = true;
    buy_list_hide = Globals.Curtime() + parseInt(Convar.GetString("mp_buytime")/* - Convar.GetString("mp_freezetime")*/) + 10;
}

//Vote revealer
var vote_options = [];
function voteRevealer(){
    if(!GetVal("vote_revealer")) return;
    var entid = Event.GetInt("entityid");
    if(!entid) return;
    var team = Event.GetInt("team");
    var option = Event.GetInt("vote_option");
    var name = Entity.GetName(entid);
    var chTeam = "null";
    switch (team) {
        case 0: chTeam = "[N] "; break; case 1: chTeam = "[S] "; break;
        case 2: chTeam = "[T] "; break; case 3: chTeam = "[CT] "; break;
        default: chTeam = "[UNK] "; break;
    }
    
    var vote = vote_options[option];
    Global.PrintColor([217, 217, 217, 255], "[onetap] \0");
    Global.Print(chTeam + name + " voted " + vote + "\n");
    Global.PrintChat(chTeam + name + " voted " + vote);
}
function onVoteOptions() {
    vote_options[0] = Event.GetString("option1");
    vote_options[1] = Event.GetString("option2");
    vote_options[2] = Event.GetString("option3");
    vote_options[3] = Event.GetString("option4");
    vote_options[4] = Event.GetString("option5");
}

//Agent Changer
var agent_list = {
    "'TwoTimes' McCoy": "CT",
    "Seal Team 6 Soldier": "CT",
    "Buckshot": "CT",
    "Lt. Commander Ricksaw": "CT",
    "Dragomir": "T",
    "Rezan The Ready": "T",
    "Maximus": "T",
    "Blackwolf": "T",
    "The Doctor' Romanov": "T",
    "B Squadron Officer": "CT",
    "3rd Commando Company": "CT",
    "Special Agent Ava": "CT",
    "Operator": "CT",
    "Markus Delrow": "CT",
    "Michael Syfers": "CT",
    "Enforcer": "T",
    "Slingshot": "T",
    "Soldier": "T",
    "The Elite Mr. Muhlik": "T",
    "Ground Rebel": "T",
    "Osiris": "T",
    "Prof. Shahmat": "T"
};
var newAgents = {
    "'Blueberries' Buckshot": "CT",
    "New 'Two Times' McCoy": "CT",
    "'Dead Cold' Jamison": "CT",
    "1st Lieutenant Farlow": "CT",
    "John 'Van Healen' Kask": "CT",
    "Bio-Haz Specialist": "CT",
    "Sergeant Bombson": "CT",
    "Chem-Haz Specialist": "CT",
    "Rezan the Redshirt": "T",
    "Bloody Miami Darryl": "T",
    "Safecracker Voltzmann": "T",
    "Little Kev": "T",
    "Getaway Sally": "T",
    "Number K": "T",
    "Bloody Silent Darryl": "T",
    "Bloody Skullhead Darryl": "T",
    "Bloody Darryl Royale": "T",
    "Bloody Loudmouth Darryl": "T",
    "Street Soldier": "T",
    "New Dragomir": "T"
};
var agentsModels = {
    "'Blueberries' Buckshot": "ctm_st6_variantj",
    "New 'Two Times' McCoy": "ctm_st6_variantl",
    "'Dead Cold' Jamison": "ctm_swat_variante",
    "1st Lieutenant Farlow": "ctm_swat_variantf",
    "John 'Van Healen' Kask": "ctm_swat_variantg",
    "Bio-Haz Specialist": "ctm_swat_varianth",
    "Sergeant Bombson": "ctm_swat_varianti",
    "Chem-Haz Specialist": "ctm_swat_variantj",
    "Rezan the Redshirt": "tm_balkan_variantk",
    "Bloody Miami Darryl": "tm_professional_varf",
    "Safecracker Voltzmann": "tm_professional_varg",
    "Little Kev": "tm_professional_varh",
    "Getaway Sally": "tm_professional_varj",
    "Number K": "tm_professional_vari",
    "Bloody Silent Darryl": "tm_professional_varf1",
    "Bloody Skullhead Darryl": "tm_professional_varf2",
    "Bloody Darryl Royale": "tm_professional_varf3",
    "Bloody Loudmouth Darryl": "tm_professional_varf4",
    "Street Soldier": "tm_phoenix_varianti",
    "New Dragomir": "tm_balkan_variantl"
};
//Fix this if you want ↓↓↓ this code tries to change an agent to new from Broken Fang operation. idk why it throws an error
function agentChanger(){
    if(!GetVal("agent_changer")) return;
    if(Cheat.FrameStage() != 2) return;
    local = Entity.GetLocalPlayer();
    var team = Entity.GetProp(local,"DT_BaseEntity", "m_iTeamNum")
    if(team == 2){ // T
        UI.SetValue("Misc", "SKINS", "Player", "Player model", getAgent("T", GetValue("T agent")));
        //setModel("T", GetValue("T agent"));
    }
    else if(team == 3){ // CT
        UI.SetValue("Misc", "SKINS", "Player", "Player model", getAgent("CT", GetValue("CT agent")));
        //setModel("CT", GetValue("CT agent"));
    }
}
function getAgents(team){
    var agents = ["None"];
    var agent_names = Object.keys(agent_list);
    for(i = 0; i < agent_names.length; i++){
        var name = agent_names[i];
        if(agent_list[name] !== team && team !== "all") continue;
        agents.push(agent_names[i]);
    }
    /*newAgents_names = Object.keys(newAgents);
    for(i = 0; i < newAgents_names.length; i++){
        var name = newAgents_names[i];
        if(newAgents[name] !== team && team !== "all") continue;
        agents.push(newAgents_names[i]);
    }*/
    return agents;
}
function getAgent(team, id){
    return getAgents("all").indexOf(getAgents(team)[id]);
}
/*function setModel(team, id){
    if(getAgents(team)[id] in agentsModels){
        Cheat.ExecuteCommand('script function ChangeAgent(n_class,p=null){{while((p=Entities.FindByClassname(p,n_class))!=null){p.SetModel("models/player/custom_player/legacy/'+getAgents(team)[id]+'.mdl")}}}')
        Cheat.ExecuteCommand('script ChangeAgent("player")');
    }
}*/

//Custom fog
function customFog(){
    if(!GetVal("custom_fog")){
        if (Convar.GetString("fog_override") !== "0"){
            Convar.SetString("fog_override", "0");
        }
        return;
    }
    if (Convar.GetString("fog_override") !== "1"){
        Convar.SetString("fog_override", "1");
    }
    var color = UI.GetColor("Script items", "Fog color");
    var color_value = color[0] + " " + color[1] + " " + color[2];
    var distance = GetVal("fog_distance").toString();
    var density = (GetVal("fog_density") / 100).toString();

    if (Convar.GetString("fog_color") != color_value){
      Convar.SetString("fog_color", color_value);
    }
    if (Convar.GetString("fog_end") != distance){
      Convar.SetString("fog_start", "0");
      Convar.SetString("fog_end", distance);
    }
    if (Convar.GetString("fog_maxdensity") != density){
        Convar.SetString("fog_maxdensity", density);
    }
    if(GetVal("useless_features") && UI.IsHotkeyActive("Visual", "WORLD", "Thirdperson")){
        Convar.SetString("fog_end", GetVal("fog_distance_3rd").toString());
    }
}

//Watermark
var last_fps = Math.floor(1 / Global.Frametime());
function watermark(){
    if(!GetVal("watermark")) return;
    UI.SetValue("Misc", "PERFORMANCE & INFORMATION", "Watermark", false);
    var elements_count = 0;
    var watermark_width = 10;
    list_font = Render.AddFont("Segoe UI", 8, 900);
    var elements = GetValue("Watermark elements");
    var cheat_name = "onetap";
    var username = UI.GetString("Script items", "Watermark custom name") || Cheat.GetUsername();
    var ping = Math.floor(Global.Latency() * 1000 / 1.6);
    var fps = Math.floor((1 / Global.Frametime() + last_fps) / 2);
    last_fps = fps;
    if((fps + "").length == 2) fps = "0" + fps;
    var today = new Date();
    var hours1 = today.getHours();
    var minutes1 = today.getMinutes();
    var seconds1 = today.getSeconds();
    var hours = hours1 <= 9 ? "0"+hours1+":" : hours1+":";
    var minutes = minutes1 <= 9 ? "0" + minutes1+":" : minutes1+":";
    var seconds = seconds1 <= 9 ? "0" + seconds1 : seconds1;
    var margin = 7;
    watermark_width += (cheat_name_width = Render.TextSizeCustom(cheat_name, list_font)[0]) + margin;
    if(elements & (1 << 0)){
        elements_count++;
        watermark_width += (username_width = Render.TextSizeCustom(username, list_font)[0]) + margin;
    }
    if(elements & (1 << 1)){
        elements_count++;
        watermark_width += (ping_width = Render.TextSizeCustom(ping + "ms", list_font)[0]) + margin;
    }
    if(elements & (1 << 2)){
        elements_count++;
        watermark_width += (fps_width = Render.TextSizeCustom(fps + "FPS", list_font)[0]) + margin;
    }
    if(elements & (1 << 3)){
        elements_count++;
        watermark_width += (tickrate_width = Render.TextSizeCustom(Globals.Tickrate() + " ticks", list_font)[0]) + margin;
    }
    if(elements & (1 << 4)){
        elements_count++;
        watermark_width += (version_width = Render.TextSizeCustom(version, list_font)[0]) + margin;
    }
    if(elements & (1 << 5)){
        elements_count++;
        watermark_width += (time_width = Render.TextSizeCustom(hours + minutes + seconds, list_font)[0]) + margin;
    }
    var watermark_x = screen_size[0] - margin - watermark_width;
    var watermark_y = 9;
    var watermark_text_y = watermark_y + 3;
    var render_offset = 0;
    var rendered_elements = 0;
    Render.GradientRect(screen_size[0] - margin - watermark_width, watermark_y, watermark_width / 2, 2, 1, [218, 160, 87, 255], [255, 223, 150, 255]);
    Render.GradientRect(watermark_x + watermark_width / 2, watermark_y, Math.ceil(watermark_width / 2), 2, 1, [255, 223, 150, 255], [218, 160, 87, 255]);
    Render.FilledRect(watermark_x, watermark_y + 2, watermark_width, list_height - 2, [38, 40, 52, 90]);
    var render_x = watermark_x + margin + render_offset;
    renderShadowText(watermark_x + margin, watermark_text_y, cheat_name, white_color, list_font);
    render_offset += cheat_name_width + margin;
    if(rendered_elements < elements_count) renderShadowText(watermark_x + render_offset + 1, watermark_text_y, "|", white_color, list_font);
    if(elements & (1 << 0)){
        renderShadowText(watermark_x + margin + render_offset, watermark_text_y, username, white_color, list_font);
        render_offset += username_width + margin;
        rendered_elements++;
        if(rendered_elements < elements_count) renderShadowText(watermark_x + render_offset + 1, watermark_text_y, "|", white_color, list_font);
    }
    if(elements & (1 << 1)){
        renderShadowText(watermark_x + margin + render_offset, watermark_text_y, ping + "ms", white_color, list_font);
        render_offset += ping_width + margin;
        rendered_elements++;
        if(rendered_elements < elements_count) renderShadowText(watermark_x + render_offset + 1, watermark_text_y, "|", white_color, list_font);
    }
    if(elements & (1 << 2)){
        renderShadowText(watermark_x + margin + render_offset, watermark_text_y, fps + "FPS", white_color, list_font);
        render_offset += fps_width + margin;
        rendered_elements++;
        if(rendered_elements < elements_count) renderShadowText(watermark_x + render_offset + 1, watermark_text_y, "|", white_color, list_font);
    }
    if(elements & (1 << 3)){
        renderShadowText(watermark_x + margin + render_offset, watermark_text_y, Globals.Tickrate() + " ticks", white_color, list_font);
        render_offset += tickrate_width + margin;
        rendered_elements++;
        if(rendered_elements < elements_count) renderShadowText(watermark_x + render_offset + 1, watermark_text_y, "|", white_color, list_font);
    }
    if(elements & (1 << 4)){
        renderShadowText(watermark_x + margin + render_offset, watermark_text_y, version, white_color, list_font);
        render_offset += version_width + margin;
        rendered_elements++;
        if(rendered_elements < elements_count) renderShadowText(watermark_x + render_offset + 1, watermark_text_y, "|", white_color, list_font);
    }
    if(elements & (1 << 5)){
        renderShadowText(watermark_x + margin + render_offset, watermark_text_y, hours + minutes + seconds, white_color, list_font);
        render_offset += time_width + margin;
        rendered_elements++;
    }
}

//Nade tracer
var nade_positions = [];
var nade_warning_max_dist = 150;
function nadeTracer(){
    if (!GetVal("nade_tracer")) return;

    const length = 256, rate = 0.1;
    const color = UI.GetColor("Script", "Nade tracer");

    for (g in nade_positions){
        if (Globals.Curtime() - nade_positions[g][3] > 3 || !Entity.IsValid(nade_positions[g][0])){
            nade_positions.shift();
            continue;
        }

        if (Globals.Curtime() - nade_positions[g][1] > rate){
            if (nade_positions[g][2].length > length){
                nade_positions[g][2].shift();
                nade_positions[g][1] = Globals.Curtime();
            }

            nade_positions[g][2].push(Entity.GetRenderOrigin(nade_positions[g][0]));
        }

        const is_he = Entity.GetClassID(nade_positions[g][0]) === 9, is_inferno = Entity.GetClassID(nade_positions[g][0]) === 100;
        const owner = Entity.GetProp(nade_positions[g][0], "CBaseCSGrenadeProjectile", "m_hOwnerEntity");
        if(!is_he && !is_inferno && owner) continue;

        for (l in nade_positions[g][2]){
            pos = Render.WorldToScreen(nade_positions[g][2][l]);

            if (l > 0) {
                last = Render.WorldToScreen(nade_positions[g][2][l - 1]);

                //why??
                //i wanna thin, not bold :)

                /*Render.Line(pos[0] - 1, pos[1] - 1, last[0] - 1, last[1] - 1, color);
                Render.Line(pos[0] - 1, pos[1] + 1, last[0] - 1, last[1] + 1, color);
                Render.Line(pos[0] + 1, pos[1] - 1, last[0] + 1, last[1] - 1, color);*/
                Render.Line(pos[0] + 1, pos[1] + 1, last[0] + 1, last[1] + 1, color);
                Render.Line(pos[0], pos[1], last[0], last[1], color);
            }

            last = Render.WorldToScreen(nade_positions[g][2][nade_positions[g][2].length - 1]);
        }
    }
}
function nadeTracer2(){
    if (!GetVal("nade_tracer")) return;

    var grenades = Entity.GetEntitiesByClassID(9).concat(Entity.GetEntitiesByClassID(113)).concat(Entity.GetEntitiesByClassID(100));
    for (e in grenades) {

        var should_pass = false;
        for (g in nade_positions) {
            if (nade_positions[g][0] == grenades[e]) {
                should_pass = true;
                continue;
            }
        }

        if (should_pass) continue;

        nade_positions.push([grenades[e], Globals.Curtime(), [Entity.GetRenderOrigin(grenades[e])], Globals.Curtime()]);
    }
}

//Nade warning
function nadeWarning(){
    if(!GetVal("nade_warning") && !GetVal("molotov_timer")) return;
    var grenades = Entity.GetEntitiesByClassID(9).concat(Entity.GetEntitiesByClassID(113)).concat(Entity.GetEntitiesByClassID(100));

    local = Entity.GetLocalPlayer();
    if (!local) return;
    
    if (!Entity.IsAlive(local)){
        const obs = Entity.GetProp(local, "CBasePlayer", "m_hObserverTarget");

        if (!Entity.IsValid(obs)) return;
        
        local = obs;
    }

    const origin = Entity.GetEyePosition(local);

    for (var i = 0; i < grenades.length; i++){
        const g = grenades[i];

        const destination = Entity.GetRenderOrigin(g);
        const distance = get_metric_distance(origin, destination);
        const is_he = Entity.GetClassID(g) === 9, is_inferno = Entity.GetClassID(g) === 100;
        

        if (distance > nade_warning_max_dist) continue;

        const screen = Render.WorldToScreen(destination);

        const trace = Trace.Line(local, origin, destination);

        const is_safe = distance > (is_inferno ? 4 : 8) || trace[1] < 0.61;

        if(!is_he && !is_inferno) continue;

        if(is_he && Entity.GetProp(g, "CBaseCSGrenadeProjectile", "m_nExplodeEffectTickBegin")) continue;
        if(is_he && Entity.GetProp(g, "CBaseCSGrenadeProjectile", "m_hThrower") === local) continue;

        //If it is flashbang we skip it
        if(is_he && Entity.GetProp(g, "CBaseGrenade", "m_flDamage") === 100) continue;

        Render.FilledCircle(screen[0], screen[1] - 50, 30, !is_safe ? [225, 20, 20, 175 ] : [20, 20, 20, 175]);
        Render.String(screen[0], screen[1] - 75, 1, "!", [255, 250, 175, 200], 4);
        if(is_he && GetVal("nade_warning")){
            var armor = Entity.GetProp(local, "CCSPlayerResource", "m_iArmor");
            var health = Entity.GetProp(local, "CBasePlayer", "m_iHealth");
            var x = origin[0] - destination[0];
            var y = origin[1] - destination[1];
            var z = origin[2] - destination[2];
            const distance = Math.sqrt(x * x + y * y + z * z);
            const a = 105.0;
            const b = 25.0;
            const c = 140.0;
            const d = (distance - b) / (c+1);
            var damage = (a - 18) * Math.exp(-d * d);
            if(armor > 0) {
                var newDmg = damage * 0.5;
                var armorDmg = (damage - newDmg) * 0.5;
 
                if(armorDmg > armor) {
                    armor = armor * (1 / 0.5);
                    newDmg = damage - armorDmg;
                }
                damage = newDmg;
            }
            damage = clamp(Math.ceil(damage) - 1, 0, 100);

            Render.String(screen[0], screen[1] - 40, 1, damage + " dmg", [232, 232, 232, 200], 3);
        }

        if (is_inferno && GetVal("molotov_timer")){
            if(!GetVal("molotov_timer")) return;
            const time = Entity.GetProp(g, "CInferno", "m_nFireEffectTickBegin") * Globals.TickInterval();
            const factor = clamp(((time + 7) - Globals.Curtime()) / 7, 0, 7);
            Render.String(screen[0], screen[1] - 40, 1, ((time + 7) - Globals.Curtime()).toFixed(1) + " s", [232, 232, 232, 200], 3);
            renderArc(screen[0], screen[1] - 50, 30, 32, -90, 360 * factor, [232, 232, 232, 200]);
        }
    }
}

//Anti bruteforce
var lastHitTime = 0.0;
var lastImpactTimes = [0.0];
var lastImpacts = [[0.0, 0.0, 0.0]];
var idealYawDelay = 3;
var idealYawBak = UI.GetValue("Anti-Aim", "Fake angles", "Hide real angle");
var block_set8 = false;
function antiBruteforce(){
    if (!GetVal("anti_brute")) return;
    if (GetVal("lowdelta") && isSlowwalking()) return;

    var curtime = Global.Curtime();
    if (Math.abs(lastHitTime - curtime) < 0.5) return;

    var entity = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    var impact = [Event.GetFloat("x"), Event.GetFloat("y"), Event.GetFloat("z"), curtime];
    var source;
    if (Entity.IsValid(entity) && Entity.IsEnemy(entity)){
        if (!Entity.IsDormant(entity)){
            source = Entity.GetEyePosition(entity);
        }
        else if (Math.abs(lastImpactTimes[entity] - curtime) < 0.1){
            source = lastImpacts[entity];
        }
        else{
            lastImpacts[entity] = impact;
            lastImpactTimes[entity] = curtime;
            return;
        }
        local = Entity.GetLocalPlayer();
        var localEye = Entity.GetEyePosition(local);
        var localOrigin = Entity.GetProp(local, "CBaseEntity", "m_vecOrigin");
        var localBody = VectorMultiply(VectorAdd(localEye, localOrigin), [0.5, 0.5, 0.5]);

        var bodyVec = ClosestPointOnRay(localBody, source, impact);
        var bodyDist = VectorDistance(localBody, bodyVec);
        
        if (bodyDist < 128.0){    //he clearly shot at us!
            var realAngle = Local.GetRealYaw();
            var fakeAngle = Local.GetFakeYaw();

            var headVec = ClosestPointOnRay(localEye, source, impact);
            var headDist = VectorDistance(localEye, headVec);
            var feetVec = ClosestPointOnRay(localOrigin, source, impact);
            var feetDist = VectorDistance(localOrigin, feetVec);

            var closestRayPoint;
            var realPos;
            var fakePos;

            if (bodyDist < headDist && bodyDist < feetDist){    //that's a pelvis   
                //pelvis direction = goalfeetyaw + 180
                closestRayPoint = bodyVec;
                realPos = ExtendVector(bodyVec, realAngle + 180.0, 10.0);
                fakePos = ExtendVector(bodyVec, fakeAngle + 180.0, 10.0);
            }
            else if (feetDist < headDist){//ow my toe
                //toe direction = goalfeetyaw -30 +- 90
                closestRayPoint = feetVec;
                var realPos1 = ExtendVector(bodyVec, realAngle - 30.0 + 90.0, 10.0);
                var realPos2 = ExtendVector(bodyVec, realAngle - 30.0 - 90.0, 10.0);
                var fakePos1 = ExtendVector(bodyVec, fakeAngle - 30.0 + 90.0, 10.0);
                var fakePos2 = ExtendVector(bodyVec, fakeAngle - 30.0 - 90.0, 10.0);
                if (VectorDistance(feetVec, realPos1) < VectorDistance(feetVec, realPos2)){
                    realPos = realPos1;
                }
                else{
                    realPos = realPos2;
                }
                if (VectorDistance(feetVec, fakePos1) < VectorDistance(feetVec, fakePos2)){
                    fakePos = fakePos1;
                }
                else{
                    fakePos = fakePos2;
                }
            }
            else{    //ow my head i feel like i slept for 2 days
                closestRayPoint = headVec;
                realPos = ExtendVector(bodyVec, realAngle, 10.0);
                fakePos = ExtendVector(bodyVec, fakeAngle, 10.0);
            }

            if (VectorDistance(closestRayPoint, fakePos) < VectorDistance(closestRayPoint, realPos)){    //they shot at our fake. they will probably not gonna shoot it again.
                lastHitTime = curtime;
                UI.SetValue("Anti-Aim", "Fake Angles", "Hide real angle", false);
                UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter");
                block_set8 = false;
            }
            else{
                if(!block_set8){
                    UI.SetValue("Anti-Aim", "Fake Angles", "Hide real angle", idealYawBak);
                    block_set8 = true;
                }
                if(UI.IsMenuOpen()){
                    idealYawBak = UI.GetValue("Anti-Aim", "Fake angles", "Hide real angle");
                }
            }
        }

        lastImpacts[entity] = impact;
        lastImpactTimes[entity] = curtime;
    }
}
function antiBruteforce2(){
    if (!GetVal("anti_brute")) return;
    if (GetVal("lowdelta") && isSlowwalking()) return;
    if (Entity.GetEntityFromUserID(Event.GetInt("userid")) !== Entity.GetLocalPlayer()) return;
    var hitbox = Event.GetInt('hitgroup');

    if (hitbox == 1 || hitbox == 6 || hitbox == 7){    //head, both toe
        var curtime = Global.Curtime();
        if (Math.abs(lastHitTime - curtime) > 0.5){   //0.2s backtrack + 0.2 extand + 0.1 extra
            lastHitTime = curtime;
            block_set8 = false;
            UI.SetValue("Anti-Aim", "Fake Angles", "Hide real angle", false);
            UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter");
        }
        else{
            if(!block_set8){
                UI.SetValue("Anti-Aim", "Fake Angles", "Hide real angle", idealYawBak);
                block_set8 = true;
            }
        }
    }
}
function antiBruteforce3(){
    if (!GetVal("anti_brute")) return;
    if(lastHitTime + idealYawDelay <= Global.Curtime()){
        if(!block_set8){
            UI.SetValue("Anti-Aim", "Fake Angles", "Hide real angle", idealYawBak);
            block_set8 = true;
        }
    }
    else{
        UI.SetValue("Anti-Aim", "Fake Angles", "Hide real angle", false);
        block_set8 = false;
    }
}

//Arms color changer
function armsColor(){
    if(!GetVal("arms_color")) return;
    var team = Entity.GetProp(Entity.GetLocalPlayer(),"DT_BaseEntity", "m_iTeamNum");
    if(team == 2){ // T
        if(Convar.GetString("r_skin") == GetValue("T arms color")) return;
        Global.ExecuteCommand("r_skin " + GetValue("T arms color"));
    }
    else if(team == 3){ // CT
        if(Convar.GetString("r_skin") == GetValue("CT arms color")) return;
        Global.ExecuteCommand("r_skin " + GetValue("CT arms color"));
    }
}

//Better glow chams
function betterGlowChams(){
    var name = "Better glow chams";
    var mat_index = Material.Get(name);
    if (mat_index > 0){
        Material.SetKeyValue(mat_index, "$baseTexture", "vgui/white");
        var additive = GetVal("better_glow_chams_hollow");
        Material.SetKeyValue(mat_index, "$additive", additive ? "1" : "0")
        Material.SetKeyValue(mat_index, "$envmap", "models/effects/cube_white")
        Material.SetKeyValue(mat_index, "$envmapfresnel", "1")
        
        var color = UI.GetColor("Script items", name);
        if(GetVal("better_glow_chams_rainbow")){
            /*color = hsv2rgb(Globals.Realtime() / 5 % 1, 1, 1);
            color = [color.r, color.g, color.b];
            color[0] /= 10;
            color[1] /= 10;
            color[2] /= 10;*/
            color = rgb(15 / 500);
        }
        if(GetVal("better_glow_chams_pulse")){
            var speed = 7
            var additive = 5
            var intensity = 0.6
            var sine = (Math.sin(Globals.Realtime() * 7) + 5) * intensity
            color[0] *= sine
            color[1] *= sine
            color[2] *= sine
        }
        var wireframe = GetVal("better_glow_chams_wireframe");
        Material.SetKeyValue(mat_index, "$wireframe", wireframe ? "1" : "0");
        var vibrancy = GetVal("better_glow_chams_vibrancy") / 10;
        Material.SetKeyValue(mat_index, "$envmapfresnelminmaxexp",  "[0 " + (11-vibrancy) + " " + ((11-vibrancy) * 2) + "]");
        Material.SetKeyValue(mat_index, "$envmaptint", "[" + color[0]/255 + " " + color[1]/255 + " " + color[2]/255 + "]");
        Material.SetKeyValue(mat_index, "$alpha", color[3] / 255 + "");
        Material.Refresh(mat_index);
    }
}
var betterGlowChamsRegistered = false;
function registerBetterGlowChams(){
    if(!GetVal("better_glow_chams")){
        betterGlowChamsRegistered = false;
        Material.Destroy("Better glow chams");
        return;
    }
    if(!betterGlowChamsRegistered){
        Material.Create("Better glow chams");
        betterGlowChamsRegistered = true;
    }
}

//Ping spike on key
function pingSpikeOnKey(){
    if(!GetVal("ping_spike")) return;
    UI.SetValue("Misc", "GENERAL", "Extended backtracking", UI.IsHotkeyActive("Script items", "Ping spike"));
}

//AA and fake-lag fixes
//bayonet, karambit, shadow daggers, knife
var pitch_bak = UI.GetValue("Anti-Aim", "Extra", "Pitch");
var restrictions_bak = UI.GetValue("Misc", "PERFORMANCE & INFORMATION", "Information", "Restrictions");
var legitAAactive = false;
var noFakeLagOnRevolver = false;
var block_set11 = false;
var block_set12 = false;
function fixes(){
    var weapon = getWeaponName();
    if(GetVal("fakelag_fix")){
        if(weapon == "revolver" && !mmFDActive){
            noFakeLagOnRevolver = true;
            block_set11 = false;
            UI.SetValue("Anti-Aim", "Fake-Lag", "Enabled", 0);
        }
        else if(!mmFDActive){
            noFakeLagOnRevolver = false;
            if(!block_set11){
                UI.SetValue("Anti-Aim", "Fake-Lag", "Enabled", fakelag_state_bak);
                block_set11 = true;
            }
            fakelag_state_bak = UI.GetValue("Anti-Aim", "Fake-Lag", "Enabled");
        }
    }
}

var generalHitchanceBak = UI.GetValue("Rage", "GENERAL", "Accuracy", "Hitchance");
var block_set15 = false;
function zeusHitchance(){
    if(!GetVal("zeus_hitchance_enabled")) return;
    player = Entity.GetLocalPlayer(); weapon = Entity.GetWeapon(player); weaponName = Entity.GetName(weapon);
    if (weaponName.includes("zeus")){
        block_set15 = false;
        UI.SetValue("Rage", "GENERAL", "Accuracy", "Hitchance", GetVal("zeus_hitchance"));
    }
    else{
        if(!block_set15){
            UI.SetValue("Rage", "GENERAL", "Accuracy", "Hitchance", generalHitchanceBak);
            block_set15 = true;
        }
        generalHitchanceBak = UI.GetValue("Rage", "GENERAL", "Accuracy", "Hitchance");
    }
}

//Enemy eye tracers
function eyeTracers(){
    if(!GetVal("eye_tracers")) return;
    var color = UI.GetColor("Script Items", "Eye tracers");
    if(!Entity.GetLocalPlayer())
        return;

    var playerList = Entity.GetEnemies();
    for(var i = 0; i < playerList.length; i++){
        if(!Entity.IsAlive(playerList[i]) || Entity.IsDormant(playerList[i]))
            continue;

        var eyeAngles = Entity.GetProp(playerList[i], "CCSPlayer", "m_angEyeAngles");
        var e_V = angle_to_vec(eyeAngles[0], eyeAngles[1]);

        var entityHead = Entity.GetHitboxPosition(playerList[i], 0); //HITBOX_HEAD

        var stop = [entityHead[0] + e_V[0] * 8192, entityHead[1] + e_V[1] * 8192, entityHead[2] + e_V[2] * 8192];

        var traceResult = Trace.Line(playerList[i], entityHead, stop);

        if(traceResult[1] == 1.0)
            continue;

        stop = [entityHead[0] + e_V[0] * traceResult[1] * 8192, entityHead[1] + e_V[1] * traceResult[1] * 8192, entityHead[2] + e_V[2] * traceResult[1] * 8192];

        entityHead = Render.WorldToScreen(entityHead);
        stop = Render.WorldToScreen(stop);

        if(stop[2] != 1 || entityHead[2] != 1)
            continue;

        Render.Line(entityHead[0], entityHead[1], stop[0], stop[1], color);
    }
}

//Dark menu background
var menuBackgroundColor = [0, 0, 0, 0];
function darkMenu(){
    if(!GetVal("dark_menu")) return;
    var maxAlpha = 150;
    var speed = 20;
    
    Render.FilledRect(0, 0, screen_size[0], screen_size[1], menuBackgroundColor);
    
    if(UI.IsMenuOpen()){
        menuBackgroundColor[3] = clamp(menuBackgroundColor[3] + speed, 0, maxAlpha);
    }
    else{
        menuBackgroundColor[3] = clamp(menuBackgroundColor[3] - speed, 0, maxAlpha);
    }
}

//Enemy location spammer
var locationLastTick = 0;
function enemyLocation(){
    if(!GetVal("enemy_location")) return;
    if (locationLastTick == 0) {
        locationLastTick = Global.Tickcount();
        return;
    }

    var SpamDelay = 96;
    var CurrentTickcount = Global.Tickcount();
    if(CurrentTickcount - locationLastTick < SpamDelay){
        return;
    }
    else if(CurrentTickcount - locationLastTick > SpamDelay){
        locationLastTick = CurrentTickcount;
    }

    var enemies = Entity.GetEnemies();

    for(i = 0; i < enemies.length; i++){
        if(Entity.IsAlive(enemies[i])){
            var Name = Entity.GetName(enemies[i]);
            var Location = Entity.GetProp(enemies[i], "CBasePlayer", "m_szLastPlaceName");
            var Health = Entity.GetProp(enemies[i], "CBasePlayer", "m_iHealth");
            var Weapon =  Entity.GetName(Entity.GetWeapon(enemies[i]));

            var SendInfo = ("[onetap] Player " + Name + " with " + Health + " HP " + " is at " + Location + " with weapon " + Weapon);
            Cheat.ExecuteCommand("say_team " + SendInfo);
        }
    }
}

//Party mode
var old_party_mode = false;
function partyMode(){
    var party_mode = GetVal("party_mode");
    
    if(old_party_mode != party_mode){
        old_party_mode = party_mode;
        Convar.SetString("sv_party_mode", party_mode ? "1" : "0");
    }
}
function partyMode2(){
    var party_mode = GetVal("party_mode");
    Convar.SetString("sv_party_mode", party_mode ? "1" : "0");
}

//Music kit changer
function musicKit(){
    if (Cheat.FrameStage() != 1 || !GetVal("music_kit"))
        return;
      
    Entity.SetProp(Entity.GetLocalPlayer(), "CCSPlayerResource", "m_nMusicID", GetValue("Music kit"));
}

//Indicator
var indicator_names = [
    ["DMG", ["Script items", "Min damage override"], [255, 133, 0, 255]],
    ["DT", ["Rage", "GENERAL", "Exploits", "Doubletap"], [74, 207, 0, 255]],
    ["HIDE", ["Rage", "GENERAL", "Exploits", "Hide shots"], [199, 34, 53, 255]],
    ["DORMANT", ["Script items", "Dormant Aimbot"], [74, 207, 0, 255]],
    ["ONSHOT", ["Script items", "Force backshoot"], [74, 207, 0, 255]],
    ["FAKEDUCK", ["Anti-Aim", "Extra", "Fake duck"], [157, 157, 157, 255]],
    ["LOWDELTA", null, [0, 222, 222, 255]],
    ["BAIM", ["Rage", "GENERAL", "General", "Force body aim"], [199, 34, 53, 255]],
    ["SAFE", ["Rage", "GENERAL", "General", "Force safe point"], [0, 222, 222, 255]],
    ["LEGIT AA", null, [0, 222, 222, 255]],
    ["FREESTANDING", ["Script items", "Freestanding"], [0, 222, 222, 255]],
    ["AUTO PEEK", ["Misc", "General", "Auto peek"], [74, 207, 0, 255]]
];
function indicators(){
    if(!GetVal("indicators")) return;
    local = Entity.GetLocalPlayer();
    if(!local || !Entity.IsValid(local) || !Entity.IsAlive(local)) return;
    var active_binds = [];
    var binds_offset = 16;
    var crosshair_size = GetValue("Better crosshair length") || 0;
    var font = Render.AddFont("MS Serif", 8, 500);
    if(GetValue("Desync strength indicator") && !betterScopeActive){
        var size = 1.25;
        var x = screen_size[0];
        var y = screen_size[1];
        var col = UI.GetColor("Script items", "Desync strength");
        var real_yaw = Local.GetRealYaw();
        var fake_yaw = Local.GetFakeYaw();
        var delta = Math.min(Math.abs(real_yaw - fake_yaw) / 2, 60).toFixed(0);
        Render.GradientRect(x / 2, y / 2 + 8 + crosshair_size, (size * delta), 5, 1, col, [0, 0, 0, 0]);
        Render.GradientRect((x / 2 - size * delta) + 1, y / 2 + 8 + crosshair_size, (size * delta), 5, 1, [0, 0, 0, 0], col);
    }
    if(GetValue("Desync strength indicator")) binds_offset += 10;
    for(bind in indicator_names){
        var bind_name = indicator_names[bind][0];
        var bind_path = indicator_names[bind][1];
        if(bind_path != null && UI.IsHotkeyActive.apply(null, bind_path) && active_binds.indexOf(bind) === -1){
            active_binds.push(bind);
            continue;
        }
        if((bind_name == "FREESTANDING" || bind_name == "DMG") && autopeek_active){
            active_binds.push(bind);
        }
        if(bind_name == "FAKEDUCK" && mmFDActive && !(bind in active_binds)){
            active_binds.push(bind);
        }
        if(bind_name == "LOWDELTA" && lowdelta_active){
            active_binds.push(bind);
        }
        if(bind_name == "LEGIT AA" && legitAAactive){
            active_binds.push(bind);
        }
    }
    for(active_bind in active_binds){
        var bind = active_binds[active_bind];
        var name = indicator_names[bind][0];
        var color = indicator_names[bind][2];
        var text_size = (GetValue("Indicator pixel style")) ? Render.TextSizeCustom(name, font) : Render.TextSize(name, 3);
        var text_height = text_size[1];
        var better_scope_active = GetValue("Better scope thickness");
        var right_shift = ((betterScopeActive) ? (-better_scope_active - 3) : 0);

        var indicator_x = screen_size[0] / 2 - right_shift;
        var indicator_y = screen_size[1] / 2 + binds_offset;
        //Render.StringCustom(screen_size[0] / 2 - ((betterScopeActive) ? (-GetValue("Better scope thickness") - 4) : (text_size[0] / 2)), screen_size[1] / 2 + 6 + binds_offset + crosshair_size, 0, name, color, font);
        if(GetValue("Indicator pixel style")){
            Render.StringCustom(indicator_x + 1, indicator_y, +!betterScopeActive, name, [0, 0, 0, 255], font);
            Render.StringCustom(indicator_x - 1, indicator_y, +!betterScopeActive, name, [0, 0, 0, 255], font);
            Render.StringCustom(indicator_x, indicator_y + 1, +!betterScopeActive, name, [0, 0, 0, 255], font);
            Render.StringCustom(indicator_x, indicator_y - 1, +!betterScopeActive, name, [0, 0, 0, 255], font);
            Render.StringCustom(indicator_x, indicator_y, +!betterScopeActive, name, color, font);
        }
        else{
            Render.String(indicator_x + 1, indicator_y, +!betterScopeActive, name, [0, 0, 0, 125], 3);
            Render.String(indicator_x, indicator_y, +!betterScopeActive, name, color, 3);
        }
        
        binds_offset = binds_offset + text_height - 1;
    }
}

//Killsay
function killsay(){
    if(!GetVal("killsay")) return;
    local = Entity.GetLocalPlayer();
    if(Entity.GetEntityFromUserID(Event.GetInt("userid")) === local) return;
    if(Entity.GetEntityFromUserID(Event.GetInt("attacker")) !== local) return;
    if(Event.GetInt("headshot") == 1 || GetValue("Killsay toxic mode")){
        Cheat.ExecuteCommand("say 1");
        return;
    }
    if(Event.GetInt("noscope") == 1){
        Cheat.ExecuteCommand("say EZ");
        return;
    }
    Cheat.ExecuteCommand("say *DEAD*");
}

//Legit AA on key and on knife
var block_set10 = false;
var block_set16 = false;
var legitAAactive = false;
function legitAA(){
    var weapon = getWeaponName();
    var local_isKnife = weapon.indexOf("knife") !== -1;
    var noAAonKnife = local_isKnife && GetVal("antiaim_fix");
    if((GetVal("legit_aa") && UI.IsHotkeyActive("Script items", "Legit AA")) || noAAonKnife){
        legitAAactive = true;
        block_set16 = false;
        block_set10 = false;
        UI.SetValue("Misc", "PERFORMANCE & INFORMATION", "Information", "Restrictions", 0);
        UI.SetValue("Anti-Aim", "Extra", "Pitch", 0);
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 180);
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset", 0);
    }
    else{
        legitAAactive = false;
        if(!lowdelta_active && !mmFDActive){
            if(!block_set10){
                UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", yaw_bak);
                UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset", jitter_bak);
                block_set10 = true;
            }
            yaw_bak = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset");
            jitter_bak = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset");
        }
        if(!block_set16){
            UI.SetValue("Anti-Aim", "Extra", "Pitch", pitch_bak);
            UI.SetValue("Misc", "PERFORMANCE & INFORMATION", "Information", "Restrictions", restrictions_bak);
            block_set16 = true;
        }
        pitch_bak = UI.GetValue("Anti-Aim", "Extra", "Pitch");
        restrictions_bak = UI.GetValue("Misc", "PERFORMANCE & INFORMATION", "Information", "Restrictions");
    }
}

function freestanding(){
    if(!GetVal("freestanding")) return;
    if(UI.IsHotkeyActive("Misc", "General", "Auto peek")) return;
    UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction", UI.IsHotkeyActive("Script items", "Freestanding"));
}

var otc3_cord_clantag = [
    " ",
    "0",
    "o",
    "o7",
    "ot",
    "ot<",
    "otc",
    "otc3",
    "otc3 <",
    "otc3 c",
    "otc3 c0",
    "otc3 co",
    "otc3 co2",
    "otc3 cor",
    "otc3 cord",
    "-otc3 cord-",
    "--otc3 cord--",
    "--otc3 cord--",
    "--otc3 cord--",
    "--otc3 cord--",
    "--otc3 cord--",
    "-otc3 cord-",
    "otc3 cord",
    "-tc3 cor-",
    "--c3 co--",
    "---3 c---",
    "----------",
    "-------",
    "-----",
    "---",
    " ",
    " ",
    " ",
    " ",
];
var otc3_cord_clantag2 = [
    "^_^",
    "~_~",
    "^_^",
    "^_^",
    "^_^",
    "^_^",
    "^.^",
    "^.^",
    "^.^ 3",
    "^.^ <3",
    "^.^ <3",
    "^_^ <3",
    "^_^ <3",
    "^_^ <3",
    "^_^ <3",
    "^_^ <3",
    "^_^ <3",
    "^_^ <3",
    "^_^ <",
    "^_^ ",
    "^_^",
    "^_^",
    "^_^",
    "^_^",
    "^_^",
    "^_^",
];
var last_clantag_time = 0;
function clantag(){
    if(!GetVal("clantag")) return;
    var speed = 4;
    var time = parseInt((Globals.Curtime() * speed));
    if (time == last_clantag_time) return;
    last_clantag_time = time;
    if(GetValue("Clantag")){
        Local.SetClanTag(otc3_cord_clantag2[(time) % otc3_cord_clantag2.length]);
        return;
    }
    Local.SetClanTag(otc3_cord_clantag[(time) % otc3_cord_clantag.length]);
}

var dormant_aim_shot = true;
function dormantAim(){
    if(!GetVal("dormant_aim")) return;
    if(!UI.IsHotkeyActive("Script items", "Dormant Aimbot")) return;
    if(!can_shoot(Entity.GetLocalPlayer())) return;
    var e = Entity.GetEnemies();
    var d = e.filter(function(e){
        return Entity.IsDormant(e) && Entity.IsAlive(e) && Trace.Bullet(Entity.GetLocalPlayer(), e, Entity.GetEyePosition(Entity.GetLocalPlayer()), VectorAdd(Entity.GetRenderOrigin(e), [0, 0, 45]))[1] > 1;
    });
    var c = d.sort(function(a, b){
        return Trace.Bullet(Entity.GetLocalPlayer(), a, Entity.GetEyePosition(Entity.GetLocalPlayer()), VectorAdd(Entity.GetRenderOrigin(a), [0, 0, 45]))[1] - Trace.Bullet(Entity.GetLocalPlayer(), b, Entity.GetEyePosition(Entity.GetLocalPlayer()), VectorAdd(Entity.GetRenderOrigin(b), [0, 0, 45]))[1];
    })[0];
    // if no enemies return
    if(!c) {
        return;
    }
    var weapon_index = Entity.GetWeapon(Entity.GetLocalPlayer()); 
    var m_flNextPrimaryAttack = Entity.GetProp(weapon_index,"DT_BaseCombatWeapon","m_flNextPrimaryAttack"); //gets time until next attack
    var viewangle = VectorAngles(VectorSubtract(VectorAdd(Entity.GetRenderOrigin(c), [0, 0, 45]),Entity.GetEyePosition(Entity.GetLocalPlayer())));
    if( Globals.Curtime() - m_flNextPrimaryAttack > 0.1){
    //UserCMD.SetViewAngles(viewangle, true)
    UserCMD.SetAngles(viewangle);
    //UserCMD.SetButtons((1 << 0) | UserCMD.GetButtons())
    var getbuttons = Entity.GetProp(Entity.GetLocalPlayer(),'CBasePlayer', 'm_fFlags');
    Cheat.ExecuteCommand("+attack");
    dormant_aim_shot = true;

    
    
    dmg = Trace.Bullet(Entity.GetLocalPlayer(), c, Entity.GetEyePosition(Entity.GetLocalPlayer()), VectorAdd(Entity.GetRenderOrigin(c), [0, 0, 45]))[1];
    // log shot
    Cheat.Print("Dormant aimed at " + Entity.GetName(c) + " for " + dmg + " dmg");
    }
}

function shoot() {
    if(dormant_aim_shot) { // don't care who shot
        Cheat.ExecuteCommand("-attack");
        dormant_aim_shot = false;
    }
}

function antiBuyBot(){
    if(!GetVal("anti_buybot")) return;
    var entity = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    if(entity != Entity.GetLocalPlayer()) return;
    var gamerules = Entity.GetGameRulesProxy();
    UI.SetValue("Misc", "General", "Buybot", "Enable", !Entity.GetProp(gamerules, "CCSGameRulesProxy", "m_bIsValveDS"));
}

var auto_dir_bak = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction");
var block_set19 = false;
var autopeek_active = false;
function autoPeek(){
    if(!GetVal("auto_peek")) return;
    var gamerules = Entity.GetGameRulesProxy();
    if(UI.IsHotkeyActive("Misc", "General", "Auto peek")){
        autopeek_active = true;
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction", true);
        //if(!UI.IsHotkeyActive('Rage', 'GENERAL', 'Force body aim')) UI.ToggleHotkey('Rage', 'GENERAL', 'Force body aim');
        !Entity.GetProp(gamerules, "CCSGameRulesProxy", "m_bIsValveDS") && !UI.IsHotkeyActive('Rage', 'GENERAL', 'Doubletap') && UI.ToggleHotkey('Rage', 'GENERAL', 'Doubletap');
        block_set19 = false;
    }
    else{
        autopeek_active = false;
        if(!block_set19){
            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction", auto_dir_bak);
            //if(UI.IsHotkeyActive('Rage', 'GENERAL', 'Force body aim') != baim_state_bak) UI.ToggleHotkey('Rage', 'GENERAL', 'Force body aim');
            block_set19 = true;
        }
        auto_dir_bak = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction");
        //baim_state_bak = UI.IsHotkeyActive('Rage', 'GENERAL', 'Force body aim');
    }

}

var targetSafeHead = -1;
var safeHeadEntities = [];

function playerList(){
    if(!World.GetServerString()) return;
    var target = Ragebot.GetTarget();
    if(target){
        var player_id = Entity.GetName(target) + target;
        if(player_id in player_list && player_list[player_id]){
            targetSafeHead = target;
            Ragebot.ForceHitboxSafety(0);
        }
    }
    var enemies = Entity.GetEnemies();
    safeHeadEntities = [];
    for(enemy in enemies){
        enemy = enemies[enemy];
        var player_id = Entity.GetName(enemy) + enemy;
        if(player_id in player_list && player_list[player_id]){
            safeHeadEntities.push(enemy);
        }
    }
}

function drawPlayerSafeHead(){
    if(!World.GetServerString()) return;
    var font = Render.AddFont("Verdana", 8, 400);
    for(enemy in safeHeadEntities){
        enemy = safeHeadEntities[enemy];
        if(!Entity.IsAlive(enemy)) return;
        var pos = Entity.GetRenderBox(enemy);
        var a = pos[3] - pos[1];
        a /= 2;
           a += pos[1];
           var color = (enemy == targetSafeHead) ? [0, 255, 0, 255] : [255, 255, 255, 255];
        Render.StringCustom(a, pos[2] - 30, 1, "SAFE", color, font);
        Render.StringCustom(a + 1, pos[2] - 30 + 1, 1, "SAFE", [0,0,0,125], font);
    }
}

var safety_hitboxes = {
    "head": [false, false, false],
    "body": [false, false, false],
    "legs": [false, false, false],
    "feet": [false, false, false]
}
var hitbox_index = {
    "head": [0],
    "body": [3],
    "legs": [9, 10],
    "feet": [11, 12]
}
var hitbox_cheat_index = {
    "head": [0],
    "body": [1, 2, 3, 4, 5],
    "legs": [6],
    "feet": [7]
}
var block_set21 = false;
var hitboxes_bak = [0, 0, 0, 0, 0, 0];
for(category in weapon_categories){
    hitboxes_bak[category] = UI.GetValue("Rage", weapon_categories[category], "Targeting", "Hitboxes");
}
function safetySystem(){
    var enemies = Entity.GetEnemies();
    var target = Ragebot.GetTarget();
    for(enemy in enemies){
        enemy = enemies[enemy];
        if(IsLethal(enemy) && Entity.IsAlive(enemy) && !Entity.IsDormant(enemy) && enemy == target){
            block_set21 = false;

            var hitboxes = 0;
            for(hitbox in safety_hitboxes){
                if(safety_hitboxes[hitbox][2] == true){
                    var hitbox_a = hitbox_cheat_index[hitbox];
                    for(hitbox_i in hitbox_a){
                        hitboxes += (1 << hitbox_a[hitbox_i]);
                    }
                }
            }
            //Lethal safety
            for(category in weapon_categories){
                UI.SetValue("Rage", weapon_categories[category], "Targeting", "Hitboxes", hitboxes);
            }

            for(hitbox in safety_hitboxes){
                if(safety_hitboxes[hitbox][1] == true){
                    var hitbox_a = hitbox_index[hitbox];
                    for(hitbox_i in hitbox_a){
                        Ragebot.ForceHitboxSafety(hitbox_a[hitbox_i]);
                    }
                }
            }

        }
        else{
            //Safety
            forceHitboxSafePoints();
            if(!block_set21){
                for(category in weapon_categories){
                    UI.SetValue("Rage", weapon_categories[category], "Targeting", "Hitboxes", hitboxes_bak[category]);
                }
                block_set21 = true;
            }
            if(UI.IsMenuOpen()){
                for(category in weapon_categories){
                    hitboxes_bak[category] = UI.GetValue("Rage", weapon_categories[category], "Targeting", "Hitboxes");
                }
            }
        }
    }
}

function forceHitboxSafePoints(){
    for(hitbox in safety_hitboxes){
        if(safety_hitboxes[hitbox][0] == true){
            var hitbox_a = hitbox_index[hitbox];
            if(typeof hitbox_a == "object"){
                for(hitbox_i in hitbox_a){
                    Ragebot.ForceHitboxSafety(hitbox_a[hitbox_i]);
                }
            }
            else{
                Ragebot.ForceHitboxSafety(hitbox_a);
            }
        }
    }
}

log("Initialized all main functions");






//Script items
var script_items = {
    "lowdelta": [
        {"name": "Lowdelta", "type": "dropdown", "elements": ["Slowwalk", "Always"]},
        {"name": "Lowdelta on FD", "type": "checkbox"}
    ],
    "dormant_aim": [
        {"name": "Dormant Aimbot", "type": "hotkey"}
    ],
    "mindamage": [{"name": "Min damage override", "type": "hotkey"}],
    "mm_fd": [
        {"name": "Matchmaking FD", "type": "hotkey"},
        {"name": "Matchmaking FD type", "type": "dropdown", "elements": ["Rage", "Lower Rage", "Semifull", "Full"]},
        {"name": "Matchmaking FD lock camera", "type": "checkbox"},
        {"name": "Matchmaking FD opposite LBY", "type": "checkbox"},
        {"name": "Matchmaking FD invert on shot", "type": "checkbox"}
    ],
    "doubletap_boost": [{"name": "Doubletap boost", "type": "dropdown", "elements": ["Faster recharge", "Fastest recharge", "Adaptive", "Adaptive agressive"]}],
    "force_backshoot": [{"name": "Force backshoot", "type": "hotkey"}],
    "ping_spike": [{"name": "Ping spike", "type": "hotkey"}],
    "freestanding": [{"name": "Freestanding", "type": "hotkey"}],
    "legit_aa": [{"name": "Legit AA", "type": "hotkey"}],
    "bullet_tracer": [
        {"name": "Bullet tracer", "type": "color"},
        {"name": "Bullet tracer thickness", "type": "slider", "min": 2, "max": 6}
    ],
    "damage_marker": [
        {"name": "Damage marker", "type": "color"},
        {"name": "Damage marker outline", "type": "checkbox"}
    ],
    "skeleton_on_hit": [
        {"name": "Skeleton Hit Color", "type": "color"},
        {"name": "Skeleton Kill Color", "type": "color"}
    ],
    "eye_tracers": [
        {"name": "Eye tracers", "type": "color"}
    ],
    "trail": [
        {"name": "Trail", "type": "color"},
        {"name": "Trail rainbow", "type": "checkbox"}
    ],
    "better_scope": [
        {"name": "Better scope hide GUI", "type": "checkbox"},
        {"name": "Better scope viewmodel", "type": "checkbox"},
        {"name": "Better scope width", "type": "slider", "min": 0, "max": 200, "default": 50},
        {"name": "Better scope thickness", "type": "slider", "min": 0, "max" : 4, "default": 3},
        {"name": "Better scope start", "type": "slider", "min": 0, "max": 50, "default": 15},
        {"name": "Better scope color 1", "type": "color"},
        {"name": "Better scope color 2", "type": "color"}
    ],
    "better_crosshair": [
        {"name": "Better crosshair", "type": "color"},
        {"name": "Better crosshair rainbow", "type": "checkbox"},
        {"name": "Better crosshair speed", "type": "slider", "min": 0, "max": 10, "default": 2},
        {"name": "Better crosshair length", "type": "slider", "min": 0, "max": 100, "default": 12}
    ],
    "hitmarker": [
        {"name": "Hitmarker", "type": "color"},
        {"name": "Hitmarker in screen center", "type": "checkbox"}
    ],
    "rainbow_bar": [{"name": "Rainbow bar", "type": "dropdown", "elements": ["Single color", "Gradient"]}],
    "nade_circle": [
        {"name": "Molotov circle fill", "type": "color"},
        {"name": "Molotov circle outline", "type": "color"},
        {"name": "Smoke circle fill", "type": "color"},
        {"name": "Smoke circle outline", "type": "color"},
        {"name": "HE circle", "type": "color"}
    ],
    "nade_tracer": [{"name": "Nade tracer", "type": "color"}],
    "transparency_on_nade": [
        {"name": "Wall transparency", "type": "slider", "min": 0, "max": 25, "default": 0},
        {"name": "Prop transparency", "type": "slider", "min": 0, "max": 100, "default": 50}
    ],
    "agent_changer": [
        {"name": "T agent", "type": "dropdown", "elements": getAgents("T")},
        {"name": "CT agent", "type": "dropdown", "elements": getAgents("CT")}
    ],
    "arms_color": [
        {"name": "T arms color", "type": "dropdown", "elements": ["Default", "Nigger", "Brown", "Asian", "Red", "Tatoo", "White"]},
        {"name": "CT arms color", "type": "dropdown", "elements": ["Default", "Nigger", "Brown", "Asian", "Red", "Tatoo", "White"]}
    ],
    "better_glow_chams": [
        {"name": "Better glow chams", "type": "color"},

    ],
    "world_color": [{"name": "World color", "type": "color"}],
    "custom_fog": [{"name": "Fog color", "type": "color"}],
    "music_kit": [{"name": "Music kit", "type": "slider", "min": 1, "max": 41}],
    "killsay": [{"name": "Killsay toxic mode", "type": "checkbox"}],
    "indicators": [
        {"name": "Indicator pixel style", "type": "checkbox"},
        {"name": "Desync strength indicator", "type": "checkbox"},
        {"name": "Desync strength", "type": "color"}
    ],
    "watermark": [
        {"name": "Watermark elements", "type": "multi", "elements": ["Username", "Ping", "FPS", "Tickrate", name_text + " version", "Time"]},
        {"name": "Watermark custom name", "type": "textbox"}
    ],
    "clantag": [
        {"name": "Clantag", "type": "dropdown", "elements": ["otc3 cord", "^_^"]}
    ]
};

//OTHER FUNCTIONS
var world_pos1;
function entities(){
    var entities = Entity.GetEntities();
    for (var i = 0; i < entities.length; i++){
        var entity = entities[i];
        var name = Entity.GetClassName(entity);
        var world_pos = Entity.GetRenderOrigin(entities[i]);
        if (name === "CEnvTonemapController"){
            worldColor2(entity);
        }
        if (name === "CInferno"){
               draw_circle_3d(world_pos[0], world_pos[1], world_pos[2], 180, 360, 0.150, UI.GetColor("Script items", "Molotov circle fill"), true, UI.GetColor("Script items", "Molotov circle outline"));
        }
        if(name === "CSmokeGrenadeProjectile"){
            var world_pos = Entity.GetRenderOrigin(entities[i]);
            draw_circle_3d(world_pos[0], world_pos[1], world_pos[2], 149, 360, 0.150, UI.GetColor("Script items", "Smoke circle fill"), true, UI.GetColor("Script items", "Smoke circle outline"));
        }
    }
}

function players(){
    var players = Entity.GetPlayers();
    for (var i = 0; i < players.length; i++){
        return;
        var player = players[i];
        var nickname = Entity.GetName(player);
        //if(player === local) continue;
        var clan = Entity.GetProp(player, "CCSPlayerResource", "m_szClan");
        if(Entity.IsBot(player)) continue;
        //if(clan == "" || !clan) continue;
        //Cheat.Print(clan);
        //Cheat.Print(nickname + "\n");
        //if(clan.length !== 9) continue;
        var command = clan[8];
        var nickname_length = nickname.length;
        nickname_length = clamp(nickname_length, 0, 9);
        if(clan[0] !== "!") continue;
        Cheat.Print(1 + "\n");
        if(clan[1] !== nickname_length) continue;
        Cheat.Print(2 + "\n");
        if(clan[2] !== "c" || clan[3] !== "r") continue;
        Cheat.Print(3 + "\n");
        if(clan[4] !== nickname[1]) continue;
        Cheat.Print(4 + "\n");
        if(clan[5] !== nickname[5]) continue;
        Cheat.Print(5 + "\n");
        if(clan[6] !== "." || (clan[7] !== "&" && clan[7] !== "$")) continue;
        //Cheat.Print(6 + "\n");
        //Cheat.Print(command);
    }
}

function updateVars(){
    screen_size = Render.GetScreenSize();
    cursor_pos = Input.GetCursorPosition();
}

function on_weapon_fire(){
    var shooter = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    last_shot_time[shooter] = Globals.Tickcount();
}

function ragebotFire(){
    if(GetVal("invert_on_shot") || (mmFDActive && GetValue("Matchmaking FD invert on shot"))){
        UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter");
    }
}

function on_player_connect(){
    var entity = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    if(entity != Entity.GetLocalPlayer()) return;
    //Resetting vars
    last_shot_time = [];
    disableTime = 0; hitmarkerTime = 0; didKill = 0;
    buys = {};
    effect_alpha = 100; effect_size = 150;
    he_positions = []; grenadeData = [];
    nade_positions = [];
    lastHitTime = 0.0;
    lastImpactTimes = [0.0];
    lastImpacts = [[0.0, 0.0, 0.0]];
    bullets = [];
}

function resetVars(){
    var entity = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    if(entity != Entity.GetLocalPlayer()) return;
    //Resetting vars
    last_shot_time = [];
    disableTime = 0; hitmarkerTime = 0; didKill = 0;
    buys = {};
    effect_alpha = 100; effect_size = 150;
    he_positions = []; grenadeData = [];
    nade_positions = [];
    bullets = [];
    if(Convar.GetString("cl_lock_camera") !== "0"){
        Convar.SetString('cl_lock_camera', '0');
    }
    Convar.SetFloat("r_drawvgui", 1);
    Convar.SetInt("fov_cs_debug", 0);
    Convar.SetString('cl_draw_only_deathnotices', '0');
}

function on_hegrenade_detonate() {
    worldLocation = [Event.GetInt("x"), Event.GetInt("y"), Event.GetInt("z")];
    he_positions.push(worldLocation);
    grenadeData.push([2, 255]);
}

function renderShadowText(x, y, text, color, font){
    Render.StringCustom(x + 1, y + 1, 0, text, [0, 0, 0, 100], font);
    Render.StringCustom(x, y, 0, text, color, font);
}

function forceBaim(){
    forcedBaim = true;
    if(!UI.IsHotkeyActive('Rage', 'GENERAL', 'Force body aim')) UI.ToggleHotkey('Rage', 'GENERAL', 'Force body aim');
}
function DisableBaim(){
    if(UI.IsHotkeyActive('Rage', 'GENERAL', 'Force body aim')) UI.ToggleHotkey('Rage', 'GENERAL', 'Force body aim');
}

function ExtrapolateTick(ticks) {
    local = Entity.GetLocalPlayer();
    var head = Entity.GetHitboxPosition(local, 0),
        velocity = Entity.GetProp(local, 'CBasePlayer', 'm_vecVelocity[0]'),
        array = [];
    return array[0] = head[0] + velocity[0] * Globals.TickInterval() * ticks, array[1] = head[1] + velocity[1] * Globals.TickInterval() * ticks, array[2] = head[2] + velocity[2] * Globals.TickInterval() * ticks, array;
}

function IsLethal(player) {
    var health = Entity.GetProp(player, 'CBasePlayer', 'm_iHealth');
    pelvis_pos = Entity.GetHitboxPosition(player, 2),
    body_pos = Entity.GetHitboxPosition(player, 3),
    thorax_pos = Entity.GetHitboxPosition(player, 4);
    local = Entity.GetLocalPlayer();
    result_thorax = Trace.Bullet(local, player, Entity.GetEyePosition(local), thorax_pos);
    if (result_thorax[1] >= health) return true;
    result_thorax_extrapolated = Trace.Bullet(local, player, ExtrapolateTick(14), thorax_pos);
    if (result_thorax_extrapolated[1] >= health) return true;
    return false;
}

function isInAir(){
    var fv = Entity.GetProp(Entity.GetLocalPlayer(), "CBasePlayer", "m_flFallVelocity");
    if(fv < -1 || fv > 1){
        return true;
    }
    return false;
}

function angle_diff(angle_1, angle_2){
    var delta = angle_1 - angle_2;
    delta %= 360;
    if(delta > 180)
    {
        delta -= 360;
    }
    if(delta < -180)
    {
        delta += 360;
    }
    return delta;
}

function closestTarget(){
    var enemies = Entity.GetEnemies();
    var dists = [];
    var damage = [];
    for(e in enemies) {
        if(!Entity.IsAlive(enemies[e]) || Entity.IsDormant(enemies[e]) || !Entity.IsValid(enemies[e])) continue;
        dists.push([enemies[e], calcDist(Entity.GetHitboxPosition(Entity.GetLocalPlayer(), 0), Entity.GetHitboxPosition(enemies[e], 0))]);
    }
    dists.sort(function(a, b)
    {
        return a[1] - b[1];
    });
    if(dists.length == 0 || dists == []) return target = -1;
    return dists[0][0];
}

// clean dist func, thanks rzr
function calcDist(a, b){
    var x = a[0] - b[0];
    var y = a[1] - b[1];
    var z = a[2] - b[2];
    return Math.sqrt(x * x + y * y + z * z);
}

function get_metric_distance(a, b){
    return Math.floor(Math.sqrt(Math.pow(a[0] - b[0], 2) + Math.pow(a[1] - b[1], 2) + Math.pow(a[2] - b[2], 2)) * 0.0254);
}

function radians_to_degrees(radians) {
  return radians * (180 / Math.PI);
}

function angle_to_vec(pitch, yaw){
    var p = degree_to_radian(pitch);
    var y = degree_to_radian(yaw)

    var sin_p = Math.sin(p);
    var cos_p = Math.cos(p);
    var sin_y = Math.sin(y);
    var cos_y = Math.cos(y);

    return [cos_p*cos_y, cos_p*sin_y, -sin_p];
}


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_circle_3d(x, y, z, radius, degrees, start_at, fill_clr, filled, clr){
    var accuracy = 10;
    var old_x, old_y;
    start_at = start_at + 1;
    for(rot = start_at; rot < degrees + start_at + 1; rot += accuracy){
        rot_r = rot*(Math.PI/180)
        line_x = radius * Math.cos(rot_r) + x, line_y = radius * Math.sin(rot_r) + y
        var curr = Render.WorldToScreen([line_x, line_y, z]), cur = Render.WorldToScreen([x, y, z]);
        if(cur[0] != null && curr[0] != null && old_x != null){
            if (filled) Render.Polygon([[curr[0], curr[1]], [old_x, old_y], [cur[0], cur[1]]], fill_clr)
            Render.Line(curr[0], curr[1], old_x, old_y, clr);
            Render.Line(curr[0] - 1, curr[1] - 1, old_x - 1, old_y - 1, clr);
            //Render.Line(curr[0] - 2, curr[1] - 2, old_x - 2, old_y - 2, clr);
        }
        old_x = curr[0], old_y = curr[1];
    }
}

function renderArc(x, y, r1, r2, s, d, col){
    for (var i = s; i < s + d; i++){
        const rad = i * Math.PI / 180;
        Render.Line(x + Math.cos(rad) * r1, y + Math.sin(rad) * r1, x + Math.cos(rad) * r2, y + Math.sin(rad) * r2, col);
    }
}

function can_shift_shot(ticks_to_shift) {
    local = Entity.GetLocalPlayer();
    var wpn = Entity.GetWeapon(local);

    if (local == null || wpn == null)
        return false;

    var tickbase = Entity.GetProp(local, "CCSPlayer", "m_nTickBase");
    var curtime = Globals.TickInterval() * (tickbase-ticks_to_shift)

    if (curtime < Entity.GetProp(local, "CCSPlayer", "m_flNextAttack"))
        return false;

    if (curtime < Entity.GetProp(wpn, "CBaseCombatWeapon", "m_flNextPrimaryAttack"))
        return false;

    return true;
}

var csgo_weapons = {
    "0": "none",
    "1": "deagle",
    "2": "elite",
    "3": "fiveseven",
    "4": "glock",
    "5": "p228",
    "6": "usp",
    "7": "ak47",
    "8": "aug",
    "9": "awp",
    "10": "famas",
    "11": "g3sg1",
    "12": "galil",
    "13": "galilar",
    "14": "m249",
    "15": "m3",
    "16": "m4a4",
    "17": "mac10",
    "18": "mp5navy",
    "19": "p90",
    "20": "ssg08",
    "21": "sg550",
    "22": "sg552",
    "23": "tmp",
    "24": "ump45",
    "25": "xm1014",
    "26": "bizon",
    "27": "mag7",
    "28": "negev",
    "29": "sawedoff",
    "30": "tec9",
    "31": "taser",
    "32": "hkp2000",
    "33": "mp7",
    "34": "mp9",
    "35": "nova",
    "36": "p250",
    "37": "scar17",
    "38": "scar20",
    "39": "sg556",
    "40": "ssg08",
    "41": "knifegg",
    "42": "knife",
    "43": "flashbang",
    "44": "hegrenade",
    "45": "smokegrenade",
    "46": "molotov",
    "47": "decoy",
    "48": "incgrenade",
    "49": "c4",
    "60": "m4a1",
    "63": "cz75",
    "64": "revolver",
    "197108": "knife",
    "197113": "knife",
    "197114": "knife",
    "197115": "knife",
    "197116": "knife",
    "197123": "knife",
    "197120": "knife",
    "197128": "knife",
    "197124": "knife",
    "197130": "knife",
    "197122": "knife",
    "197117": "knife",
    "197131": "knife",
    "197127": "knife",
    "197111": "knife",
    "197125": "knife",
    "197126": "knife",
    "197129": "knife",
    "197133": "knife",
    "262205": "usp",
    "262208": "revolver"
};
function getWeaponName(){
    var weapon = Entity.GetProp(Entity.GetWeapon(Entity.GetLocalPlayer()), "DT_WeaponBaseItem", "m_iItemDefinitionIndex");
    return csgo_weapons[weapon];
}

function canShoot(player){
    var index = Entity.GetWeapon(player)
    var classid = Entity.GetClassID(index);
    
    var weapon =  classid == 107 || classid == 108 || classid == 96 || classid == 99 || classid ==112 || classid == 155 || classid == 47;//checking if the selected weapon is knife or nade
    var clip = Entity.GetProp(index, "DT_BaseCombatWeapon", "m_iClip1");
    var getbuttons = Entity.GetProp(index,'CBasePlayer', 'm_fFlags');
    if(weapon || clip == 0 || getbuttons & 1 << 1 )//check if player is jumping or as an empty mag // UserCMD.GetButtons() & (1 << 1)
        return false;
    return true;
}

function isSlowwalking(){
    return UI.IsHotkeyActive("Anti-Aim", "Extra", "Slow walk");
}

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

function fakelag(state){
    UI.SetValue("Anti-Aim", "Fake-Lag", "Enabled", state);
}

function alp(c, a) {
  return [c[0], c[1], c[2], a]
}

function clamp(v, min_int, max_int){
    return Math.max(Math.min(v, max_int), min_int);
}

function VectorNew(array){
    return {
        x: array[0],
        y: array[1],
        z: array[2]
    }
}

function VectorToArray(vector) {
    return [vector['x'], vector['y'], vector['z']]
}

function VectorOperate(a, b, operation) {
    switch (operation){
        case '+':
            return {
                x: a.x + b.x,
                y: a.y + b.y,
                z: a.z + b.z
            };
        case '-':
            return {
                x: a.x - b.x,
                y: a.y - b.y,
                z: a.z - b.z
            };
        case '*':
            return {
                x: a.x * b.x,
                y: a.y * b.y,
                z: a.z * b.z
            };
        case '/':
            return {
                x: a.x / b.x,
                y: a.y / b.y,
                z: a.z / b.z
            };
    }
}

var meme_text = "CTACcord";

function duplicate(theObject) {
    return JSON.parse(JSON.stringify(theObject));
}

function degree_to_radian(degree){
    return degree * Math.PI / 180.0;
}

function ExtendVector(vector, angle, extension){
    var radianAngle = degree_to_radian(angle);
    return [extension * Math.cos(radianAngle) + vector[0], extension * Math.sin(radianAngle) + vector[1], vector[2]];
}

function VectorAdd(a, b){
    return [a[0] + b[0], a[1] + b[1], a[2] + b[2]];
}

function VectorDot(a, b){
    return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}

function VectorLength(x, y, z){
    return Math.sqrt(x * x + y * y + z * z);
}

function VectorNormalize(vec){
    var length = VectorLength(vec[0], vec[1], vec[2]);
    return [vec[0] / length, vec[1] / length, vec[2] / length];
}

function VectorSubtract(a, b){
    return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
}

function VectorMultiply(a, b){
    return [a[0] * b[0], a[1] * b[1], a[2] * b[2]];
}

function VectorDistance(a, b){
    return VectorLength(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
}

function VectorAngles(forward){
    var angles;
    var tmp, yaw, pitch;
    
    if (forward[1] == 0 && forward[0] == 0){
        yaw = 0;
        if (forward[2] > 0)
            pitch = 270;
        else
            pitch = 90;
    }
    else{
        yaw = (Math.atan2(forward[1], forward[0]) * 180 / Math.PI);
        if (yaw < 0)
            yaw += 360;
        tmp = Math.sqrt (forward[0]*forward[0] + forward[1]*forward[1]);
        pitch = (Math.atan2(-forward[2], tmp) * 180 / Math.PI);
        if (pitch < 0)
            pitch += 360;
    }
    
    x = pitch;
    y = yaw;
    z = 0;
    angles = [x, y, z];
    
    return angles;
}

function ClosestPointOnRay(target, rayStart, rayEnd){
    var to = VectorSubtract(target, rayStart);
    var dir = VectorSubtract(rayEnd, rayStart);
    var length = VectorLength(dir[0], dir[1], dir[2]);
    dir = VectorNormalize(dir);

    var rangeAlong = VectorDot(dir, to);
    if (rangeAlong < 0.0)
    {
        return rayStart;
    }
    if (rangeAlong > length)
    {
        return rayEnd;
    }
    return VectorAdd(rayStart, VectorMultiply(dir, [rangeAlong, rangeAlong, rangeAlong]));
}


function setHotkey(path, state){
    if(UI.IsHotkeyActive(path) !== state){
        UI.ToggleHotkey(path);
    }
}

function update_anti_aim_state(state) {
    if(UI.GetValue('Rage', 'GENERAL', 'General', 'Enabled')){
        if (UI.IsHotkeyActive('Anti-Aim', 'Fake angles', 'Inverter') !== state){
            UI.ToggleHotkey('Anti-Aim', 'Fake angles', 'Inverter');
        }
        return;
    }
}

function exploitsActive(type){
    var hideshots = UI.IsHotkeyActive("Rage", "GENERAL", "Exploits", "Hide shots") && UI.GetValue("Rage", "GENERAL", "Exploits", "Hide shots");
    var doubletap = UI.IsHotkeyActive("Rage", "GENERAL", "Exploits", "Doubletap") && UI.GetValue("Rage", "GENERAL", "Exploits", "Doubletap");
    if(type == "hs"){
        return hideshots;
    }
    if(type == "dt"){
        return doubletap;
    }
    if(type == "all"){
        return (hideshots || doubletap);
    }
}

function can_shoot(Player){
    var index = Entity.GetWeapon(Player);
    var classid = Entity.GetClassID(index);
    
    var weapon =  classid == 107 || classid == 108 || classid == 96 || classid == 99 || classid ==112 || classid == 155 || classid == 47;
    var clip = Entity.GetProp(index, "DT_BaseCombatWeapon", "m_iClip1");
    var getbuttons = Entity.GetProp(index,'CBasePlayer', 'm_fFlags' );
    if(weapon || clip == 0 || getbuttons & 1 << 1 ) return false;
    return true;
}

for(var element in script_items){
    for(i = 0; i < script_items[element].length; i++){
        addScriptItem(script_items[element][i]);
    }
}
function addScriptItem(item){
    if(item["type"] == "color"){
        UI.AddColorPicker(item["name"]);
        UI.SetColor("Script items", item["name"], [255, 255, 255, 255]);
    }
    if(item["type"] == "hotkey"){
        UI.AddHotkey(item["name"]);
    }
    if(item["type"] == "checkbox"){
        UI.AddCheckbox(item["name"]);
    }
    if(item["type"] == "dropdown"){
        UI.AddDropdown(item["name"], item["elements"]);
    }
    if(item["type"] == "slider"){
        UI.AddSliderInt(item["name"], item["min"], item["max"]);
        if("default" in item) UI.SetValue("Script items", item["name"], item["default"]);
    }
    if(item["type"] == "multi"){
        UI.AddMultiDropdown(item["name"], item["elements"]);
    }
    if(item["type"] == "textbox"){
        UI.AddTextbox(item["name"]);
    }
}

function scriptItems(){
    if(!UI.IsMenuOpen()) return;
    show_items = GetValue("Show " + name_text + " items");
    for(var checkbox in checkboxes){
        checkbox = checkboxes[checkbox];
        if(checkbox in script_items){
            if(GetVal(checkbox) == true){
                for(i = 0; i < script_items[checkbox].length; i++){
                    UI.SetEnabled("Script items", script_items[checkbox][i]["name"], show_items);
                }
            }
            else{
                for(i = 0; i < script_items[checkbox].length; i++){
                    UI.SetEnabled("Script items", script_items[checkbox][i]["name"], false);
                }
            }
        }
    }
}

UI.IsCursorInBox = function(x, y, width, height) {
    var cursor = Input.GetCursorPosition()
    if (cursor[0] > x && cursor[0] < x + width && cursor[1] > y && cursor[1] < y + height)
        return true
    return false
}


function GetValue(name){
    return UI.GetValue("Script items", name);
}

function GetVal(id){
    return UI.GetValue("Script items", name_text + "_" + id);
}

log("Initialized all other functions");

//dangerous. shitcode
//this script is a shitcode itself tbh
for(hitbox in safety_hitboxes){
    var text = name_text + "_safety_";
    UI.AddCheckbox(text + hitbox + "_safe");
    UI.AddCheckbox(text + hitbox + "_lethal");
    UI.AddCheckbox(text + hitbox + "_force");
    UI.SetEnabled("Script items", text + hitbox + "_safe", false);
    UI.SetEnabled("Script items", text + hitbox + "_lethal", false);
    UI.SetEnabled("Script items", text + hitbox + "_force", false);
}
var tab_names = Object.keys(menu_elements);
var loadedSettings = 0;
var elementsAreReady = false;
var loadSettingsCount = 0;
function loadSettings(){
    if(settingsAreLoaded) return;
    if(!settingsAreLoaded){
        loadedSettings++;
    }
    log("Loading settings");
    for(i = 0; i < tab_names.length; i++){
        var tabname = tab_names[i];
        var subtab_names = Object.keys(menu_elements[tab_names[i]]);
        subtabs_names[tabname] = subtab_names;
        selected_subtabs[tab_names[i]] = subtabs_names[tab_names[i]][0];
        for(s = 0; s < subtab_names.length; s++){
            var subtab = subtab_names[s];
            var box_names = Object.keys(menu_elements[tabname][subtab]);
            var boxes = menu_elements[tabname][subtab];
            for(b = 0; b < box_names.length; b++){
                var box_name = box_names[b];
                var box = boxes[box_name];
                for(e = 0; e < box.length; e++){
                    var element = box[e];
                    var element_name = name_text + "_" + element["id"];
                    switch(element["type"]){
                        case "checkbox":
                            if(!elementsAreReady)
                                UI.AddCheckbox(element_name);
                            checkboxes.push(element["id"]);
                            break;
                        case "slider":
                            if(!elementsAreReady)
                                UI.AddSliderInt(element_name, element["min"], element["max"]);
                            if("default" in element){
                                if(!elementsAreReady)
                                    UI.AddCheckbox(element_name + "_not_def");
                                if(!UI.GetValue("Script items", element_name + "_not_def"))
                                    UI.SetValue("Script items", element_name, element["default"]);
                                UI.SetEnabled("Script items", element_name + "_not_def", false);   
                            }
                            var value = UI.GetValue("Script items", element_name);
                            value = clamp(value, element["min"], element["max"]);
                            UI.SetValue("Script items", element_name, value);
                            break;
                    }   
                    UI.SetEnabled("Script items", element_name, false);           
                }
            }
        }
    }
    loadSettingsCount++;
    for(hitbox in safety_hitboxes){
        var text = name_text + "_safety_";
        safety_hitboxes[hitbox][0] = UI.GetValue("Script items", text + hitbox + "_safe");
        safety_hitboxes[hitbox][1] = UI.GetValue("Script items", text + hitbox + "_lethal");
        safety_hitboxes[hitbox][2] = UI.GetValue("Script items", text + hitbox + "_force");
    }
    if(!elementsAreReady){
        elementsAreReady = true;
    }
    else{
        if(loadSettingsCount >= 64){
            settingsAreLoaded = true;
            scriptItems();
        }
    }
}
var block_set9 = false;
function drawMenu(){
    //log("Starting drawing menu");
    //OTC3 CORD MADE BY @ZXSLEEBU
    if(UI.IsMenuOpen()){
        Cheat.ExecuteCommand("fps_max 99");
        block_set9 = false;
    }
    else{
        if(!block_set9){
            Cheat.ExecuteCommand("fps_max 400");
            block_set9 = true;
        }
        return;
    }

    //Fonts
    var logo_font = Render.AddFont("Segoe UI", 20, 800);
    icon_font = Render.AddFont("menu_font", 16, 300);
    text_icon_font = Render.AddFont("Segoe UI", 10, 800);
    menu_font = Render.AddFont("Segoe UI", 10, 300);
    subtabs_font = Render.AddFont("Segoe UI", 7, 800);

    //Clearing the hint text
    hint_text = "";
    
    //Gradient line
    Render.FilledCircle(x + header_radius, y + header_radius + 1, header_radius, [217, 157, 86, 255]);
    Render.FilledCircle(x + width - header_radius - 3, y + header_radius + 1, header_radius + 2, [217, 157, 86, 255]);
    Render.GradientRect(x, y + 4, (width / 2), 8, 1, [217, 157, 86, 255], [223, 174, 97, 255]);
    Render.GradientRect(x + (width / 2), y + 4, (width / 2), 8, 1, [223, 174, 97, 255], [217, 157, 86, 255]);
    Render.GradientRect(x + header_radius, y, (width / 2) - header_radius, 8, 1, [217, 157, 86, 255], [223, 174, 97, 255]);
    Render.GradientRect(x + (width / 2), y, (width / 2) - header_radius, 8, 1, [223, 174, 97, 255], [217, 157, 86, 255]);
    Render.Line(x + 3, y + 1, x + width - 3, y + 1, [217, 157, 86, 255]);

    //Top bright line
    Render.Line(x + 3, y, x + width - 3, y, bright_line_color);

    //Left bright lines
    Render.Line(x, y + 3, x + 2, y, bright_line_color);
    Render.Line(x, y + 2, x, y + 8, bright_line_color);
    Render.Line(x + 1, y + 3, x + 3, y, [217, 157, 86, 255]);

    //Right bright lines
    Render.Line(x + width - 1, y + 3, x + width - 3, y, bright_line_color);
    Render.Line(x + width - 1, y + 2, x + width - 1, y + 8, bright_line_color);

    //Bottom bright line
    Render.Line(x, y + 8, x + width - 1, y + 8, bright_line_color);
    
    //Background
    Render.FilledRect(x + 2, y + 8, width - 4, height - 12, background_color);
    Render.FilledRect(x + 6, y + height - 6, width - 12, 4, background_color);
    Render.Polygon([[x + 2, y + height - 5], [x + 6, y + height - 5], [x + 6, y + height - 1]], background_color);
    Render.Polygon([[x + width - 2, y + height - 5], [x + width - 6, y + height - 1], [x + width - 6, y + height - 5]], background_color);

    //Borders
    Render.Line(x, y + 8, x, y + height - 6, [31, 33, 37, 255]);
    Render.Line(x + width - 1, y + 8, x + width - 1, y + height - 6, [31, 33, 37, 255]);
    Render.Line(x, y + height - 5, x + 4, y + height - 1, [31, 33, 37, 255]);
    Render.Line(x + 4, y + height - 1, x + width - 5, y + height - 1, [31, 33, 37, 255]);
    Render.Line(x + width - 1, y + height - 5, x + width - 4, y + height - 2, [31, 33, 37, 255]);
    Render.Line(x + 1, y + 8, x + 1, y + height - 5, [77, 81, 88, 255]);
    Render.Line(x + width - 2, y + 8, x + width - 2, y + height - 6, [77, 81, 88, 255]);
    Render.Line(x + 1, y + height - 5, x + 4, y + height - 2, [77, 81, 88, 255]);
    Render.Line(x + 5, y + height - 2, x + width - 6, y + height - 2, [77, 81, 88, 255]);
    Render.Line(x + width - 2, y + height - 5, x + width - 6, y + height - 2, [77, 81, 88, 255]);
    
    //Header gradient transition
    Render.GradientRect(x + 1, y + 8, width - 2, 9, 0, [98, 86, 69, 255], [98, 86, 69, 0]);

    //Footer
    Render.Line(x + 10, y + height - 28, x + width - 10, y + height - 28, line_color);

    var text_size2 = Render.TextSizeCustom("Made by @zxsleebu", menu_font);
    Render.StringCustom(x + width - 14 - text_size2[0], y + height - 26, 0, "Made by @zxsleebu", text_color, menu_font);
    Render.StringCustom(x + 15, y + height - 26, 0, "Update: " + last_upd + "; v" + version, text_color, menu_font);
    if(UI.IsCursorInBox(x + width - 14 - text_size2[0], y + height - 27, text_size2[0], text_size2[1] + 1)){
        hint_text = "Discord: Sleebu#0448\nTelegram: @zxsleebu\nInstagram: @zxsleebu\nInvite me to skeet :)";
        hint_size = Render.TextSizeCustom(hint_text, menu_font);
        hint_y = cursor_pos[1] + checkbox_height;
        hint_x = clamp(cursor_pos[0] - (box_margin_x * 2) - hint_size[0], 0, screen_size[0]);
    }

    if(!settingsAreLoaded)
        return renderLoading();

    //Name
    Render.StringCustom(x + 14, y + 17, 0, name_text, text_color, logo_font);
    var text_size = Render.TextSizeCustom(name_text, logo_font);
    
    //Vertical line after name
    Render.Line(x + 14 + text_size[0] + 8, y + 22, x + 14 + text_size[0] + 8, y + 21 + text_size[1], line_color);

    //Horizontal line below header
    Render.Line(x + 10, y + 21 + text_size[1] + 8, x + width - 10, y + 21 + text_size[1] + 8, line_color);
    
    //Preparing variables
    tab_start = x + 14 + text_size[0] + 8 + 15;
    subtab_text_pos = y + 23 + text_size[1] + 8 + 8 + 50 - 8;
    subtab_start = y + 23 + text_size[1] + 8 + 8;

    //Menu tabs
    renderTabs(tab_names);
    
    //Subtabs
    Render.FilledRect(x + 14, y + 23 + text_size[1] + 8 + 8, subtabs_width, 50, element_color);
    Render.Rect(x + 15, y + 23 + text_size[1] + 8 + 8 + 1, subtabs_width - 2, 48, element_border_color);
    
    renderSubtabs(subtabs_names);

    //Menu elements and boxes
    renderElements();

    //Render hints on top of the all
    renderHints();

    drawPlayerList();

    drawSafetySystem();
}

function moveMenu(){
    if(!UI.IsMenuOpen()) return;
    cursor_pos = Input.GetCursorPosition();
    if(!Input.IsKeyPressed(0x01)){
        is_moving = false;
        old_cursor = cursor_pos;
    }
    if((cursor_pos[0] >= x && cursor_pos[0] <= x + width && cursor_pos[1] >= y && cursor_pos[1] <= y + 30) || (is_moving)){
        is_moving = true;
        x = cursor_pos[0] - old_cursor[0] + x;
        y = cursor_pos[1] - old_cursor[1] + y;
        UI.SetValue("Script items", name_text + "_x", x);
        UI.SetValue("Script items", name_text + "_y", y);
        old_cursor = cursor_pos;
    }

    x = clamp(x, -width + 5, screen_size[0] - 5);
    y = clamp(y, -28, screen_size[1] - 5);
}

function renderLoading(){
    renderArc(x + width / 2, y + height / 2, 27, 25, Math.pow(loadedSettings, 1.6), 300, [255, 255, 255, 255]);
}

function drawPlayerList(){
    var selected_tab_name = tab_names[selected_tab];
    var selected_subtab = selected_subtabs[selected_tab_name];
    if(selected_subtab !== "Player list") return;
    element_y = subtab_start + 50 + 13;
    var pre_height = 174;
    var textX = x + 23;
    var enemies = Entity.GetEnemies();

    if(!World.GetServerString()){
        renderLabel("Join a server!", textX, element_y);
        height = 280;
        return;
    }

    renderLabel("Force safe point on head", textX, element_y);
    element_y += 24;
    pre_height += 24;

    for(enemy in enemies){
        enemy = enemies[enemy];
        var name = Entity.GetName(enemy);
        var player_id = name + enemy;
        player_list[player_id] = renderCheckbox(name, element_y, false, player_id, player_list[player_id], "");
        element_y += element_margin_bottom + checkbox_height;
        pre_height += element_margin_bottom + checkbox_height;
    }

    height = clamp(pre_height, 280, 999);
}

function drawSafetySystem(){
    var selected_tab_name = tab_names[selected_tab];
    var selected_subtab = selected_subtabs[selected_tab_name];
    if(selected_subtab !== "Safety system") return;
    element_y = subtab_start + 50 + 13;
    var red = [255, 0, 0, 255];
    var green = [0, 255, 0, 255];
    var blue = [0, 0, 255, 255];
    var textX = x + 23;
    renderSmallCircle(textX, element_y + 10, red);
    renderSmallCircle(textX, element_y + 26, green);
    renderSmallCircle(textX, element_y + 44, blue);
    textX += 10;
    renderLabel("LMB - force safe point\nRMB - force safe point if lethal\nMWHEEL Click - force hitbox if lethal", textX, element_y);
    var size = 22;
    var head_color = [255, 255, 255, 255];
    var body_color = [255, 255, 255, 255];
    var legs_color = [255, 255, 255, 255];
    var feet_color = [255, 255, 255, 255];

    if(UI.IsCursorInBox(x + width - (size * 5) + 4, element_y, size * 2, size * 2)){
        safetySystemSet("head");
        head_color = [230, 230, 230, 255];
    }

    if(UI.IsCursorInBox(x + width - (size * 3) - 47, element_y + size * 2 + 3, size * 2.5, size * 5)){
        safetySystemSet("body");
        body_color = [230, 230, 230, 255];
    }

    if(UI.IsCursorInBox(x + width - (size * 3) - 47, element_y + size * 7 + 2, size * 2.5 + 4, size * 3 + 4)){
        safetySystemSet("legs");
        legs_color = [230, 230, 230, 255];
    }

    if(UI.IsCursorInBox(x + width - (size * 3) - 47, element_y + size * 10 + 6, size * 2.5 + 3, size * 0.5)){
        safetySystemSet("feet");
        feet_color = [230, 230, 230, 255];
    }


    //Head
    Render.FilledCircle(x + width - (size * 2) - 40, element_y + size, size, head_color);
    drawSafetySystemDots(x + width - (size * 2) - 38, element_y + size, false, "head");

    //Arms
    rounded_rect(x + width - (size * 4) - 44, element_y + size * 2 + 4, size * 1 - 2, size * 3.5, 8, [255, 255, 255, 255]);
    rounded_rect(x + width - (size * 1) - 33, element_y + size * 2 + 4, size * 1 - 2, size * 3.5, 8, [255, 255, 255, 255]);

    //Legs
    rounded_rect(x + width - (size * 2) - 34, element_y + size * 5 + 4, size * 1, size * 5, 7, legs_color);
    rounded_rect(x + width - (size * 3) - 45, element_y + size * 5 + 4, size * 1, size * 5, 7, legs_color);
    drawSafetySystemDots(x + width - (size * 2) - 25, element_y + size * 8 + 16, true, "legs");
    drawSafetySystemDots(x + width - (size * 3) - 37, element_y + size * 8 + 16, true, "legs");

    //Feet
    rounded_rect(x + width - (size * 2) - 34, element_y + size * 10 + 6, size * 1, size * 0.5, 2, feet_color);
    rounded_rect(x + width - (size * 3) - 45, element_y + size * 10 + 6, size * 1, size * 0.5, 2, feet_color);
    drawSafetySystemDots(x + width - (size * 1.5) - 34, element_y + size * 10 + 12, false, "feet", 6);
    drawSafetySystemDots(x + width - (size * 2.5) - 45, element_y + size * 10 + 12, false, "feet", 6);

    //Body
    rounded_rect(x + width - (size * 3) - 45, element_y + size * 2 + 4, size * 2.5, size * 5, 8, body_color);
    drawSafetySystemDots(x + width - (size * 2) - 38, element_y + size * 4 + 12, false, "body");

    force_lethal = false;
    for(check_hitbox in safety_hitboxes){
        if(safety_hitboxes[check_hitbox][2]){
            force_lethal = true;
            break;
        }
    }

    if(force_lethal){
        for(check_hitbox in safety_hitboxes){
            if(safety_hitboxes[check_hitbox][1] && !safety_hitboxes[check_hitbox][2]){
                safety_hitboxes[check_hitbox][1] = false;
            }
        }
    }

    height = 420;
}

function safetySystemSet(hitbox){
    var anykey_pressed = Input.IsKeyPressed(0x01) || Input.IsKeyPressed(0x02) || Input.IsKeyPressed(0x04);
    if(anykey_pressed && !click_block){
        click_block = true;
        if(Input.IsKeyPressed(0x01)){
            safety_hitboxes[hitbox][0] = !safety_hitboxes[hitbox][0];
        }
        if(Input.IsKeyPressed(0x02)){
            if(force_lethal && !safety_hitboxes[hitbox][2]){
                safety_hitboxes[hitbox][1] = false;
                return;
            }
            else{
                safety_hitboxes[hitbox][1] = !safety_hitboxes[hitbox][1];
            }
        }
        if(Input.IsKeyPressed(0x04)){
            safety_hitboxes[hitbox][2] = !safety_hitboxes[hitbox][2];
        }
    }
    if(!anykey_pressed){
        click_block = false;
    }
    for(hitbox in safety_hitboxes){
        var text = name_text + "_safety_";
        UI.SetValue("Script items", text + hitbox + "_safe", safety_hitboxes[hitbox][0]);
        UI.SetValue("Script items", text + hitbox + "_lethal", safety_hitboxes[hitbox][1]);
        UI.SetValue("Script items", text + hitbox + "_force", safety_hitboxes[hitbox][2]);
    }
}

function drawSafetySystemDots(x, y, vertical, hitbox, space){
    hitbox = safety_hitboxes[hitbox];
    var dot_count = hitbox[0] + hitbox[1] + hitbox[2];
    var red = [255, 0, 0, 255];
    var green = [0, 255, 0, 255];
    var blue = [0, 0, 255, 255];
    if(space === null || space === undefined){
        space = 8;
    }
    (!vertical) ? x -= dot_count * (space / 2) : y -= dot_count * (space / 2);
    for(type in hitbox){
        if(hitbox[type] == true){
            var color = ((type == 0) ? red : ((type == 1) ? green : blue));
            renderSmallCircle(x, y, color);
            (!vertical) ? x += space : y += space;
        }
    }
}

function renderTabs(tabs){
    for(i = 0; i < tabs.length; i++){
        var name = tabs[i];
        var color = tab_active_color;
        var animate_speed = 11;
        cursor_pos = Input.GetCursorPosition();
        var font = Render.AddFont("Segoe UI", 10, 900);
        var text_size = Render.TextSizeCustom(name, font);
        var x1 = tab_start + ((tab_margin + tab_width) * i);
        var y1 = y + 29;
        var x2 = tab_start + ((tab_margin + tab_width) * i) + tab_width;
        var y2 = y + 29 + 22;
        color[3] = tab_colors[i];

        //if(cursor_pos[0] >= x1 && cursor_pos[0] <= x2 && cursor_pos[1] >= y1 && cursor_pos[1] <= y2 || i == selected_tab){
        if(UI.IsCursorInBox(x1, y1, tab_width, 22) || i == selected_tab){
            if(Input.IsKeyPressed(0x01) && !is_moving){
                selected_tab = i;
            }
            color[3] += (color[3] > 100) ? (animate_speed / 1.5) : animate_speed;
        }
        else{
            color[3] -= animate_speed;
        }
        if(color[3] > 255){
            color[3] = 255;
        }
        else{
            if(color[3] < 0){
                color[3] = 0;
            }
        }
        tab_colors[i] = color[3];
        rounded_rect(x1, y1, tab_width, 22, 2, color);
        /*Render.FilledRect(x1, y1, tab_width, 22, color);*/
        Render.StringCustom(x1 + (tab_width / 2) - (text_size[0] / 2), y1 + 11 - (text_size[1] / 2), 0, name, text_color, font);
    }
}

function renderSubtabs(subtabs){
    //0TC3 C0RD M4D3 BY @Z X S L 3 3 B U
    var name = tab_names[selected_tab];
    var subtabs_count = subtabs[name].length;
    for(i = 0; i < subtabs_count; i++){
        var subtab = subtabs[name][i].toUpperCase();
        var icon = subtabs_icons[name][subtabs[name][i]];
        var text_icon = subtabs_text_icons[name][subtabs[name][i]];
        var text_size = Render.TextSizeCustom(subtab, subtabs_font);
        var icon_size = Render.TextSizeCustom(icon, icon_font);
        var text_icon_size = Render.TextSizeCustom(text_icon, text_icon_font);
        var color = subtab_text_color;
        cursor_pos = Input.GetCursorPosition();
        var x1 = x + 14 + ((subtabs_width / subtabs_count) * i);
        var y1 = subtab_start;
        var x2 = x + 14 + ((subtabs_width / subtabs_count) * (i + 1));
        var y2 = subtab_start + 50;
        //if(cursor_pos[0] >= x1 && cursor_pos[0] <= x2 && cursor_pos[1] >= y1 && cursor_pos[1] <= y2 || subtabs[name][i] == selected_subtabs[name]){
        if(UI.IsCursorInBox(x1, subtab_start, (subtabs_width / subtabs_count), 50) || subtabs[name][i] == selected_subtabs[name]){
            if(Input.IsKeyPressed(0x01) && !is_moving){
                selected_subtabs[name] = subtabs[name][i];
            }
            color = text_color;
        }
        var textX = x + 14 + ((subtabs_width / subtabs_count) / 2) - (text_size[0] / 2) + ((subtabs_width / subtabs_count) * i);
        var textY = subtab_text_pos - text_size[1] + 1;
        var iconX = x + 14 + ((subtabs_width / subtabs_count) / 2) - (icon_size[0] / 2) + ((subtabs_width / subtabs_count) * i);
        var iconY = subtab_text_pos - text_size[1] - 4 - icon_size[1];
        var text_iconX = x + 14 + ((subtabs_width / subtabs_count) / 2) - (text_icon_size[0] / 2) + ((subtabs_width / subtabs_count) * i);
        var text_iconY = subtab_text_pos - text_size[1] - 5 - text_icon_size[1];
        
        Render.StringCustom(textX, textY, 0, subtab, color, subtabs_font);
        Render.StringCustom(iconX, iconY, 0, icon, color, icon_font);
        Render.StringCustom(text_iconX, text_iconY, 0, text_icon, color, text_icon_font);
    }
}

function renderBox(name, height, right){
    box_width = ((width - (15 * 2)) / 2) - 12;
    var boxX = (right) ? x + 15 + box_width + 24 : x + 15;
    var boxY = subtab_start + box_offsets[(right) ? 1 : 0] + 50 + 13;

    Render.Line(boxX, boxY + height - 3, boxX + 3, boxY + height, line_color);
    Render.Line(boxX + box_width, boxY + height - 3, boxX + box_width - 3, boxY + height, line_color);

    Render.Line(boxX, boxY, boxX, boxY + height - 3, line_color);
    Render.Line(boxX + box_width, boxY, boxX + box_width, boxY + height - 3, line_color);
    Render.Line(boxX + 3, boxY + height, boxX + box_width - 4, boxY + height, line_color);
    
    var text_size = Render.TextSizeCustom(name, menu_font);
    
    var textX = boxX + (box_width / 2) - (text_size[0] / 2);
    Render.GradientRect(boxX, boxY, (box_width / 2) - (text_size[0] / 2) - 4, 1, 1, [217, 157, 86, 255], [246, 207, 135, 255]);
    Render.GradientRect(textX + text_size[0] + 4, boxY, (box_width / 2) - Math.floor(text_size[0] / 2) - 3, 1, 1, [246, 207, 135, 255], [217, 157, 86, 255]);
    Render.StringCustom(textX, boxY - (text_size[1] / 2) - 1, 0, name, text_color, menu_font);
    box_offsets[(right) ? 1 : 0] += height + 18;
}

function renderElements(){
    var selected_tab_name = tab_names[selected_tab];
    var selected_subtab = selected_subtabs[selected_tab_name];
    var subtab_boxes_names = Object.keys(menu_elements[selected_tab_name][selected_subtab]);
    var subtab_boxes = menu_elements[selected_tab_name][selected_subtab];

    for(i = 0; i < subtab_boxes_names.length; i++){
        var box_name = subtab_boxes_names[i];
        var box_height = box_margin_top;
        var side = i % 2;
        if(box_offsets[0] > 250){
            side = 1;
        }

        for(e = 0; e < subtab_boxes[box_name].length; e++){
            element_y = subtab_start + 50 + 13;
            var element = subtab_boxes[box_name][e];
            if("master" in element && (!GetVal(element["master"]))) continue;
            if(element["master"] == "mindamage_advanced" && !GetVal("mindamage")) continue;
            switch(element["type"]){
                case "checkbox":
                    var visible = ("visible" in element) ? element["visible"] : true;
                    if(!visible && !GetVal("useless_features")) break;
                    element_y += box_offsets[side] + box_height;
                    var hint = ("hint" in element) ? element["hint"] : "";
                    renderCheckbox(element["name"], element_y, side, element["id"], GetVal(element["id"]), hint);
                    box_height += element_margin_bottom + checkbox_height;
                    break;
                case "slider":
                    var visible = ("visible" in element) ? element["visible"] : true;
                    if(!visible && !GetVal("useless_features")) break;
                    element_y += box_offsets[side] + box_height;
                    var min = ("min" in element) ? element["min"] : 0;
                    var max = ("max" in element) ? element["max"] : 0;
                    var append = ("append" in element) ? element["append"] : "";
                    renderSlider(element["name"], element_y, side, element["id"], min, max, append);
                    box_height += element_margin_bottom + slider_height + 18;
                    break;
            }
        }

        box_height += box_margin_bottom;
        renderBox(box_name, box_height, side);
    }

    if(selected_subtab !== "Player list" && selected_subtab !== "Safety system"){
        height = Math.max.apply(null, box_offsets) + 164;
    }

    //0TC3 (if) C0RD (you) M4D3 (remove) BY (this) @ Z Х S L 3 3 В U (you're gay)
    box_offsets = [0, 0];
}

function renderCheckbox(name, checkboxY, right, id, active, hint){
    var checkboxX = ((right) ? x + 15 + box_width + 24 : x + 15) + box_margin_x;
    var text_size = Render.TextSizeCustom(name, menu_font);
    var textX = ((right) ? x + 15 + box_width + 24 : x + 15) + box_text_margin_x;
    var color = element_color;
    var color2 = element_border_color2;
    var checkboxX2 = checkboxX + checkbox_width;
    var checkboxY2 = checkboxY + checkbox_height;
    var elementWidth = checkboxX + box_width - box_margin_x * 2;
    var animationSpeed = 12;
    var checkboxState = active;

    if(active){
        color = [217, 157, 86, 255];
        color2 = [217, 157, 86, 255];
    }
    if(id in checkbox_alpha){
        checkbox_alpha[id] = clamp(checkbox_alpha[id], 0, 255);
    }
    if(active){
        checkbox_alpha[id] = 255;
    }
    //if(cursor_pos[0] >= checkboxX && cursor_pos[0] <= elementWidth && cursor_pos[1] >= checkboxY && cursor_pos[1] <= checkboxY2 && !slider_changing){
    if(UI.IsCursorInBox(checkboxX, checkboxY, box_width - box_margin_x * 2, checkbox_height) && !slider_changing){
        if(id in script_items){
            var circle_y_start = checkboxY + (checkbox_height / 2) + 1;
            var circle_x_start = elementWidth - 10;
            if(hint !== ""){
                circle_x_start = elementWidth - 28;
            }
            renderSmallCircle(circle_x_start, circle_y_start, element_active_color);
            //Render.FilledCircle(elementWidth - 27, checkboxY + (checkbox_height / 2), 3, element_active_color);
            //Render.FilledRect(elementWidth - 27, checkboxY + (checkbox_height / 2) - 2, 4, 4, element_active_color);
            if(cursor_pos[0] >= circle_x_start - 4 && cursor_pos[0] <= circle_x_start + 12 && cursor_pos[1] >= checkboxY && cursor_pos[1] <= checkboxY2){
                hint_text = "This function has settings in the Script items";
                //hint_size = Render.TextSizeCustom(hint_text, menu_font);
                hint_x = cursor_pos[0] + box_margin_x;
                /*var hint_overflowing_menu = (hint_x + hint_size[0] + 3 > x + width + 50);
                var hint_overflowing_screen = (hint_x - hint_size[0] - 9 < screen_size[0]) && (hint_x + hint_size[0] + 9 > screen_size[0]);
                var hint_overflowing = (hint_overflowing_screen && !right) || (right && !hint_overflowing_screen);*/
                var hint_overflowing = hint_x - 100 > screen_size[0] / 2;
                if(hint_overflowing){
                    hint_x = cursor_pos[0] - (box_margin_x * 2) - hint_size[0];
                }
                hint_y = cursor_pos[1] + checkbox_height;
            }
        }
        if(hint !== ""){
            var hint_icon_font = Render.AddFont("menu_font", 12, 300);
            Render.StringCustom(elementWidth - 16, checkboxY - 1, 0, "G", text_color, hint_icon_font);

            if(cursor_pos[0] >= elementWidth - 17 && cursor_pos[0] <= elementWidth + 1 && cursor_pos[1] >= checkboxY && cursor_pos[1] <= checkboxY2){
                hint_text = hint;
                //hint_size = Render.TextSizeCustom(hint_text, menu_font);
                hint_x = cursor_pos[0] + box_margin_x;
                /*var hint_overflowing_menu = (hint_x + hint_size[0] + 3 > x + width + 50);
                var hint_overflowing_screen = (hint_x - hint_size[0] - 9 < screen_size[0]) && (hint_x + hint_size[0] + 9 > screen_size[0]);
                var hint_overflowing = (hint_overflowing_screen && !right) || (right && !hint_overflowing_screen);*/
                var hint_overflowing = hint_x - 100 > screen_size[0] / 2;
                if(hint_overflowing){
                    hint_x = cursor_pos[0] - (box_margin_x * 2) - hint_size[0];
                }
                hint_y = cursor_pos[1] + checkbox_height;
            }       
        }
    }
    if(UI.IsCursorInBox(checkboxX - 1, checkboxY - 1, textX - checkboxX + text_size[0] + 1, checkbox_height + 3) && !slider_changing){
        if(Input.IsKeyPressed(0x01) && !is_moving){
            if(!click_block){
                checkboxState = !checkboxState;
                UI.SetValue("Script items", name_text + "_" + id, !GetVal(id));
                click_block = true;
            }
            color = [217, 157, 86, 255];
        }
        else{
            click_block = false;
        }
        color2 = [217, 157, 86, 255];
        if(!(id in checkbox_alpha)){
            checkbox_alpha[id] = 0;
        }
        color2[3] = (checkbox_alpha[id] = clamp(checkbox_alpha[id] + animationSpeed, 0, 255));
    }
    else{
        if((id in checkbox_alpha) && checkbox_alpha[id] > 5 && !GetVal(id)){
            color2 = [217, 157, 86, 255];
            color2[3] = (checkbox_alpha[id] = clamp(checkbox_alpha[id] - animationSpeed, 0, 255));
        }
    }

    //Inactive border
    //Vertical
    Render.Line(checkboxX, checkboxY + 1, checkboxX, checkboxY + checkbox_height - 2, element_border_color2);
    Render.Line(checkboxX + checkbox_width - 1, checkboxY + 1, checkboxX + checkbox_width - 1, checkboxY + checkbox_height - 2, element_border_color2);
    //Horizontal
    Render.Line(checkboxX + 1, checkboxY, checkboxX + checkbox_width - 2, checkboxY, element_border_color2);
    Render.Line(checkboxX + 1, checkboxY + checkbox_height - 1, checkboxX + checkbox_width - 2, checkboxY + checkbox_height - 1, element_border_color2);
    //Fill
    Render.FilledRect(checkboxX + 1, checkboxY + 1, checkbox_width - 2, checkbox_height - 2, element_border_color2);

    //Active border
    //Vertical
    Render.Line(checkboxX, checkboxY + 1, checkboxX, checkboxY + checkbox_height - 2, color2);
    Render.Line(checkboxX + checkbox_width - 1, checkboxY + 1, checkboxX + checkbox_width - 1, checkboxY + checkbox_height - 2, color2);
    //Horizontal
    Render.Line(checkboxX + 1, checkboxY, checkboxX + checkbox_width - 2, checkboxY, color2);
    Render.Line(checkboxX + 1, checkboxY + checkbox_height - 1, checkboxX + checkbox_width - 2, checkboxY + checkbox_height - 1, color2);
    //Fill
    Render.FilledRect(checkboxX + 1, checkboxY + 1, checkbox_width - 2, checkbox_height - 2, color2);

    //Background
    //Vertical
    Render.Line(checkboxX + 1, checkboxY + 2, checkboxX + 1, checkboxY + checkbox_height - 3, color);
    Render.Line(checkboxX + checkbox_width - 2, checkboxY + 2, checkboxX + checkbox_width - 2, checkboxY + checkbox_height - 3, color);
    //Horizontal
    Render.Line(checkboxX + 2, checkboxY + 1, checkboxX + checkbox_width - 3, checkboxY + 1, color);
    Render.Line(checkboxX + 2, checkboxY + checkbox_height - 2, checkboxX + checkbox_width - 3, checkboxY + checkbox_height - 2, color);
    //Fill
    Render.FilledRect(checkboxX + 2, checkboxY + 2, checkbox_width - 4, checkbox_height - 4, color);

    //Checkbox name
    Render.StringCustom(textX, checkboxY - 2, 0, name, text_color, menu_font);

    //my nickname is numberless. like z x s l e e b u but without spaces
    //why i put so many comments in code?
    //i just wanna to be a bigname, you know :)
    //btw this mеnu іs crеаtеd bу @zхslееbu

    return checkboxState;
}

function renderHints(){
    if(hint_text === "") return;
    hint_size = Render.TextSizeCustom(hint_text, menu_font);
    rounded_rect(hint_x, hint_y, hint_size[0] + 8, hint_size[1] + 4, 2, hintbox_color);
    Render.StringCustom(hint_x + 4, hint_y + 1, 0, hint_text, text_color, menu_font);
    //0TC3 C0RD M4D3 BY @Z X SL3E B U

}

function renderSlider(name, sliderY, right, id, min, max, append, master){
    var sliderX = ((right) ? x + 15 + box_width + 24 : x + 15) + box_text_margin_x - 6;
    var sliderWidth = box_width - box_text_margin_x * 2 + 14;
    var value = GetVal(id);
    var value_start = -1;
    var percent = (sliderWidth - value_start) / Math.abs(max - min);
    var progress = value * percent + value_start;
    value = (value > max) ? max : value;
    value = (value <= min) ? min : value;
    progress = value * percent + value_start - (min * percent);
    progress = (progress > sliderWidth) ? sliderWidth : progress;
    progress = (value == max) ? sliderWidth - 2 : progress;

    //if((cursor_pos[0] >= sliderX && cursor_pos[0] <= sliderX + sliderWidth - 1 && cursor_pos[1] >= sliderY + 16 && cursor_pos[1] <= sliderY + 16 + slider_height && slider_changing == false) || slider_changing == id){
    if((UI.IsCursorInBox(sliderX, sliderY + 16, sliderWidth - 1, slider_height) && slider_changing == false) || slider_changing == id){
        if(Input.IsKeyPressed(0x01) && !is_moving){
            value = clamp(Math.round(((cursor_pos[0] - sliderX) / percent) + min), min, max);
            UI.SetValue("Script items", name_text + "_" + id, value);
            progress = value * percent + value_start - (min * percent);
            progress = (progress > sliderWidth) ? sliderWidth : progress;
            progress = (value == max) ? sliderWidth - 2 : progress;
            slider_changing = id;
            UI.SetValue("Script items", name_text + "_" + id + "_not_def", true);
        }
        else{
            slider_changing = false;
        }

        var value_size = Render.TextSizeCustom(value + append, menu_font);

        var slider_hint_x = (cursor_pos[0] >= (sliderX + sliderWidth - value_size[0] - 8 - 12)) ? (sliderX + sliderWidth - value_size[0] - 9) : cursor_pos[0] + 12;
        slider_hint_x = (slider_hint_x <= sliderX) ? sliderX : slider_hint_x;
        var slider_hint_y = sliderY + 16 + slider_height + 2;
        hint_x = slider_hint_x;
        hint_y = slider_hint_y;
        hint_text = value + append;
        /*Render.FilledRect(slider_hint_x, slider_hint_y, value_size[0] + 8, value_size[1] + 4, hintbox_color);
        Render.StringCustom(slider_hint_x + 4, slider_hint_y + 1, 0, value + append, text_color, menu_font);*/
    }

    //Slider name
    Render.StringCustom(sliderX + 6, sliderY - 4, 0, name, text_color, menu_font);

    //Slider background
    Render.FilledRect(sliderX, sliderY + 16, sliderWidth, slider_height, element_color);

    //Slider border
    //Horizontal
    Render.Line(sliderX, sliderY + 16, sliderX + sliderWidth - 1, sliderY + 16, element_border_color2);
    Render.Line(sliderX, sliderY + 16 + slider_height - 1, sliderX + sliderWidth - 1, sliderY + 16 + slider_height - 1, element_border_color2);
    //Vertical
    Render.Line(sliderX - 1, sliderY + 17, sliderX - 1, sliderY + 17 + slider_height - 3, element_border_color2);
    Render.Line(sliderX + sliderWidth, sliderY + 17, sliderX + sliderWidth, sliderY + 17 + slider_height - 3, element_border_color2);
    //Curves
    Render.Line(sliderX - 1, sliderY + 17, sliderX + 5, sliderY + 16, element_border_color2);
    Render.Line(sliderX - 1, sliderY + 14 + slider_height, sliderX + 5, sliderY + 15 + slider_height, element_border_color2);
    Render.Line(sliderX + sliderWidth, sliderY + 17, sliderX + sliderWidth - 3, sliderY + 16, element_border_color2);
    Render.Line(sliderX + sliderWidth, sliderY + 14 + slider_height, sliderX + sliderWidth - 3, sliderY + 15 + slider_height, element_border_color2);


    //Slider progress
    Render.Line(sliderX + 1, sliderY + 17, sliderX + 1, sliderY + 16 + slider_height - 2, element_active_color);
    Render.Line(sliderX, sliderY + 18, sliderX, sliderY + 16 + slider_height - 3, element_active_color);
    Render.FilledRect(sliderX + 2, sliderY + 17, progress - 2, slider_height - 2, element_active_color);
    if(progress > 2){
        Render.Line(sliderX + progress, sliderY + 17, sliderX + progress, sliderY + 16 + slider_height - 2, element_active_color);
        Render.Line(sliderX + progress + 1, sliderY + 18, sliderX + progress + 1, sliderY + 16 + slider_height - 3, element_active_color);
    }
}

function renderLabel(name, labelX, labelY){
    Render.StringCustom(labelX, labelY, 0, name, text_color, menu_font);
}

function renderSmallCircle(x, y, color){
    Render.Line(x, y + 1, x, y - 2, color);
    Render.Line(x + 1, y + 2, x + 1, y - 3, color);
    Render.Line(x + 2, y + 2, x + 2, y - 3, color);
    Render.Line(x + 3, y + 2, x + 3, y - 3, color);
    Render.Line(x + 4, y + 1, x + 4, y - 2, color);
}

function rounded_rect (from_x, from_y, to_x, to_y, radius, color) {
    var diameter = radius * 2;

    Render.FilledRect(from_x + radius, from_y,          to_x - diameter, to_y,            color); // vertical
    Render.FilledRect(from_x,          from_y + radius, to_x,            to_y - diameter, color); // horizontal

    // top
    Render.FilledCircle(from_x + radius,        from_y + radius,         radius, color); // left
    if(radius < 5){
        Render.FilledCircle(from_x + to_x - radius - 2, from_y + radius,         radius + 1, color); // right
    }
    else{
        Render.FilledCircle(from_x + to_x - radius, from_y + radius,         radius, color); // right
    }
    
    // bottom
    Render.FilledCircle(from_x + radius,        from_y + to_y - radius,  radius, color); // left
    if(radius < 5){
        Render.FilledCircle(from_x + to_x - radius - 2, from_y + to_y - radius - 2,  radius + 2, color); // right
    }
    else{
        Render.FilledCircle(from_x + to_x - radius, from_y + to_y - radius,  radius, color); // right
    }
}

function onUnload(){
    //cuz i luv you and appreciate your time :)
    Exploit.EnableRecharge();
    Exploit.Recharge();
    AntiAim.SetOverride(0);
    Convar.SetString("cl_lock_camera", "0");
    Cheat.ExecuteCommand("-attack2");
    Convar.SetString("fog_override", "0");
    Convar.SetFloat("mat_ambient_light_r", 0);
    Convar.SetFloat("mat_ambient_light_g", 0);
    Convar.SetFloat("mat_ambient_light_b", 0);
    Convar.SetString("mat_force_tonemap_scale", "0");
    Convar.SetFloat("r_modelAmbientMin", 0);
    Cheat.ExecuteCommand("fov_cs_debug 0");
    var entities = Entity.GetEntities();
    for (var i = 0; i < entities.length; i++){
        var entity = entities[i];
        var name = Entity.GetClassName(entity);
        if (name === "CEnvTonemapController"){
            var props = 0;
            if(props == 0){
                Entity.SetProp(entity, 'CEnvTonemapController', 'm_flCustomBloomScale', 0);
                props = 1;
            }
            if(props == 1){
                Entity.SetProp(entity, 'CEnvTonemapController', 'm_bUseCustomAutoExposureMin', false);
                Entity.SetProp(entity, 'CEnvTonemapController', 'm_bUseCustomAutoExposureMax', false);
                Entity.SetProp(entity, 'CEnvTonemapController', 'm_bUseCustomBloomScale', false);
            }
        }
    }
    for(checkbox in script_items){
        checkbox = script_items[checkbox];
        for(script_item in checkbox){
            script_item = checkbox[script_item];
            UI.SetEnabled("Script items", script_item["name"], false);
        }
    }
}

log("Initialized all the drawing functions etc");

//Prioritizing rage functions to have better response time
//idc if it will not work :D

//Main
Global.RegisterCallback("Draw", "updateVars");

//Rage
Global.RegisterCallback("CreateMove", "safetySystem");
Global.RegisterCallback("CreateMove", "dormantAim");
Global.RegisterCallback("weapon_fire", "shoot");
Global.RegisterCallback("CreateMove", "safeAWP");
Global.RegisterCallback("CreateMove", "jumpscout");
Global.RegisterCallback("CreateMove", "minDamageOverride");
Global.RegisterCallback("CreateMove", "safePointOnDT");
Global.RegisterCallback("CreateMove", "autoscope");
Global.RegisterCallback("CreateMove", "forceBackshoot");
Global.RegisterCallback("CreateMove", "preferBaimOnDT");
Global.RegisterCallback("CreateMove", "doubletapBoost");
Global.RegisterCallback("weapon_fire", "on_weapon_fire");
Global.RegisterCallback("CreateMove", "playerList");
Global.RegisterCallback("CreateMove", "zeusHitchance");
Global.RegisterCallback("CreateMove", "autoPeek");
Global.RegisterCallback("ragebot_fire", "ragebotFire");

//Functions that can delay
Global.RegisterCallback("hegrenade_detonate", "on_hegrenade_detonate");
Global.RegisterCallback("player_hurt", "skeletonOnHit");
Global.RegisterCallback("player_hurt", "addHitShot");
Global.RegisterCallback("player_death", "effectOnKill2");
Global.RegisterCallback("item_purchase", "addWeaponInBuyList");

//Anti Aim
Global.RegisterCallback("CreateMove", "idealYaw");
Global.RegisterCallback("CreateMove", "lowdelta");
Global.RegisterCallback("CreateMove", "antiBruteforce3");
Global.RegisterCallback("CreateMove", "oppositeOnExploits");
//Global.RegisterCallback("CreateMove", "pitchZeroOnLand");
Global.RegisterCallback("CreateMove", "legBreaker");
Global.RegisterCallback("CreateMove", "slowmotion");
Global.RegisterCallback("CreateMove", "standingAutoInvert");
Global.RegisterCallback("CreateMove", "mmFD");
Global.RegisterCallback("CreateMove", "alternativeFakelag");
Global.RegisterCallback("bullet_impact", "antiBruteforce");
Global.RegisterCallback("player_hurt", "antiBruteforce2");
Global.RegisterCallback("round_start", "alternativeFakelag2");
Global.RegisterCallback("CreateMove", "pingSpikeOnKey");
Global.RegisterCallback("CreateMove", "fixes");
Global.RegisterCallback("Draw", "legitAA");
Global.RegisterCallback("CreateMove", "freestanding");

//Visuals
Global.RegisterCallback("Draw", "worldColor");
Global.RegisterCallback("Draw", "bulletTracer2");
Global.RegisterCallback("Draw", "betterScope");
Global.RegisterCallback("FrameStageNotify", "betterScope2");
Global.RegisterCallback("Draw", "skeletonOnHit2");
Global.RegisterCallback("Draw", "trail");
Global.RegisterCallback("Draw", "transparencyOnNade");
Global.RegisterCallback("Draw", "betterCrosshair");
Global.RegisterCallback("Draw", "effectOnKill");
Global.RegisterCallback("Draw", "eyeTracers");
Global.RegisterCallback("Draw", "rainbowBar");
Global.RegisterCallback("Draw", "customFog");
Global.RegisterCallback("Draw", "entities");
Global.RegisterCallback("Draw", "nadeWarning");
Global.RegisterCallback("Draw", "nadeTracer");
Global.RegisterCallback("Draw", "nadeTracer2");
Global.RegisterCallback("Draw", "nadeCircle");
Global.RegisterCallback("Draw", "registerBetterGlowChams");
Global.RegisterCallback("bullet_impact", "bulletTracer");
Global.RegisterCallback("player_connect_full", "on_player_connect");
Global.RegisterCallback("FrameStageNotify", "aspectRatio");
Global.RegisterCallback("FrameStageNotify", "agentChanger");
Global.RegisterCallback("Draw", "armsColor");
Global.RegisterCallback("Material", "betterGlowChams");
Global.RegisterCallback("Draw", "indicators");
Global.RegisterCallback("Draw", "hitShotsHandle");
Global.RegisterCallback("Draw", "drawPlayerSafeHead");

//Misc
Global.RegisterCallback("Draw", "fps_boost");
Global.RegisterCallback("Draw", "moveBuyList");
Global.RegisterCallback("Draw", "watermark");
Global.RegisterCallback("Draw", "autostrafeFix");
Global.RegisterCallback("CreateMove", "enemyLocation");
Global.RegisterCallback("FrameStageNotify", "zoomFix");
Global.RegisterCallback("CreateMove", "clantagOnPeek");
Global.RegisterCallback("vote_options", "onVoteOptions");
Global.RegisterCallback("vote_cast", "voteRevealer");
Global.RegisterCallback("CreateMove", "players");
Global.RegisterCallback("round_end", "clearBuyList");
Global.RegisterCallback("round_freeze_end", "hideBuyList");
Global.RegisterCallback("player_death", "resetVars");
Global.RegisterCallback("player_death", "killsay");
Global.RegisterCallback("Draw", "partyMode");
Global.RegisterCallback("game_newmap", "partyMode2");
Global.RegisterCallback("FrameStageNotify", "musicKit");
Global.RegisterCallback("Draw", "clantag");
Global.RegisterCallback("player_connect_full", "antiBuyBot");

//Menu
Global.RegisterCallback("Draw", "scriptItems");
Global.RegisterCallback("Draw", "loadSettings");
Global.RegisterCallback("Draw", "buyList");
Global.RegisterCallback("Draw", "darkMenu");
Global.RegisterCallback("Draw", "drawMenu");
Global.RegisterCallback("Draw", "moveMenu");
Global.RegisterCallback("Unload", "onUnload");

log("Initialized all the callbacks");
 
Zodiak 1love
Пользователь
Статус
Оффлайн
Регистрация
19 Авг 2019
Сообщения
250
Реакции[?]
35
Поинты[?]
0
Код:
function minDamageOverride(){
    if(!GetVal("mindamage")) return;
    if(UI.IsMenuOpen()){
        if(!GetVal("mindamage_advanced")){
            for(mindamage in mindamage_override){
                mindamage_override[mindamage] = GetVal("mindamage_hp");
            }
        }
        else{
            mindamage_override[0] = GetVal("mindamage_hp");
            mindamage_override[1] = GetVal("mindamage_hp_pistol");
            mindamage_override[2] = GetVal("mindamage_hp_revolver");
            mindamage_override[3] = GetVal("mindamage_hp_scout");
            mindamage_override[4] = GetVal("mindamage_hp_awp");
            mindamage_override[5] = GetVal("mindamage_hp_auto");
        }
    }
    if(UI.IsHotkeyActive('Script items', 'Min damage override') || autopeek_active){
        block_set20 = false;
        for(category in weapon_categories){
            UI.SetValue("Rage", weapon_categories[category], "Targeting", "Minimum damage", mindamage_override[category]);
        }
    }
    else{
        if(!block_set20){
            for(category in weapon_categories){
                UI.SetValue("Rage", weapon_categories[category], "Targeting", "Minimum damage", mindamage_bak[category]);
            }
            block_set20 = true;
        }
        if(UI.IsMenuOpen()){
            for(category in weapon_categories){
                mindamage_bak[category] = UI.GetValue("Rage", weapon_categories[category], "Targeting", "Minimum damage");
            }
        }
    }
}
 
Начинающий
Статус
Оффлайн
Регистрация
4 Июл 2021
Сообщения
54
Реакции[?]
2
Поинты[?]
0
Код:
function minDamageOverride(){
    if(!GetVal("mindamage")) return;
    if(UI.IsMenuOpen()){
        if(!GetVal("mindamage_advanced")){
            for(mindamage in mindamage_override){
                mindamage_override[mindamage] = GetVal("mindamage_hp");
            }
        }
        else{
            mindamage_override[0] = GetVal("mindamage_hp");
            mindamage_override[1] = GetVal("mindamage_hp_pistol");
            mindamage_override[2] = GetVal("mindamage_hp_revolver");
            mindamage_override[3] = GetVal("mindamage_hp_scout");
            mindamage_override[4] = GetVal("mindamage_hp_awp");
            mindamage_override[5] = GetVal("mindamage_hp_auto");
        }
    }
    if(UI.IsHotkeyActive('Script items', 'Min damage override') || autopeek_active){
        block_set20 = false;
        for(category in weapon_categories){
            UI.SetValue("Rage", weapon_categories[category], "Targeting", "Minimum damage", mindamage_override[category]);
        }
    }
    else{
        if(!block_set20){
            for(category in weapon_categories){
                UI.SetValue("Rage", weapon_categories[category], "Targeting", "Minimum damage", mindamage_bak[category]);
            }
            block_set20 = true;
        }
        if(UI.IsMenuOpen()){
            for(category in weapon_categories){
                mindamage_bak[category] = UI.GetValue("Rage", weapon_categories[category], "Targeting", "Minimum damage");
            }
        }
    }
}
пиздец, спасибо большое <3
 
Сверху Снизу