const x1 = UI.AddSliderInt("Onetap", 0, 0);
const y1 = UI.AddSliderInt("onetap", 556, 556);
function in_bounds(vec, x, y, x2, y2)
{
    return (vec[0] > x) && (vec[1] > y) && (vec[0] < x2) && (vec[1] < y2)
}
function main()
{
    if(!World.GetServerString()) return;
    const x = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Onetap"),
            y = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "onetap");
    color = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "Hotkeys");
    var font = Render.AddFont( "MuseoSansCyrl-500", 10, 100);
    const icon = Render.AddFont("untitled-font-1", 14, 10);
    Render.GradientRect(x, y - 58, 200, 17, 500, [ 0, 0, 0, 255 ], [ 0, 0, 0, 0 ]);
    var h = [];

     if (UI.IsHotkeyActive("Anti-Aim", "Extra", "Slow walk")) {
       h.push("Slow walk")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Rage Anti-Aim", "Jitter offset")) {
       h.push("Jitter offset")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Extra", "Fake duck")) {
       h.push("Fake duck")
     }
     if (UI.IsHotkeyActive("Misc", "GENERAL", "Movement", "Auto peek")) {
       h.push("Auto peek")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter")) {
       h.push("Anti-Aim Inverter")
     }
     if (UI.IsHotkeyActive("Rage", "GENERAL", "General", "Force safe point")) {
       h.push("Safe point")
     }
     if (UI.IsHotkeyActive("Rage", "GENERAL", "General", "Force body aim")) {
       h.push("Body aim")
     }
     if (UI.IsHotkeyActive("Rage", "Exploits", "Doubletap")) {
       h.push("Doubletap")
     }
     if (UI.IsHotkeyActive("Rage", "Exploits", "Hide shots")) {
       h.push("Hide shots")
     }
     if (UI.IsHotkeyActive("Misc", "JAVASCRIPT", "Script items", "Min Damage")) {
       h.push("Damage override")
     }
    if (h.length > 0) {
        for (i = 0; i < h.length; i++)
        {
            Render.StringCustom(x + 29, y - 35 + 17 * i, 0, h[i], [0, 0, 0, 180], font);
            Render.StringCustom(x + 5, y - 37 + 17 * i, 0, "a", [245, 245, 245, 255], icon);
            Render.StringCustom(x + 29, y - 35 + 17 * i, 0, h[i], [255, 255, 255, 255], font);
        }
    }
}
Global.RegisterCallback("Draw", "main")
var observators = [];
function getObservators(){
    var ents = Entity.GetPlayers();
    var local = Entity.GetLocalPlayer();
    var localtarget = Entity.GetProp(local,"DT_BasePlayer","m_hObserverTarget");
    if(!local)return;
    observators = [];
    for(i = 0; i < ents.length;i++){
        if(Entity.IsAlive(local)){
            if(!ents[i] || Entity.IsAlive(ents[i]))continue;
            var observer = Entity.GetProp(ents[i],"DT_BasePlayer","m_hObserverTarget");
            if(!observer || observer == "m_hObserverTarget")continue;
            if(observer == local)observators.push(Entity.GetName(ents[i]));
        }
        else{
            if(!ents[i] || Entity.IsAlive(ents[i]))continue;
            var observer = Entity.GetProp(ents[i],"DT_BasePlayer","m_hObserverTarget");
            if(!observer || observer == "m_hObserverTarget")continue;
            if(observer == localtarget)observators.push(Entity.GetName(ents[i]));
        }
    }
}
function drawObservators(){
    var screen = Render.GetScreenSize();
    var type = UI.GetValue("Script Items","type");
    var font = Render.AddFont("Verdana",8,100);
    for(i = 0; i < observators.length; i++){
        var name = observators[i];
        var size = Render.TextSizeCustom(name,font);
        Render.StringCustom(screen[0]-size[0]-1850,(i*-20)+540,0,name,[255,255,255,255],font);
    }
    
}
function onRoundStart(){
    observators = [];
}


Global.RegisterCallback("Draw","getObservators");
Global.RegisterCallback("Draw","drawObservators");
Global.RegisterCallback("round_start","onRoundStart");