UI.AddLabel("MultiScript by Vanity");
UI.AddMultiDropdown("Indicator", ["DT", "FD", "BAIM"]);

var height = Render.GetScreenSize()[1];


// Indicators
function indicators() {
		selected = (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Indicator")).toString(2).split("").reverse().map(Number);
        var t = Render.AddFont("Verdana", 15, 700);

if(selected[0]) {
        if (UI.IsHotkeyActive("Rage", "GENERAL", "Exploits", "Doubletap")) {
            Render.StringCustom(3, height - 120, 0, "DT", [0, 0, 0, 255], t);
            Render.StringCustom(4, height - 120, 0, "DT", [163, 240, 41, 255], t);
        } else {
            Render.StringCustom(3, height - 120, 0, "DT", [0, 0, 0, 255], t);
            Render.StringCustom(4, height - 120, 0, "DT", [222, 44, 44, 255], t);
        }
}
if(selected[1]) {
        if (UI.IsHotkeyActive("Anti-Aim", "Extra", "Fake duck")) {
            Render.StringCustom(3, height - 100, 0, "DUCK", [0, 0, 0, 255], t);
            Render.StringCustom(4, height - 100, 0, "DUCK", [163, 240, 41, 255], t);
        } else {
            Render.StringCustom(3, height - 100, 0, "DUCK", [0, 0, 0, 255], t);
            Render.StringCustom(4, height - 100, 0, "DUCK", [222, 44, 44, 255], t);
        }
}      
if(selected[2]) {
		if (UI.IsHotkeyActive("Rage", "General", "Force body aim")) {
            Render.StringCustom(3, height - 80, 0, "BODY", [0, 0, 0, 255], t);
            Render.StringCustom(4, height - 80, 0, "BODY", [163, 240, 41, 255], t)
        } else {
            Render.StringCustom(3, height - 80, 0, "BODY", [0, 0, 0, 255], t);
            Render.StringCustom(4, height - 80, 0, "BODY", [222, 44, 44, 255], t);
        }
}
}
Cheat.RegisterCallback("Draw", "indicators");

// Hitlogs
UI.AddCheckbox("Hitlogs");
var hitchance = "unknown";

function getHitboxName(t) {
    switch (t) {
        case 0:
            return " with a nade";
        case 1:
            return " in the head";
        case 2:
            return " in the chest";
        case 3:
            return " in the stomach";
        case 4:
            return " in the left arm";
        case 5:
            return " in the right arm";
        case 6:
            return " in the left leg";
        case 7:
            return " in the right leg";
        case 8:
            return " in the body";
        default:
            return " with utility";
    }
}

function updateHitchance() {
    hitchance = Event.GetInt("hitchance");
}
Cheat.RegisterCallback("ragebot_fire", "updateHitchance");

function hitlog() {
    if (UI.GetValue("Script items", "Hitlogs")) {
            localPlayer = Entity.GetLocalPlayer();
            attacker = Entity.GetEntityFromUserID(Event.GetInt("attacker"));

            if (localPlayer == attacker) {
                victim = Entity.GetName(Entity.GetEntityFromUserID(Event.GetInt("userid")));
                hitgroup = getHitboxName(Event.GetInt("hitgroup"));
                damage = Event.GetInt("dmg_health");

                Global.PrintChat(" [Onetap] hurt  " + victim + " for " + damage + hitgroup + (" with a nade" == hitgroup ? "" : "\n (Hitchance: " + hitchance + ")"));
        }
    }
}
Global.RegisterCallback("player_hurt", "hitlog");

// Clantag
UI.AddCheckbox("Clantag");
var previous = "";
function clantag() {
	var index = parseInt(Globals.Curtime() * 2.7) % 18
    if (UI.GetValue("Script items", "Clantag") && index != previous) {
        switch (index) {
            case 0:
                Local.SetClanTag("o");
                break;
            case 1:
                Local.SetClanTag("on");
                break;
            case 2:
                Local.SetClanTag("one");
                break;
            case 3:
                Local.SetClanTag("onet");
                break;
            case 4:
                Local.SetClanTag("oneta");
                break;
            case 5:
                Local.SetClanTag("onetap");
                break;
            case 6:
                Local.SetClanTag("onetap");
                break;
            case 7:
                Local.SetClanTag("onetap");
                break;
            case 8:
                Local.SetClanTag("onetap");
                break;
            case 9:
                Local.SetClanTag("onetap");
                break;
            case 10:
                Local.SetClanTag("onetap");
                break;
            case 11:
                Local.SetClanTag("netap");
                break;
            case 12:
                Local.SetClanTag("etap");
                break;
            case 13:
                Local.SetClanTag("tap");
                break;
            case 14:
                Local.SetClanTag("ap");
                break;
            case 15:
                Local.SetClanTag("p");
                break;
            case 16:
                Local.SetClanTag("");
                break;
			case 17:
                Local.SetClanTag("");
                break;
			case 18:
                Local.SetClanTag("");
                break;	
        }
    }
	previous = index;
}
Cheat.RegisterCallback("Draw", "clantag");

// Autobuy
UI.AddDropdown("Autobuy", ["None", "AWP", "Scout", "Auto"]);
var roundstart = true;
var prediction = 0;

function init() {
    prediction = Globals.Curtime() + Convar.GetInt("mp_round_restart_delay")
    roundstart = true;
}
Cheat.RegisterCallback("round_end", "init");

function purchaseWeapon(t) {
    switch (UI.GetValue("Script items", "Autobuy")) {
        case 1:
            Cheat.ExecuteCommand("buy awp");
            break;
        case 2:
            Cheat.ExecuteCommand("buy ssg08");
            break;
        case 3:
            Cheat.ExecuteCommand("buy scar20");
            Cheat.ExecuteCommand("buy g3sg1");
            break;
    }
    roundstart = false;
}

function autobuy() {
    if (roundstart && Globals.Curtime() + Local.Latency() / 1e3 >= prediction) {
        purchaseWeapon(UI.GetValue("Script items", "Autobuy"));
    }
}
Cheat.RegisterCallback("Draw", "autobuy");
