client.exec("clear")
client.color_log(255, 255, 255, "Welcome to Lunar v2")
client.color_log(255, 255, 255, "Anti-Aim develop by Oscar")
client.color_log(255, 255, 255, "Ind Misc develop by wheezy")
client.color_log(255, 255, 255, "Update date: 2022 05 05")

local bit_band,
    client_camera_angles,
    client_color_log,
    client_create_interface,
    client_delay_call,
    client_exec,
    client_eye_position,
    client_key_state,
    client_log,
    client_random_int,
    client_scale_damage,
    client_screen_size,
    client_set_event_callback,
    client_trace_bullet,
    client_userid_to_entindex,
    database_read,
    database_write,
    entity_get_player_weapon,
    entity_get_players,
    entity_get_prop,
    entity_hitbox_position,
    entity_is_alive,
    entity_is_enemy,
    math_abs,
    math_atan2,
    require,
    error,
    globals_absoluteframetime,
    globals_curtime,
    globals_realtime,
    math_atan,
    math_cos,
    math_deg,
    math_floor,
    math_max,
    math_min,
    math_rad,
    math_sin,
    math_sqrt,
    print,
    renderer_circle_outline,
    renderer_gradient,
    renderer_measure_text,
    renderer_rectangle,
    renderer_text,
    renderer_triangle,
    string_find,
    string_gmatch,
    string_gsub,
    string_lower,
    table_insert,
    table_remove,
    ui_get,
    ui_new_checkbox,
    ui_new_color_picker,
    ui_new_hotkey,
    ui_new_multiselect,
    ui_reference,
    tostring,
    ui_is_menu_open,
    ui_mouse_position,
    ui_new_combobox,
    ui_new_slider,
    ui_set,
    ui_set_callback,
    ui_set_visible,
	ui_new_label,
    tonumber,
    pcall =
    bit.band,
    client.camera_angles,
    client.color_log,
    client.create_interface,
    client.delay_call,
    client.exec,
    client.eye_position,
    client.key_state,
    client.log,
    client.random_int,
    client.scale_damage,
    client.screen_size,
    client.set_event_callback,
    client.trace_bullet,
    client.userid_to_entindex,
    database.read,
    database.write,
    entity.get_player_weapon,
    entity.get_players,
    entity.get_prop,
    entity.hitbox_position,
    entity.is_alive,
    entity.is_enemy,
    math.abs,
    math.atan2,
    require,
    error,
    globals.absoluteframetime,
    globals.curtime,
    globals.realtime,
    math.atan,
    math.cos,
    math.deg,
    math.floor,
    math.max,
    math.min,
    math.rad,
    math.sin,
    math.sqrt,
    print,
    renderer.circle_outline,
    renderer.gradient,
    renderer.measure_text,
    renderer.rectangle,
    renderer.text,
    renderer.triangle,
    string.find,
    string.gmatch,
    string.gsub,
    string.lower,
    table.insert,
    table.remove,
    ui.get,
    ui.new_checkbox,
    ui.new_color_picker,
    ui.new_hotkey,
    ui.new_multiselect,
    ui.reference,
    tostring,
    ui.is_menu_open,
    ui.mouse_position,
    ui.new_combobox,
    ui.new_slider,
    ui.set,
    ui.set_callback,
    ui.set_visible,
	ui.new_label,
    tonumber,
    pcall
local ui_menu_position,
    ui_menu_size,
    math_pi,
    renderer_indicator,
    entity_is_dormant,
    client_set_clan_tag,
    client_trace_line,
    entity_get_all,
    entity_get_classname =
    ui.menu_position,
    ui.menu_size,
    math.pi,
    renderer.indicator,
    entity.is_dormant,
    client.set_clan_tag,
    client.trace_line,
    entity.get_all,
    entity.get_classname
local bit = require "bit"
local vector = require("vector")
local images = require "gamesense/surface"
local ffi = require("ffi")
local anti_aim = require 'gamesense/antiaim_funcs'
local js = panorama.open()
local persona_api = js.MyPersonaAPI
local start_time = globals.realtime()
local abftimer = globals.tickcount()

local YawS = 0
local BdoYS = 0
local YJAS = 0
local INVERTS_INFO = 0
local reversed = false
local should_swap = false
local force_antibrute = false
local detvar = 0
local detvar2 = 0
local return_reset_hit = true
local brutesetting = false
preferbrute = {}
forceperferbrute = {}
local bruteangle = 24
local anglefigure = -180
local forceangle = false
local lastb = 0

local function detectvar(O,C)
    if globals_curtime() > detvar2 and detvar then
	    detvar = detvar + 10
		detvar2 = detvar2 + 2
		client_delay_call(7, detvar)
		math.random(1, detvar)
	end
	if globals_curtime() < detvar2 then
	    detvar = detvar2
		client_delay_call(7, detvar)
		math.random(1, detvar)
	end
	return O or C
end

local function gradient_text(r1, g1, b1, a1, r2, g2, b2, a2, text)
    local output = ''
    local len = #text-1
    local rinc = (r2 - r1) / len
    local ginc = (g2 - g1) / len
    local binc = (b2 - b1) / len
    local ainc = (a2 - a1) / len
    for i=1, len+1 do
        output = output .. ('\a%02x%02x%02x%02x%s'):format(r1, g1, b1, a1, text:sub(i, i))
        r1 = r1 + rinc
        g1 = g1 + ginc
        b1 = b1 + binc
        a1 = a1 + ainc
    end

    return output
end

local type         = type;
local setmetatable = setmetatable;
local tostring     = tostring;

local math_pi   = math.pi;
local math_min  = math.min;
local math_max  = math.max;
local math_deg  = math.deg;
local math_rad  = math.rad;
local math_sqrt = math.sqrt;
local math_sin  = math.sin;
local math_cos  = math.cos;
local math_atan = math.atan;
local math_acos = math.acos;
local math_fmod = math.fmod;

-- set up vector3 metatable
local _V3_MT   = {};
_V3_MT.__index = _V3_MT;

--
-- create Vector3 object
--
local function Vector3( x, y, z )
    -- check args
    if( type( x ) ~= "number" ) then
        x = 0.0;
    end

    if( type( y ) ~= "number" ) then
        y = 0.0;
    end

    if( type( z ) ~= "number" ) then
        z = 0.0;
    end

    x = x or 0.0;
    y = y or 0.0;
    z = z or 0.0;

    return setmetatable(
        {
            x = x,
            y = y,
            z = z
        },
        _V3_MT
    );
end


function _V3_MT.__sub( a, b ) -- subtract another vector or number
    local a_type = type( a );
    local b_type = type( b );

    if( a_type == "table" and b_type == "table" ) then
        return Vector3(
            a.x - b.x,
            a.y - b.y,
            a.z - b.z
        );
    elseif( a_type == "table" and b_type == "number" ) then
        return Vector3(
            a.x - b,
            a.y - b,
            a.z - b
        );
    elseif( a_type == "number" and b_type == "table" ) then
        return Vector3(
            a - b.x,
            a - b.y,
            a - b.z
        );
    end
end

function _V3_MT:length_sqr() -- squared 3D length
    return ( self.x * self.x ) + ( self.y * self.y ) + ( self.z * self.z );
end

function _V3_MT:length() -- 3D length
    return math_sqrt( self:length_sqr() );
end

function _V3_MT:dot( other ) -- dot product
    return ( self.x * other.x ) + ( self.y * other.y ) + ( self.z * other.z );
end

function _V3_MT:cross( other ) -- cross product
    return Vector3(
        ( self.y * other.z ) - ( self.z * other.y ),
        ( self.z * other.x ) - ( self.x * other.z ),
        ( self.x * other.y ) - ( self.y * other.x )
    );
end

function _V3_MT:dist_to( other ) -- 3D length to another vector
    return ( other - self ):length();
end

function _V3_MT:normalize() -- normalizes this vector and returns the length
    local l = self:length();
    if( l <= 0.0 ) then
        return 0.0;
    end

    self.x = self.x / l;
    self.y = self.y / l;
    self.z = self.z / l;

    return l;
end


function _V3_MT:normalized() -- returns a normalized unit vector
    local l = self:length();
    if( l <= 0.0 ) then
        return Vector3();
    end

    return Vector3(
        self.x / l,
        self.y / l,
        self.z / l
    );
end

function math.round(number, precision)
    local mult = 10 ^ (precision or 0)

    return math.floor(number * mult + 0.5) / mult
end

local angle_c = {}
local angle_mt = {
    __index = angle_c
}

local function angle(p, y, r)
    return setmetatable(
        {
            p = p or 0,
            y = y or 0,
            r = r or 0
        },
        angle_mt
    )
end

local aa = {
    dormant = false,
    move = "stand",
	ind = "sb",
    peek = false,
    shots = 0,
    lastfired = 0,
    lastp = nil,
    lastlocal = 0,
    lastmov = 0,
    ignore = false,
    oldhp = 0,
    lastj = 0,
	lastjh = 0,
    enem = {},
    lastdt = 0,
    manaa = 0,
    input = 0,
	lastsb = 0,
	nbshu = 180,
    enemhit = {},
	miss = {},
	lastmiss = {},
	lastenemhit = {},
	lastshots = {},
	mhit = {},
	brutedelay = 0,
	hmsreset = false,
	    wuqi = {
	"knife",
	"hegrenade",
	"inferno",
	"flashbang",
	"decoy",
	"smokegrenade",
	"taser"
	}
}
--ref
local aaenabled = ui_reference("AA", "Anti-aimbot angles", "Enabled")
local Pitch = ui_reference("AA", "Anti-aimbot angles", "Pitch")
local YB = ui_reference("aa", "Anti-aimbot angles", "Yaw base")
local Yaw,YA = ui_reference("aa", "Anti-aimbot angles", "Yaw")
local YJ,YJA = ui_reference("aa", "Anti-aimbot angles", "Yaw Jitter")
local BY,BYA = ui_reference("aa", "Anti-aimbot angles", "Body yaw")
local FBS = ui_reference("aa", "Anti-aimbot angles", "Freestanding body yaw")
local FakeL = ui_reference("aa", "Anti-aimbot angles", "Fake yaw limit")
local EY = ui_reference("aa", "Anti-aimbot angles", "Edge yaw")
local FS,FSK = ui_reference("aa", "Anti-aimbot angles", "Freestanding")
local RL = ui_reference("aa", "Anti-aimbot angles", "Roll")
local fakelag = ui_reference("AA", "Fake lag", "Limit")
local slow,slowkey = ui_reference("aa", "Other", "Slow motion")
local fakeduck = ui_reference("RAGE", "Other", "Duck peek assist")
local safepoint = ui_reference("RAGE", "Aimbot", "Force safe point")
local forcebaim = ui_reference("RAGE", "Other", "Force body aim")
local os,ost = ui_reference("AA", "Other", "On shot anti-aim")
local dt_limit = ui_reference("RAGE", "Other", "Double tap fake lag limit")
local dt,dtm = ui_reference("RAGE", "Other", "Double tap")
local legs = ui.reference("AA", "other", "leg movement")
local ctick = ui_reference("MISC", "Settings", "sv_maxusrcmdprocessticks")
local shit_var = 0
----menuitem
label = ui_new_label("aa", "Anti-aimbot angles", "================================")
labe2 = ui_new_label("aa", "Anti-aimbot angles", "                     \a66ff66ff[LUNAR] version2.0.0")
labe3 = ui_new_label("aa", "Anti-aimbot angles", "================================")
en = ui_new_checkbox("aa", "Anti-aimbot angles", "                       \aff4da6ffLUNAR Yaw Switch")
labe7 = ui_new_label("aa", "Anti-aimbot angles", "\affff66ff[+]AA")
aaf = ui_new_combobox("aa", "Anti-aimbot angles", "AA mode", "-", "SIMPLE JITTER", "SMALL TANK", "LARGE TANK", "EX TANK")
oss = ui_new_checkbox("aa", "Anti-aimbot angles", "OnShot fakelag fix")
weak = ui_new_checkbox("aa", "Anti-aimbot angles", "Jitter when not networke")
legit = ui_new_checkbox("aa", "Anti-aimbot angles", "Legit aa")
BBBFS = {
    ui_new_checkbox("aa", "Anti-aimbot angles", "Freestand\nTS"),
	ui_new_hotkey("aa", "Anti-aimbot angles", "Freestand key", true)
}
slow_walk_AA = ui_new_checkbox("aa", "Anti-aimbot angles", "Slow motion")
manual_enable = ui_new_checkbox("AA", "Anti-aimbot angles", "Manual anti-aim")
manual_left = ui_new_hotkey("AA", "Anti-aimbot angles", "Manual left")
manual_right = ui_new_hotkey("AA", "Anti-aimbot angles", "Manual right")
ui_new_label("aa", "Anti-aimbot angles", " ")
labe9 = ui_new_label("aa", "Anti-aimbot angles", "\affff66ff[+]VIS")
ind = ui_new_checkbox("aa", "Anti-aimbot angles", "Indicator")
AASI = ui_new_multiselect("aa", "Anti-aimbot angles", "Ind EXT", "AA STATE")
labe5 = ui_new_label("aa", "Anti-aimbot angles", "Left main ind color")
colorp = ui_new_color_picker("aa", "Anti-aimbot angles", "LEFT Ind color", 255, 255, 255)
labe6 = ui_new_label("aa", "Anti-aimbot angles", "Right main ind color")
colorp2 = ui_new_color_picker("aa", "Anti-aimbot angles", "RIGHT Ind color", 255, 255, 255)
labe10 = ui_new_label("aa", "Anti-aimbot angles", "Stand STATE color")
color6 = ui_new_color_picker("aa", "Anti-aimbot angles", "SpSTATE color", 255, 255, 255)
labe11 = ui_new_label("aa", "Anti-aimbot angles", "In air STATE color")
color2 = ui_new_color_picker("aa", "Anti-aimbot angles", "ApSTATE color", 255, 255, 255)
labe12 = ui_new_label("aa", "Anti-aimbot angles", "Move STATE color")
color3 = ui_new_color_picker("aa", "Anti-aimbot angles", "MpSTATE color", 255, 255, 255)
labe13 = ui_new_label("aa", "Anti-aimbot angles", "Slow STATE color")
color4 = ui_new_color_picker("aa", "Anti-aimbot angles", "SWpSTATE color", 255, 255, 255)
labe14 = ui_new_label("aa", "Anti-aimbot angles", "Duck STATE color")
color5 = ui_new_color_picker("aa", "Anti-aimbot angles", "DpSTATE color", 255, 255, 255)
ui_new_label("aa", "Anti-aimbot angles", " ")
labe8 = ui_new_label("aa", "Anti-aimbot angles", "\affff66ff[+] MISC")
leg = ui_new_combobox("AA", "Anti-aimbot angles", "Leg movement", "-", "Static", "Jitter")
----menuitem

local function contains(table, key)
    for index, value in pairs(table) do
        if value == key then return true end -- , index
    end
    return false -- , nil
end

local function multi_select(search_table, search_value)
	for _, table_value in pairs(search_table) do
		if (search_value == table_value) then
			return true
		end
	end

	return false
end

local create_callback = function(name, func)
    local get_func_index = function(fn)
        return ffi.cast("int*", ffi.cast(ffi.typeof("void*(__thiscall*)(void*)"), fn))[0]
    end
    local DEC_HEX = function(IN)
        local B, K, OUT, I, D = 16, "0123456789ABCDEF", "", 0
        while IN > 0 do
            I = I + 1
            IN, D = math.floor(IN / B), math.fmod(IN, B) + 1
            OUT = string.sub(K, D, D) .. OUT
        end
        return OUT
    end
    client.delay_call(
        0.1,
        function()
            client.set_event_callback(name, func)
        end
    )
end

----check dt
local function doubletap_charged()
    if not ui_get(dt) or not ui_get(dtm) or ui.get(fakeduck) then
        return false
    end
    if not entity.is_alive(entity.get_local_player()) or entity.get_local_player() == nil then
        return
    end
    local weapon = entity.get_prop(entity.get_local_player(), "m_hActiveWeapon")
    if weapon == nil then
        return false
    end
    local next_attack = entity.get_prop(entity.get_local_player(), "m_flNextAttack") + 0.25
    local jewfag = entity.get_prop(weapon, "m_flNextPrimaryAttack")
    if jewfag == nil then
        return
    end
    local next_primary_attack = jewfag + 0.5
    if next_attack == nil or next_primary_attack == nil then
        return false
    end
    return next_attack - globals.curtime() < 0 and next_primary_attack - globals.curtime() < 0
end

----yingcang
uiyincang = function()
    if ui_get(en) then
	    ui_set_visible(Pitch, false)
	    ui_set_visible(YB, false)
	    ui_set_visible(Yaw, false)
	    ui_set_visible(YA, false)
	    ui_set_visible(YJ, false)
	    ui_set_visible(YJA, false)
	    ui_set_visible(BY, false)
	    ui_set_visible(BYA, false)
	    ui_set_visible(FBS, false)
	    ui_set_visible(FakeL, false)
	    ui_set_visible(EY, false)
	    ui_set_visible(FS, false)
	    ui_set_visible(FSK, false)
	    ui_set_visible(RL, false)
	else
	    ui_set_visible(Pitch, true)
	    ui_set_visible(YB, true)
	    ui_set_visible(Yaw, true)
	    ui_set_visible(YA, true)
	    ui_set_visible(YJ, true)
	    ui_set_visible(YJA, true)
	    ui_set_visible(BY, true)
	    ui_set_visible(BYA, true)
	    ui_set_visible(FBS, true)
	    ui_set_visible(FakeL, true)
	    ui_set_visible(EY, true)
	    ui_set_visible(FS, true)
	    ui_set_visible(FSK, true)
	    ui_set_visible(RL, true)
	end
end

normalize_yaw = function(angle)
    angle = (angle % 360 + 360) % 360
    return angle > 180 and angle - 360 or angle
end

clamp = function(min, max, value)
    if min < max then
        return math.max(min, math.min(max, value))
    else
        return math.max(max, math.min(min, value))
    end
end

angle_forward = function(angle)
    if angle[1] ~= nil and angle[2] ~= nil then
        angle[1] = math.rad(angle[1])
        angle[2] = math.rad(angle[2])

        local sin_pitch = math.sin(angle[1])
        local sin_yaw = math.sin(angle[2])
        local cos_pitch = math.cos(angle[1])
        local cos_yaw = math.cos(angle[2])

        return {cos_pitch * cos_yaw, cos_pitch * sin_yaw, -sin_pitch}
    end
end

extrapolate_angle = function(camera, angles, limit)
    local forward = angle_forward(angles)
    local trace = {client_trace_line(entity.get_local_player(), camera[1], camera[2], camera[3], forward[1] * (8192), forward[2] * (8192), forward[3] * (8192))}

    return {
        camera[1] + (forward[1] * clamp(0, limit, (8192 * trace[1]))),
        camera[2] + (forward[2] * clamp(0, limit, (8192 * trace[1]))),
        camera[3] + (forward[3] * clamp(0, limit, (8192 * trace[1])))
    }, 8192 * trace[1]
end

Angle_Vector = function(angle_x, angle_y)
    sy = math.sin(math.rad(angle_y));
    cy = math.cos(math.rad(angle_y));
    sp = math.sin(math.rad(angle_x));
    cp = math.cos(math.rad(angle_x));
    return cp * cy, cp * sy, -sp;
end

get_best_enemy = function()

    best_enemy = nil

    local enemies = entity_get_players(true)
    local best_fov = 180

    local lx, ly, lz = client_eye_position()
    local view_x, view_y, roll = client_camera_angles()
    
    for i=1, #enemies do
        local cur_x, cur_y, cur_z = entity_get_prop(enemies[i], "m_vecOrigin")
        local cur_fov = math.abs(normalize_yaw(ang_on_screen(lx - cur_x, ly - cur_y) - view_y + 180))
        if cur_fov < best_fov then
			best_fov = cur_fov
			best_enemy = enemies[i]
		end
    end
end

local function closestToCrosshair()
    local enemy_players = entity.get_players(true)
    if #enemy_players ~= 0 then
        local own_x, own_y, own_z = client.eye_position()
        local own_pitch, own_yaw = client.eye_position()
        local closest_enemy = nil
        local closest_distance = 999999999

        for i = 1, #enemy_players do
            local enemy = enemy_players[i]
            local enemy_x, enemy_y, enemy_z = entity.get_prop(enemy, "m_vecOrigin")

            local x = enemy_x - own_x
            local y = enemy_y - own_y
            local z = enemy_z - own_z

            local yaw = ((math.atan2(y, x) * 200 / math.pi))
            local pitch = -(math.atan2(z, math.sqrt(math.pow(x, 2) + math.pow(y, 2))) * 200 / math.pi)

            local yaw_dif = math.abs(own_yaw % 360 - yaw % 360) % 360
            local pitch_dif = math.abs(own_pitch - pitch ) % 360

            if yaw_dif > 180 then yaw_dif = 360 - yaw_dif end
            local real_dif = math.sqrt(math.pow(yaw_dif, 2) + math.pow(pitch_dif, 2))

            if closest_distance > real_dif then
                closest_distance = real_dif
                closest_enemy = enemy
            end
        end

        if closest_enemy ~= nil then
            return closest_enemy, closest_distance
        end
    end

    return nil, nil
end

local function vec3_dot(ax, ay, az, bx, by, bz)

    return ax*bx + ay*by + az*bz
end

local function vec3_normalize(x, y, z)
    local len = math.sqrt(x * x + y * y + z * z)
    if len == 0 then
        return 0, 0, 0
    end
    local r = 1 / len
    return x*r, y*r, z*r
end

function CalcAngle(localplayerxpos, localplayerypos, enemyxpos, enemyypos)
    relativeyaw = math.atan( (localplayerypos - enemyypos) / (localplayerxpos - enemyxpos) )
    return relativeyaw * 180 / math.pi
end

local function get_fov_cos(ent, vx,vy,vz, lx,ly,lz)
    local ox,oy,oz = entity_get_prop(ent, "m_vecOrigin")
    if ox == nil then
        return -1
    end

    local dx,dy,dz = vec3_normalize(ox-lx, oy-ly, oz-lz)
    return vec3_dot(dx,dy,dz, vx,vy,vz)
end

local function get_damage(plocal, enemy, x, y,z)
	local ex = { }
	local ey = { }
	local ez = { }
	ex[0], ey[0], ez[0] = entity_hitbox_position(enemy, 1)
	ex[1], ey[1], ez[1] = ex[0] + 40, ey[0], ez[0]
	ex[2], ey[2], ez[2] = ex[0], ey[0] + 40, ez[0]
	ex[3], ey[3], ez[3] = ex[0] - 40, ey[0], ez[0]
	ex[4], ey[4], ez[4] = ex[0], ey[0] - 40, ez[0]
	ex[5], ey[5], ez[5] = ex[0], ey[0], ez[0] + 40
	ex[6], ey[6], ez[6] = ex[0], ey[0], ez[0] - 40
	local ent, dmg = 0
	for i=0, 6 do
		if dmg == 0 or dmg == nil then
			ent, dmg = client_trace_bullet(enemy, ex[i], ey[i], ez[i], x, y, z)
		end
	end
	return ent == nil and client_scale_damage(plocal, 1, dmg) or dmg
end

local function get_closest_point(A, B, P)
   local a_to_p = { P[1] - A[1], P[2] - A[2] }
   local a_to_b = { B[1] - A[1], B[2] - A[2] }
   local ab = a_to_b[1]^2 + a_to_b[2]^2
   local dots = a_to_p[1]*a_to_b[1] + a_to_p[2]*a_to_b[2]
   local t = dots / ab
    
   return { A[1] + a_to_b[1]*t, A[2] + a_to_b[2]*t }
end

local function angle_to_vec(pitch, yaw)
    local p, y = math.rad(pitch), math.rad(yaw)
    local sp, cp, sy, cy = math.sin(p), math.cos(p), math.sin(y), math.cos(y)
    return cp*cy, cp*sy, -sp
end

----setup epeek and closestFOvCL
local function setupsimple(cmd)
	local FP = entity.get_prop(entity.get_game_rules(), "m_bFreezePeriod")
	if ui_get(legit) then
        if cmd.in_grenade1 == 1 or cmd.in_grenade2 == 1 or cmd.in_attack == 1 then return end
        local pitch, yaw = client.camera_angles()
        local weapon = entity.get_player_weapon(entity.get_local_player())
        if weapon ~= nil and entity.get_classname(weapon) == "CC4" then
            if cmd.in_attack == 1 then
                cmd.in_attack = 0
                cmd.in_use = 1
			    ui_set(FBS, true)
            end
        else
            if cmd.chokedcommands == 0 then
                cmd.in_use = 0
			    ui_set(FBS, false)
            end
        end
	end
    if FP then
        INVERTS_INFO = 0
    end
	
	local entindex = entity.get_local_player( )
    if entindex == nil then return end
    local lx,ly,lz = entity_get_prop( entindex, "m_vecOrigin" )
    if lx == nil then return end
	
    local players = entity_get_players( true )    
    local pitch, yaw = client_camera_angles( )
    local vx, vy, vz = angle_to_vec( pitch, yaw )
    local closest_fov_cos = -1
    enemyclosesttocrosshair = nil
    for i=1, #players do
        local idx = players[ i ]
        if entity_is_alive( idx ) then
            local fov_cos = get_fov_cos( idx, vx, vy, vz, lx, ly, lz )
            if fov_cos > closest_fov_cos then
                closest_fov_cos = fov_cos
                enemyclosesttocrosshair = idx
            end
        end
    end
end

abforcetarget = 0
----Anti brute for fl in weak
local function avoidshot(c)
    local nowcl = 0
	local reback = 0
	local curr = globals_curtime()
    local me = entity.get_local_player()
    if not entity_is_alive(me) then
	    return
	end
    local attme = client_userid_to_entindex(c.userid)
	if not entity.is_dormant(attme) and entity.is_enemy(attme) then
	    local attme_shoot = { entity.get_prop( attme, "m_vecOrigin" ) }
        attme_shoot[ 3 ] = attme_shoot[ 3 ]+entity.get_prop( attme, "m_vecViewOffset[2]" )
        local player_head = { entity.hitbox_position( me, 0 ) }
        local closest = get_closest_point( attme_shoot, { c.x, c.y, c.z }, player_head )
        local delta = { player_head[ 1 ]-closest[ 1 ], player_head[ 2 ]-closest[ 2 ] }
        local delta_2d = math.sqrt( delta[ 1 ]^2+delta[ 2 ]^2 )
		aa.enemhit = 180
		aa.miss = 0
		aa.lastmiss = 0
        if math.abs( delta_2d ) < 32 and curr == 1 then
		    abforcetarget = attme
		    lastb = globals_curtime() + 2
		    INVERTS_INFO = INVERTS_INFO + 1
			anglefigure = anglefigure + 100
		    should_swap = true
			curr = nowcl
			aa.enemhit = aa.enemhit - 360
			if should_swap == true then
			    aa.miss = (aa.miss + 1)^(aa.miss + 1)
				aa.lastmiss = math.sqrt(aa.miss, 1)
			else
			    aa.lastmiss = 0
				client_delay_call(1, aa.lastmiss)
			end
		elseif math.abs( delta_2d ) < 32 and nowcl - curr < 1 and curr > 1 then
		    abforcetarget = attme
		    lastb = globals_curtime() + 2
		    INVERTS_INFO = INVERTS_INFO + 1
			anglefigure = anglefigure + 100
		    should_swap = true
			curr = nowcl
			aa.enemhit = aa.enemhit - 360
			if should_swap == true then
			    aa.miss = (aa.miss + 1)^(aa.miss + 1)
				aa.lastmiss = math.sqrt(aa.miss, 1)
			else
			    aa.lastmiss = 0
				client_delay_call(1, aa.lastmiss)
			end
		elseif math.abs( delta_2d ) < 3 and nowcl - curr < 6 then
		    abforcetarget = attme
		    lastb = globals_curtime() + 1
		    INVERTS_INFO = INVERTS_INFO - 1
		    should_swap = true
			curr = nowcl
			aa.enemhit = aa.enemhit - 180
			if should_swap == true then
			    aa.miss = (aa.miss + 0)^(aa.miss + 0)
				aa.lastmiss = aa.miss
			else
			    aa.lastmiss = 0
				client_delay_call(1, aa.lastmiss)
			end
		elseif math.abs( delta_2d ) < 3 and nowcl - curr > 20 then
		    abforcetarget = attme
		    lastb = globals_curtime() + 1
		    INVERTS_INFO = INVERTS_INFO - 1
		    should_swap = true
		    curr = nowcl
			aa.enemhit = aa.enemhit - 180
			if should_swap == true then
			    aa.miss = (aa.miss + 0)^(aa.miss + 0)
				aa.lastmiss = aa.miss
			else
			    aa.lastmiss = 0
				client_delay_call(1, aa.lastmiss)
			end
		end
		if math.abs( delta_2d ) < 10 or math.abs( delta_2d ) < 5 then
		    abforcetarget = attme
		    delta_2d = delta_2d^-2
			delta_2d = reback
			aa.enemhit = 0
			lastb = globals_curtime() + 0
		end
		if math.abs( delta_2d ) < 220 then
		    local lp_health = entity_get_prop(entity.get_local_player(),"m_iHealth")
			if lp_health ~= nil then
                if lp_health ~= aa.oldhp then
                    local wep = entity.get_player_weapon(attme)
                    local class = entity.get_classname(wep)
                    if class ~= nil then
                        if class == "CWeaponSSG08" or class == "CWeaponAWP" then
                            aa.timer = globals.tickcount() + 50
                        else
                            aa.timer = globals.tickcount() + 2
                        end
					    aa.lastjh = true
						if ui_get(weak) then
                            if aa.mhit[attme] == nil then
                                aa.mhit[attme] = {shots = 0, time = 0}
                            end
                            local entity_data = aa.mhit[attme] or {shots = 0, time = 0}
                            entity_data.shots = entity_data.shots + 1
                            entity_data.time = globals.curtime()
                            aa.mhit[attme] = entity_data
                        end
                        aa.oldhp = lp_health
					else
	                    if aa.lastjh == true then
                            aa.lastjh = false
                        else
                            local wep = entity.get_player_weapon(attme)
                            local class = entity.get_classname(wep)
                            if class ~= nil then
                                if class == "CWeaponSSG08" or class == "CWeaponAWP" then
                                    aa.timer = globals.tickcount() + 50
                                else
                                    aa.timer = globals.tickcount() + 2
                                end
                            end
                            if ui_get(weak) then
                                if aa.mhit[attme] == nil then
                                    aa.mhit[attme] = {shots = 0, time = 0}
                                end
                                local entity_data = aa.mhit[attme] or {shots = 0, time = 0}
                                entity_data.shots = entity_data.shots + 1
                                entity_data.time = globals.curtime()
                                aa.mhit[attme] = entity_data
                            end								
                        end							
                    end
                end
            end
		end	
	end
end

----brute hurt
local function on_player_hurt(e)
	local victim = client_userid_to_entindex(e.userid)
	local attacker = client_userid_to_entindex(e.attacker)

	if not entity_is_enemy(attacker) or not entity_is_alive(entity.get_local_player()) then
		return
	end
	
	for i=1, #aa.wuqi do
		if e.weapon == aa.wuqi[i] then
			return
		end
	end

	local dsy = aa.hmsreset and (ui_get(BYA) * -1) or ui_get(BYA)
	if victim and attacker == entity.get_local_player() then
	    anglefigure = anglefigure + 10
	    abforcetarget = attacker
	    should_swap = true
	    lastb = globals_curtime() + 3
		bruteangle = client_random_int(23,28)
	    if detectvar(1, 10) < 8 or ui_get(weak) then
			aa.lastj = (aa.lastj + 1)^4
			preferbrute[#preferbrute + 1] = bruteangle
			if should_swap == true then
			    forceangle = true
				aa.brutedelay = 9
			end
		elseif detectvar(1, 10) > 5 or ui_get(weak) then
			aa.lastj = (aa.lastj + 1)^4
			preferbrute[#preferbrute + 1] = bruteangle
			if should_swap == true then
			    forceangle = false
				aa.brutedelay = 3
			end
		else
		    should_swap = false
		    preferbrute = not bruteangle
		end
	end
end

----check movement
function fl_onground( ent )
    local flags = entity.get_prop( ent, "m_fFlags" )
    local flags_on_ground = bit.band( flags, 1 )

    if flags_on_ground == 1 then
        return true
    end	
    return false
end

function fl_induck( ent )
    local flags = entity.get_prop( ent, "m_fFlags" )
    local flags_induck = bit.band( flags, 2 )

    if flags_induck == 2 then
        return true
    end	
    return false
end

function in_air(player)
    local flags = entity.get_prop(player, "m_fFlags")

    if bit.band(flags, 1) == 0 then
        return true
    end

    return false
end
----check movement

local function calculateBestAngle(enemy, ...)
    lx, ly, lz = entity.get_prop(entity.get_local_player(), "m_vecOrigin")
    viewangle_x, viewangle_y, roll = client.camera_angles()
    headx, heady, headz = entity.hitbox_position(entity.get_local_player(), 0)
    enemyx, enemyy, enemyz = entity.get_prop(enemy, "m_vecOrigin")
    bestangle = nil
    
    if(entity.is_alive(enemy)) then
        yaw = CalcAngle(lx, ly, enemyx, enemyy)
        for i,v in pairs({...}) do
        
            dir_x, dir_y, dir_z = Angle_Vector(0, (yaw + v))
            end_x = lx + dir_x * 55
            end_y = ly + dir_y * 55
            end_z = lz + 80
            
            index, damage = client.trace_bullet(enemy, enemyx, enemyy, enemyz + 70, end_x, end_y, end_z)
            
            index2, damage2 = client.trace_bullet(enemy, enemyx, enemyy, enemyz + 70, end_x + 12, end_y, end_z) --test
            
            index3, damage3 = client.trace_bullet(enemy, enemyx, enemyy, enemyz + 70, end_x - 12, end_y, end_z) --test
            
            if(damage < lowestdmg) then
                lowestdmg = damage
                if(damage2 > damage) then
                    lowestdmg = damage2
                end
            end
            if(damage3 > damage) then
                lowestdamage = damage3
            end	
            if(lx - enemyx > 0) then
                bestangle = v
            else
                bestangle = v * -1
            end
            if bestangle > 1 then
                if ui_get(BBBFS[1]) and ui_get(BBBFS[2]) then
                    return -1
                else
                    return 1
                end
            end
        end
    end
end

local function betterfs(enemy, ...)
    local e_x, e_y, e_z = entity_hitbox_position(enemy, 0)
    local lx, ly, lz = client_eye_position()
    local yaw = CalcAngle(lx, ly, e_x, e_y)
    local rdir_x, rdir_y, rdir_z = Angle_Vector(0, (yaw + 90))
    local rend_x = lx + rdir_x * 10
    local rend_y = ly + rdir_y * 10
    
    local ldir_x, ldir_y, ldir_z = Angle_Vector(0, (yaw - 90))
    local lend_x = lx + ldir_x * 10
    local lend_y = ly + ldir_y * 10
    
    local r2dir_x, r2dir_y, r2dir_z = Angle_Vector(0, (yaw + 90))
    local r2end_x = lx + r2dir_x * 100
    local r2end_y = ly + r2dir_y * 100

    local l2dir_x, l2dir_y, l2dir_z = Angle_Vector(0, (yaw - 90))
    local l2end_x = lx + l2dir_x * 100
    local l2end_y = ly + l2dir_y * 100          
    local ldamage = get_damage(entity.get_local_player(), enemy, rend_x, rend_y, lz)
    local rdamage = get_damage(entity.get_local_player(), enemy, lend_x, lend_y, lz)

    local l2damage = get_damage(entity.get_local_player(), enemy, r2end_x, r2end_y, lz)
    local r2damage = get_damage(entity.get_local_player(), enemy, l2end_x, l2end_y, lz)
    if l2damage > r2damage or ldamage > rdamage or l2damage > ldamage then
        return 1
    elseif r2damage > l2damage or rdamage > ldamage or r2damage > rdamage then
        if ui_get(BBBFS[1]) and ui_get(BBBFS[2]) then
            return -1
        else
            return 1
        end
    else
        return(calculateBestAngle(enemy, -60, 60))
    end
end

local function is_enemy_peeking( player )
    local vx,vy,vz = entity.get_prop( player, "m_vecVelocity" )
    local speed = math.sqrt( vx*vx+vy*vy+vz*vz )
    if speed < 5 then
        return false
    end
    local ex, ey, ez = entity.get_origin( player ) 
    local lx, ly, lz = entity.get_origin( entity.get_local_player ( ) )
    local start_distance = math.abs( distance_3d( ex, ey, ez, lx, ly, lz ) )
    local smallest_distance = 999999
    for ticks = 1, predict_ticks do
        local tex,tey,tez = extrapolate( player, ticks, ex, ey, ez )
        local distance = math.abs( distance_3d( tex, tey, tez, lx, ly, lz ) )

        if distance < smallest_distance then
            smallest_distance = distance
        end
        if smallest_distance < start_distance then
            return true
        end
    end
    return smallest_distance < start_distance
end

function resethit( )
    return_reset_hit = true
    delta_brute = false
	forceangle = false
	should_swap = false
	abforcetarget = 0
end

function handlebruteangle(c)
    if should_swap == true then
	    delta_brute = true
		return_reset_hit = false
		client_delay_call(2, resethit)
		if force_antibrute == true then
		    if aa.brutedelay > 3 or aa.brutedelay == 3 then
		        if globals_curtime() > lastb then
				    ui_set(FakeL, 58)
				    brutesetting = not brutesetting
			    else
                    ui_set(FakeL, 25)
				    brutesetting = false
		        end
		    elseif aa.brutedelay > 5 then
		        if is_enemy_peeking( player ) then
				    ui_set(FakeL, 35)
				    brutesetting = not brutesetting
			    else
				    ui_set(FakeL, 59)
				    brutesetting = false
			    end
		    elseif aa.brutedelay < 10 then
		        if bruteforce then
				    ui_set(FakeL, 27)
				    brutesetting = not brutesetting
			    else
				    ui_set(FakeL, 58)
                    brutesetting = false			    
			    end
		    end
		end
		if not entity.is_dormant(antiBruteForceTarget) and entity.is_enemy(antiBruteForceTarget) then
			for k in pairs (preferbrute) do
			    if preferbrute[k] == bruteangle then
				    bruteangle = client_random_int(0, 60)
				end
			end
			if INVERTS_INFO > 0 then
			    anglefigure = bruteangle / 2
			elseif bruteangle > 10 or bruteangle == 10 then
			    anglefigure = bruteangle + 3 - bruteangle
			else
			    anglefigure = bruteangle / 1
			end
		elseif globals_curtime() > lastb and force_antibrute == true then
		    forceangle = false
		end
	end
end

local a = 0
local b = 0
local gettick = globals.tickcount
local curchoke = globals.chokedcommands
local d = false
local c = 0
local function tankyaw(x,y)
	if b - c > 0 and a == 1 then
		d = not d
		c = b
	end
	if b - c < 0 or b - c > 20 then
		c = b
    end
	return d and x or y
end

local de = false
local dd = 0
local function tankbyaw(x,z)
		if b - dd > 1 and a == 1 then
			de = not de
			dd = b
		end
		if b - dd > 20 or b - dd < 0 then
			dd = b
		end
		return de and x or z
end

local ae = false
local cad = 0
local function tankyawYJA(x,o)
	if b - cad > 1 and a == 1 then
		ae = not ae
		cad = b
	end
	if  b - cad < 0 or b - cad > 20 then
		cad = b
    end
	return d and x or o
end

local invent = 0
function ajitter(misses, side, cmd)
    local velocity = { entity.get_prop(entity.get_local_player(), "m_vecVelocity") }
    local velocity2d = math.sqrt(velocity[1]^2+velocity[2]^2)
        allow = false
        if not in_air(entity.get_local_player()) then
           allow = true
        else
           allow = false
        end
	if invent > 50 then
	    invent = 0
	end
	local value = 0
	ui_set(Pitch, "Minimal")
	ui_set(YB, "At targets")
    ui_set(Yaw, "180")
    ui_set(YJ, "Center")
    ui_set(YJA, math.random(79,79))
	ui_set(BY, "jitter")
	ui_set(BYA, 0)
	ui_set(FakeL, 58)
	ui_set(FBS, false)
	ui_set(RL, 0)
	if misses == 1 then
	    if side == 1 then
	        ui_set(YJA, math.random(-79,-79))
		    ui_set(FakeL, 52)
		elseif side == 0 then
	        ui_set(YJA, math.random(79,79))
		    ui_set(FakeL, 48)
        elseif side == 2 then
 	        ui_set(YJA, math.random(-79,-79))
		    ui_set(FakeL, 58)
		else
	        ui_set(YJA, math.random(79,79))
		    ui_set(FakeL, 58)		
		end
	elseif misses == 2 then
	    if side == 1 then
	        ui_set(YJA, math.random(-79,-79))
			value = math.random(value + 10^4, 60)
			value = value - 5
		    ui_set(FakeL, value)
		elseif side == 0 then
	        ui_set(YJA, math.random(79,79))
			value = math.random(value + 10^4, 60)
			value = value - 5
		    ui_set(FakeL, value)
        elseif side == 2 then
 	        ui_set(YJA, math.random(-79,-79))
			value = math.random(value + 10^4, 60)
			value = value - 5
		    ui_set(FakeL, value)
		else
	        ui_set(YJA, math.random(79,79))
			value = math.random(value + 10^4, 60)
			value = value - 5
		    ui_set(FakeL, value)		
		end
	end
end

local function bjitter(misses, side, cmd)
        allow = false
        if not in_air(entity.get_local_player()) then
           allow = true
        else
           allow = false
        end
	    if cmd.chokedcommands == 0 then
	        ui_set(FBS, false)
		end
	    ui_set(Pitch, "Minimal")
		ui_set(YB, "At targets")
		ui_set(Yaw, "180")
		ui_set(YA, 0)
		ui_set(YJ, "Center")
		ui_set(YJA, math.random(65,65))
		ui_set(BY, "jitter")
		ui_set(BYA, 0)
		ui_set(FBS, false)
		ui_set(FakeL, math.random(58, 59))
		ui_set(RL, 0)
end

function cjitter(misses, side, cmd)
        allow = false
        if not in_air(entity.get_local_player()) then
           allow = true
        else
           allow = false
        end
    ui_set(FBS, false)
    ui_set(Pitch, "Minimal")
	ui_set(YB, "At targets")
	ui_set(Yaw, "180")
	ui_set(YA, 5)
	ui_set(YJ, "Center")
	ui_set(YJA, 25)
	ui_set(BY, "Static")
	ui_set(FakeL, 60)
	ui_set(RL, 0)
end

function djitter(misses, side, cmd)
    local velocity = { entity.get_prop(entity.get_local_player(), "m_vecVelocity") }
    local velocity2d = math.sqrt(velocity[1]^2+velocity[2]^2)
        allow = false
        if not in_air(entity.get_local_player()) then
           allow = true
        else
           allow = false
        end
	ui_set(Pitch, "Minimal")
	ui_set(YB, "At targets")
	ui_set(Yaw, "180")
	ui_set(YJ, "Center")
	ui_set(YJA, 0)
	ui_set(BY, "Jitter")
	ui_set(BYA, 0)
	ui_set(FBS, false)
	ui_set(FakeL, 59)
	ui_set(RL, 0)
end

function lslowing(misses, side, cmd)
    local velocity = { entity.get_prop(entity.get_local_player(), "m_vecVelocity") }
    local velocity2d = math.sqrt(velocity[1]^2+velocity[2]^2)
	local pextra = (ui_get(BYA) * -1) or ui_get(BYA)
	local invent = 0
        allow = false
        if not in_air(entity.get_local_player()) then
           allow = true
        else
           allow = false
        end
	ui_set(Pitch, "Minimal")
	ui_set(YB, "At targets")
    ui_set(Yaw, "180")
	ui_set(YA, 9)
	ui_set(YJ, "Off")
	ui_set(BY, "Static")
	ui_set(BYA, 28)
	ui_set(FakeL, 48)
	ui_set(FBS, false)
	ui_set(RL, 0)
end

function lducking(misses, side, cmd)
    	ui_set(Pitch, "Minimal")
		ui_set(YB, "At targets")
		ui_set(Yaw, "180")
		ui_set(YA, -6)
		ui_set(YJ, "Center")
		ui_set(YJA, 14)
		ui_set(BY, "Static")
		ui_set(BYA, -180)
		ui_set(FakeL, math.random(60, 60))
		ui_set(FBS, false)
		ui_set(RL, 0)
end

local function gvel(p)
    if p ~= nil then
        local velocity = { entity.get_prop(p, "m_vecVelocity") }
        local velocity2d = math.sqrt(velocity[1]^2+velocity[2]^2)
        return velocity2d
    else
        return 0
    end
end

function Sinair(misses, side, cmd)
    local velocity = { entity.get_prop(entity.get_local_player(), "m_vecVelocity") }
    local velocity2d = math.sqrt(velocity[1]^2+velocity[2]^2)
        allow = false
        if not in_air(entity.get_local_player()) then
           allow = true
        else
           allow = false
        end
	if invent > 50 then
	    invent = 0
	end
    ui_set(Pitch, "Minimal")
	ui_set(YB, "At targets")
	ui_set(Yaw, "180")
	ui_set(YA, 0)
	ui_set(YJ, "Center")
	ui_set(YJA, 22)
	ui_set(BY, "Jitter")
	ui_set(BYA, 0)
	ui_set(FBS, false)
	ui_set(FakeL, math.random(60, 60))
	ui_set(RL, 0)
end

local function STATIC_AA(c)
	ui_set(Pitch, "Minimal")
	ui_set(YB, "At targets")
	ui_set(Yaw, "180")
	ui_set(YA, 0)
	ui_set(YJ, "Off")
	ui_set(BY, "Static")
	ui_set(BYA, 180)
	ui_set(FakeL, 60)
end

local function RIGHTAA(misses, side, cmd)
    ui_set(Pitch, "Minimal")
    ui_set(YJ, "off")
    ui_set(YJA, 0)
    ui_set(BY, "static")
    ui_set(BYA, 180)
    ui_set(FBS, false)
    ui_set(YB, "local view")
    ui_set(Yaw, "180")
    ui_set(YA, 90)
    ui_set(FakeL, 58)
end

local function LEFTAA(misses, side, cmd)
    ui_set(Pitch, "Minimal")
    ui_set(YJ, "off")
    ui_set(YJA, 0)
    ui_set(BY, "static")
    ui_set(BYA, 180)
    ui_set(FBS, false)
    ui_set(YB, "local view")
    ui_set(Yaw, "180")
    ui_set(YA, -90)
    ui_set(FakeL, 58)
end

aa.manaa = 0
local indfont = "nil"
local function mainAA(c)
	local aafunc = ui_get(aaf)
	local dsb = closestToCrosshair()
	local pl = entity.get_local_player()
	local al = entity_is_alive(pl)
	local vx, vy = entity.get_prop(pl, "m_vecVelocity")
	local speed = math.floor(math.min(10000, math.sqrt(vx*vx + vy*vy) + 0.5))
	local vel = gvel(pl)
	if ui_get(oss) and ui_get(dtm) and not ui_get(fakeduck) then
		ui_set(fakelag,1)
	elseif ui_get(oss) and ui_get(ost) and not ui_get(fakeduck) then
		ui_set(fakelag,1)
	elseif ui_get(oss) then
		ui_set(fakelag,14)
	end
	if ui_get(en) then
		b = gettick()
		a = curchoke()
	    if ui_get(manual_enable) then
            ui_set(manual_left, "On Hotkey")
            ui_set(manual_right, "On Hotkey")
            if aa.input + 0.22 < globals.curtime() then
                if aa.manaa == 0 then
                    if ui_get(manual_left) then
                        aa.manaa = 1
					    aa.input = globals.curtime()
                    elseif ui_get(manual_right) then
                        aa.manaa = 2
					    aa.input = globals.curtime()
                    end
                elseif aa.manaa == 1 then
                    if ui_get(manual_right) then
                        aa.manaa = 2
					    aa.input = globals.curtime()
                    elseif ui_get(manual_left) then
                        aa.manaa = 0
					    aa.input = globals.curtime()
                    end
                elseif aa.manaa == 2 then
                    if ui_get(manual_left) then
                        aa.manaa = 1
					    aa.input = globals.curtime()
                    elseif ui_get(manual_right) then
                        aa.manaa = 0
					    aa.input = globals.curtime()
                    end
                end
            end
            if aa.manaa == 2 then
                RIGHTAA(0, 0, c)
            elseif aa.manaa == 1 then            
                LEFTAA(0, 0, c)
            end
		end
		if dsb == nil then
		    aa.dormant = true
			if aa.dormant == true then
				resethit()
			end
        end
        if aa.manaa == 0 and ui_get(FS, "-") then
	        if fl_induck(pl) and fl_onground(pl) then 
		        aa.move = "duck"
				indfont = "iduck"
		    elseif fl_onground(pl) == false then
		        aa.move = "air"
				indfont = "iair"
		    elseif ui_get(slow_walk_AA) and ui_get(slow) and ui_get(slowkey) then
		        aa.move = "slow"
				indfont = "islow"
		    elseif speed > 5 and fl_onground(pl) then
		        aa.move = "run"
				indfont = "irun"
			else
			    aa.move = "stand"
				indfont = "istand"
		    end
		    if aa.move == "slow" and al and aafunc == "LARGE TANK" then
				if should_swap == true then
				    lslowing(entity_data_shots, 0, c)
					ui_set(BYA, -35)
				elseif should_swap == false then
				    lslowing(entity_data_shots, 0, c)
					ui_set(BYA, 35)
				end		
            elseif aa.move == "air" and al and aafunc == "LARGE TANK" then	
                if should_swap == true then
                    Sinair(0, 0, c)				
                    ui_set(YA, -27)
				elseif should_swap == false then
                    Sinair(0, 0, c)
                end
		    elseif aa.move == "duck" and al and aafunc == "LARGE TANK"then		
                if should_swap == true then
                    lducking(0, 0, c)				
                    ui_set(BYA, 180)
                elseif should_swap == false then
                    lducking(0, 0, c)				
				end
		    elseif aafunc == "LARGE TANK" and aa.move == "run" and al then
                ajitter(0, sides, c)
				YawS = tankyaw(2, -2)
				ui_set(YA, YawS)
		    elseif aafunc == "LARGE TANK" and aa.move == "stand" and al then
                ajitter(entity_data_shots, sides, c)
				YawS = tankyaw(2, -2)
				ui_set(YA, YawS)				
		    end
		    if aa.move == "slow" and al and aafunc == "SMALL TANK" then
				if should_swap == true then
				    lslowing(entity_data_shots, 0, c)
					ui_set(BYA, -35)
				elseif should_swap == false then
				    lslowing(entity_data_shots, 0, c)
					ui_set(BYA, 35)
				end	
            elseif aa.move == "air" and al and aafunc == "SMALL TANK" then	
                if should_swap == true then
                    Sinair(0, 0, c)				
                    ui_set(YA, -27)
				elseif should_swap == false then
                    Sinair(0, 0, c)
                end
		    elseif aa.move == "duck" and al and aafunc == "SMALL TANK"then		
                if should_swap == true then
                    lducking(0, 0, c)				
                    ui_set(BYA, 180)
                elseif should_swap == false then
                    lducking(0, 0, c)				
				end
		    elseif aafunc == "SMALL TANK" and aa.move == "run" and al then
                bjitter(0, 0, c)
				YawS = tankyaw(5, -5)
				ui_set(YA, YawS)
            elseif aafunc == "SMALL TANK" and aa.move == "stand" and al then
                bjitter(0, 0, c)
				YawS = tankyaw(5, -5)
				ui_set(YA, YawS)				
		    end
		    if aa.move == "slow" and al and aafunc == "SIMPLE JITTER" then
				if should_swap == true then
				    lslowing(entity_data_shots, 0, c)
					ui_set(BYA, -35)
				elseif should_swap == false then
				    lslowing(entity_data_shots, 0, c)
					ui_set(BYA, 35)
				end		
            elseif aa.move == "air" and al and aafunc == "SIMPLE JITTER" then	
                if should_swap == true then
                    Sinair(0, 0, c)				
                    ui_set(YA, -27)
				elseif should_swap == false then
                    Sinair(0, 0, c)
                end
		    elseif aa.move == "duck" and al and aafunc == "SIMPLE JITTER"then		
                if should_swap == true then
                    lducking(0, 0, c)				
                    ui_set(BYA, 180)
                elseif should_swap == false then
                    lducking(0, 0, c)				
				end
		    elseif aafunc == "SIMPLE JITTER" and aa.move == "run" and al then
                cjitter(0, 0, c)		
			elseif aafunc == "SIMPLE JITTER" and aa.move == "stand" and al then
                cjitter(0, 0, c)		
		    end
            if aa.move == "slow" and al and aafunc == "EX TANK" then
				if should_swap == true then
				    lslowing(entity_data_shots, 0, c)
					ui_set(BYA, -35)
				elseif should_swap == false then
				    lslowing(entity_data_shots, 0, c)
					ui_set(BYA, 35)
				end			
            elseif aa.move == "air" and al and aafunc == "EX TANK" then
                if should_swap == true then
                    Sinair(0, 0, c)				
                    ui_set(YA, -27)
				elseif should_swap == false then
                    Sinair(0, 0, c)
                end
		    elseif aa.move == "duck" and al and aafunc == "EX TANK" then
                if should_swap == true then
                    lducking(0, 0, c)				
                    ui_set(BYA, 180)
                elseif should_swap == false then
                    lducking(0, 0, c)				
				end			
		    elseif aafunc == "EX TANK" and aa.move == "run" and al then
			    if should_swap == true then
				    djitter(0, 0, c)
		            YawS = tankyaw(31, -41)
				    ui_set(YJ, "Offset")
				    ui_set(YJA, 10)
				    ui_set(YA, YawS)
				    ui_set(BY, "Jitter")
			        ui_set(BYA, 0)
				    ui_set(FakeL, 17)
				elseif should_swap == false then
				    djitter(0, 0, c)
		            YawS = tankyaw(34, -44)
				    ui_set(YJ, "Offset")
				    ui_set(YJA, 10)
				    ui_set(YA, YawS)
				    ui_set(BY, "Jitter")
			        ui_set(BYA, 0)
				    ui_set(FakeL, 13)
				end				
			elseif aafunc == "EX TANK" and aa.move == "stand" and al then
			    if should_swap == true then
			        djitter(0, 0, c)
				    YawS = tankyaw(33, -33)
				    BdoYS = tankbyaw(48 + math.random(1, 2), 57 + math.random(1, 2))
				    ui_set(BY, "static")
				    ui_set(YA, YawS)
				    ui_set(BYA, -180)
				    ui_set(FakeL, BdoYS)
				elseif should_swap == false then
			        djitter(0, 0, c)
				    YawS = tankyaw(36, -36)
				    BdoYS = tankbyaw(48, 58)
				    ui_set(BY, "static")
				    ui_set(YA, YawS)
				    ui_set(BYA, 180)
				    ui_set(FakeL, BdoYS)				
				end
			end
		end
	end
end

dir = function()
    ui_set(FSK, "Always on")
	local on_ground = bit.band(entity.get_prop(entity.get_local_player(), "m_fFlags"), 1) == 1 and not client.key_state(0x20)
	local p_key = ui_get(legit)
	local fs_e = ui_get(BBBFS[2]) and ui_get(BBBFS[1]) and on_ground
	if fs_e then
	    ui_set(FS, "Default")
	else
	    ui_set(FS, "-")
	end
end

client_set_event_callback("pre_render", function()
local lex = ui_get(leg)
if lex == "back" or "jitter" then
    ui_set(legs, "always slide")
else  
	ui_set(legs, "never slide")
end
if lex == "-" then
    ui_set(legs, "never slide")
end
    randome = math.random(1,10)
    if lex == "jitter" then
		idx = 7
		if randome > idx then
			entity.set_prop(entity.get_local_player(), "m_flPoseParameter", 1, 0)
		end
    elseif lex == "back" then
	    idx = 1
		if randome > idx then
			entity.set_prop(entity.get_local_player(), "m_flPoseParameter", 1, 0)
		end
	else
		entity.set_prop(entity.get_local_player(), "m_flPoseParameter", 1, 0)
	end
end)

local function gradient_text(r1, g1, b1, a1, r2, g2, b2, a2, text)
    local output = ''
    local len = #text-1
    local rinc = (r2 - r1) / len
    local ginc = (g2 - g1) / len
    local binc = (b2 - b1) / len
    local ainc = (a2 - a1) / len
    for i=1, len+1 do
        output = output .. ('\a%02x%02x%02x%02x%s'):format(r1, g1, b1, a1, text:sub(i, i))
        r1 = r1 + rinc
        g1 = g1 + ginc
        b1 = b1 + binc
        a1 = a1 + ainc
    end

    return output
end

local screen = {client.screen_size()}
local center = {screen[1] / 2, screen[2] / 2}
local ffi = require 'ffi'
local interface_ptr = ffi.typeof('void***')
local latency_ptr = ffi.typeof('float(__thiscall*)(void*, int)')
local rawivengineclient = client.create_interface('engine.dll', 'VEngineClient014') or error('VEngineClient014 wasnt found', 2)
local ivengineclient = ffi.cast(interface_ptr, rawivengineclient) or error('rawivengineclient is nil', 2)
local get_net_channel_info = ffi.cast('void*(__thiscall*)(void*)', ivengineclient[0][78]) or error('ivengineclient is nil')

client_set_event_callback("paint_ui", function()
    local color_1 = {ui_get(colorp)}
	local color_2 = {ui_get(colorp2)}
	local AC = {ui_get(color2)}
	local MC = {ui_get(color3)}
	local SC = {ui_get(color6)}
	local LC = {ui_get(color4)}
	local DC = {ui_get(color5)}
    local gradient_text = gradient_text(color_1[1], color_1[2], color_1[3], color_1[4], color_2[1], color_2[2], color_2[3], color_2[4], "LUNAR")
	local AAx, AAy = renderer.measure_text("b", "   LUNAR")
	local alpha_pul = 1 + math.sin(math.abs(- math.pi + globals.realtime() % (math.pi * 1))) * 219
    local ziji = entity.get_local_player()
    local apl = entity_is_alive(ziji)

	if not apl then
        return
	end
    h_index = 0
    if ui_get(ind) then
        renderer.text(center[1] - 0, center[2] + 20, 0, 0, 0, 255, "b", 0, gradient_text)
		h_index = h_index + 0
        if ui_get(dt) and ui_get(dtm) then
            if doubletap_charged() then
                renderer.text(center[1] + 1, center[2] + 38, 0, 201, 87, 255, "a-", 0, "DT+")
                h_index = h_index + 0
            else
                renderer.text(center[1] + 1, center[2] + 38, 162, 39, 42, 255, "a-", 0, "DT-")
				h_index = h_index + 0
            end
        end
		if multi_select(ui_get(AASI), "AA STATE") then
            if indfont == "iair" then
		        renderer.text(center[1] + 1, center[2] + 30 + h_index, AC[1], AC[2], AC[3], 255, "a-", 0, "IN AIR")
            elseif indfont == "irun" then
		        renderer.text(center[1] + 1, center[2] + 30 + h_index, MC[1], MC[2], MC[3], 255, "a-", 0, "MOVE")
            elseif indfont == "istand" then
		        renderer.text(center[1] + 1, center[2] + 30 + h_index, SC[1], SC[2], SC[3], 255, "a-", 0, "STAND")			
            elseif indfont == "islow" then
		        renderer.text(center[1] + 1, center[2] + 30 + h_index, LC[1], LC[2], LC[3], 255, "a-", 0, "LOWDELTA")
            elseif indfont == "iduck" then
		        renderer.text(center[1] + 1, center[2] + 30 + h_index, DC[1], DC[2], DC[3], 255, "a-", 0, "DUCK")		
		    end
		end
        if ui_get(os) and ui_get(ost) then
            if ui_get(dt) and ui_get(dtm) then
                renderer.text(center[1] + 30, center[2] + 43, 200, 139, 135, 155, "c-", 0, "ONSHOT")
            else
                renderer.text(center[1] - -15, center[2] + 43, 200, 139, 135, 255, "c-", 0, "ONSHOT")
            end
        end
	end
end)


function manvis()
    ui_set_visible(manual_left, false)
    ui_set_visible(manual_right, false)
	ui_set_visible(colorp, false)
	ui_set_visible(colorp2, false)
	ui_set_visible(labe5, false)
	ui_set_visible(labe6, false)
	ui_set_visible(AASI, false)
	ui_set_visible(aaf, false)
    ui_set_visible(leg, false)
    ui_set_visible(weak, false)
    ui_set_visible(legit, false)
    ui_set_visible(BBBFS[1], false)
    ui_set_visible(BBBFS[2], false)	
    ui_set_visible(slow_walk_AA, false)
    ui_set_visible(manual_enable, false)
	ui_set_visible(ind, false)
	ui_set_visible(labe7, false)
	ui_set_visible(labe8, false)
	ui_set_visible(labe9, false)
	ui_set_visible(oss, false)
    ui_set_visible(labe10, false)
	ui_set_visible(color2, false)
	ui_set_visible(labe11, false)
	ui_set_visible(color3, false)
	ui_set_visible(labe12, false)
	ui_set_visible(color4, false)
	ui_set_visible(labe13, false)
	ui_set_visible(color5, false)
	ui_set_visible(labe14, false)
	ui_set_visible(color6, false)
	if ui_get(en) then
	    ui_set_visible(aaf, true)
        ui_set_visible(leg, true)
        ui_set_visible(weak, true)
        ui_set_visible(legit, true)
        ui_set_visible(BBBFS[1], true)
        ui_set_visible(BBBFS[2], true)	
        ui_set_visible(slow_walk_AA, true)
        ui_set_visible(manual_enable, true)
		ui_set_visible(ind, true)
		ui_set_visible(labe7, true)
	    ui_set_visible(labe8, true)
	    ui_set_visible(labe9, true)
		ui_set_visible(oss, true)
	    ui_set_visible(labe10, true)
		ui_set_visible(color2, true)
		ui_set_visible(labe11, true)
		ui_set_visible(color3, true)
		ui_set_visible(labe12, true)
		ui_set_visible(color4, true)
		ui_set_visible(labe13, true)
		ui_set_visible(color5, true)
		ui_set_visible(labe14, true)
		ui_set_visible(color6, true)		
	else
		ui_set_visible(aaf, false)
        ui_set_visible(leg, false)
        ui_set_visible(weak, false)
        ui_set_visible(legit, false)
        ui_set_visible(BBBFS[1], false)
        ui_set_visible(BBBFS[2], false)	
        ui_set_visible(slow_walk_AA, false)
        ui_set_visible(manual_enable, false)
		ui_set_visible(ind, false)
		ui_set_visible(labe7, false)
	    ui_set_visible(labe8, false)
	    ui_set_visible(labe9, false)
		ui_set_visible(oss, false)
        ui_set_visible(labe10, false)
	    ui_set_visible(color2, false)
	    ui_set_visible(labe11, false)
	    ui_set_visible(color3, false)
	    ui_set_visible(labe12, false)
	    ui_set_visible(color4, false)
	    ui_set_visible(labe13, false)
	    ui_set_visible(color5, false)
	    ui_set_visible(labe14, false)
	    ui_set_visible(color6, false)		
	end
    if ui_get(manual_enable) then
        ui_set_visible(manual_left, true)
        ui_set_visible(manual_right, true)
    end
	if ui_get(ind) then
		ui_set_visible(AASI, true)
		ui_set_visible(colorp, true)
		ui_set_visible(colorp2, true)
		ui_set_visible(labe5, true)
		ui_set_visible(labe6, true)
	end
	if multi_select(ui_get(AASI), "AA STATE") then
	    ui_set_visible(labe10, true)
		ui_set_visible(color2, true)
		ui_set_visible(labe11, true)
		ui_set_visible(color3, true)
		ui_set_visible(labe12, true)
		ui_set_visible(color4, true)
		ui_set_visible(labe13, true)
		ui_set_visible(color5, true)
		ui_set_visible(labe14, true)
		ui_set_visible(color6, true)
	else
        ui_set_visible(labe10, false)
	    ui_set_visible(color2, false)
	    ui_set_visible(labe11, false)
	    ui_set_visible(color3, false)
	    ui_set_visible(labe12, false)
	    ui_set_visible(color4, false)
	    ui_set_visible(labe13, false)
	    ui_set_visible(color5, false)
	    ui_set_visible(labe14, false)
	    ui_set_visible(color6, false)	
	end
end
   
function forpaint()
    manvis()
end

client_set_event_callback("player_hurt", on_player_hurt)
client_set_event_callback("bullet_impact", avoidshot)
create_callback("setup_command", mainAA)
create_callback("setup_command", dir)
create_callback("setup_command", setupsimple)
create_callback("paint_ui", uiyincang)
create_callback("paint_ui", forpaint)
create_callback("setup_command", handlebruteangle) 

Lua online compiler

Write, Run & Share Lua code online using OneCompiler's Lua online compiler for free. It's one of the robust, feature-rich online compilers for Lua language, running the latest Lua version 5.4. Getting started with the OneCompiler's Lua editor is easy and fast. The editor shows sample boilerplate code when you choose language as Lua and start coding.

Taking inputs (stdin)

OneCompiler's Lua online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Lua program which takes name as input and prints hello message with your name.

name = io.read("*a")
print ("Hello ", name)

About Lua

Lua is a light weight embeddable scripting language which is built on top of C. It is used in almost all kind of applications like games, web applications, mobile applications, image processing etc. It's a very powerful, fast, easy to learn, open-source scripting language.

Syntax help

Variables

  • By default all the variables declared are global variables
  • If the variables are explicitly mentioned as local then they are local variables.
  • Lua is a dynamically typed language and hence only the values will have types not the variables.

Examples

-- global variables
a = 10

-- local variables

local x = 30
Value TypeDescription
numberRepresents numbers
stringRepresents text
nilDifferentiates values whether it has data or not
booleanValue can be either true or false
functionRepresents a sub-routine
userdataRepresents arbitary C data
threadRepresents independent threads of execution.
tableCan hold any value except nil

Loops

1. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while(condition)
do
--code
end

2. Repeat-Until:

Repeat-Until is also used to iterate a set of statements based on a condition. It is very similar to Do-While, it is mostly used when you need to execute the statements atleast once.

repeat
   --code
until( condition )

3. For:

For loop is used to iterate a set of statements based on a condition.

for init,max/min value, increment
do
   --code
end

Functions

Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increase re-usuability and modularity.

optional_function_scope function function_name( argument1, argument2, argument3........, argumentn)
--code
return params with comma seperated
end