--Security
local users = "pa1us, rosse, PeTeRo, legmiss"
local username = globals.get_username()
if string.find(users, username) then
    client.log("Welcome")
else
    client.log("imagine using leaked version")
    console.execute("quit")
end


menu.next_line()
menu.add_slider_int("Rage Selection", 0, 0)
menu.add_key_bind("Body Aim")
menu.add_check_box("Safe Point On Autopeek")
menu.add_check_box("Baim On Autopeek")
menu.add_slider_int("Anti Aim Selection", 0, 0)
menu.add_combo_box("Anti-Aim type", {"Select", "Minimal Jiter", "Static", "Jiter", "Adaptive Jiter", "Low Delta", })
menu.add_check_box("Dodge Bruteforce")
menu.add_check_box("Avoid Backstab")
menu.add_check_box("Edge Yaw") 
menu.add_key_bind("Edge Yaw Bind")
menu.add_check_box("Legit AA")
menu.add_key_bind("Legit AA Bind")
menu.add_key_bind("Custom Slow Walk")
menu.add_slider_int("Custom Slow Walk Speed", 1, 120)
menu.add_check_box("Anti Bruteforce")
menu.add_combo_box("Anti Bruteforce Condition", {"Select", "On Shot", "On Hit"})
menu.add_slider_int("Miscelanous", 0, 0)
menu.add_check_box("Leg Breaker")
menu.add_slider_int("Speed", 1, 3 )
menu.add_check_box("Quick Peek")
menu.add_check_box("Third Person Distance")
menu.add_slider_int("Distance", 50, 150  )
menu.add_check_box("Viewmodel In Scope")
menu.add_check_box("Nortsync Logs")
menu.add_slider_int("Visuals ", 0, 0)
menu.add_combo_box("Indicators Type", {"Select", "First Style", "Second Style"})
menu.add_color_picker("Second Style Line Color")
menu.add_check_box("Anti Aim Arrows") 
menu.add_color_picker("Color Active Manual")
menu.add_check_box("Watermark")
menu.add_check_box("Autopeek Dot")
menu.add_key_bind("Autopeek Dot")
menu.add_color_picker("Autopeek Color")
menu.add_slider_int("", 0, 0)

local font3 = render.create_font("Calibri", 15, 1, true, true, false) --Indicators
local font = render.create_font("Small Fonts", 10, 200, true, false, true)


--1 style
local function bindactive(bind)
    if menu.get_key_bind_state(bind) then
        return true
    else 
        return false
    end
end
local baimonkey = function()
    if menu.get_key_bind_state("Body Aim") then
        v = 0
        for i=0,8 do
          menu.set_int("rage.weapon[" .. i .. "].body_aim", 2)
        end
    end
end
client.add_callback("create_move", baimonkey)
client.add_callback("on_paint", baimonkey)
client.add_callback("on_paint", function()
    local offset = 40
    local offsety = 50
    local offsetx = 8
    local dt = bindactive("rage.double_tap_key")
    local hs = bindactive("rage.hide_shots_key")
    local fd = bindactive("anti_aim.fake_duck_key")
    local dmg = bindactive("rage.force_damage_key")
    local ap = bindactive("misc.automatic_peek_key")
    local body = menu.get_key_bind_state("Body Aim") 
    local dodge = bindactive("misc.slow_walk_key")
    if menu.get_int("Indicators Type") == 1 then
        if engine.is_connected() then
    render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offset, color.new(209, 209, 209), "NORTSYNC")
    render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(132, 110, 181), "DYNAMIC")


    if(dodge) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(147, 245, 222), "DODGE")
    end
    if(dt) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(144, 255, 25), "DT")
    end
    if(hs) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(255, 255, 255), "AA")
    end
    if(dmg) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(199, 147, 245), "DMG")
    end
    if(fd) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(149, 147, 245), "DUCK")
    end
    if(ap) then
       offsety = offsety + 10
    render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(147, 170, 245), "PEEK") 
    end
    if(body) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(43, 255, 138), "BAIM")
    end
else
    return end
end
end)

-- 2 style
local ffi = require("ffi")
local UnhsAEhFcg = 1839226496
local function pqhUziiLXh()
local NdkBMTqxLS = 4194228727
end
client.add_callback( "on_paint", pqhUziiLXh)
local function pqhUziiLXh()
end
client.add_callback( "on_paint", pqhUziiLXh)
local entity=render.create_font("Calibri Bold",16,4,false,true,false)
local cpfont = render.create_font("Calibri Bold", 16, 4, false, true, false)
local sw, sh = engine.get_screen_width(), engine.get_screen_height()
ffi.cdef[[
    typedef unsigned char BYTE;
    typedef void *PVOID;
    typedef PVOID HMODULE;
    typedef const char *LPCSTR;
    typedef int *FARPROC;
    
    HMODULE GetModuleHandleA(
        LPCSTR lpModuleName
    );
    
    FARPROC GetProcAddress(
        HMODULE hModule,
        LPCSTR  lpProcName
    );
    
    typedef struct{
        BYTE r, g, b, a;
    } Color;
    
    typedef void(__cdecl *ColorMsgFn)(Color&, const char*);
]]
local ConsolePrint = function(label, r, g, b, a)
    local ConColorMsg = ffi.cast("ColorMsgFn", ffi.C.GetProcAddress(ffi.C.GetModuleHandleA("tier0.dll"), "?ConColorMsg@@YAXABVColor@@PBDZZ"))
    local color = ffi.new("Color") 
    color.r = r
    color.g = g
    color.b = b
    color.a = a
    ConColorMsg( color, label )
end
local function l()
    ballchunks = 1
    local desync = menu.get_key_bind_state("anti_aim.invert_desync_key")
    if menu.get_int("Indicators Type") == 2 then
        local *****=menu.get_color("Second Style Line Color")
    if engine.is_connected() then
    if desync then
         render.draw_text(entity, sw/2-render.get_text_width(cpfont, "sync")/5+ 8, sh/2+29, color.new(255, 255, 255), "sync")
 render.draw_text(entity, sw/2-render.get_text_width(cpfont, "Nort")/2- 11, sh/2+29, color.new(0, 0, 0, 50), "Nort")
        render.draw_text(entity, sw/2-render.get_text_width(cpfont, "Nort")/2- 11, sh/2+28, color.new(180, 180, 180, 255), "Nort")
                render.draw_text(entity, sw/2-render.get_text_width(cpfont, "________")/2, sh/2+32, *****, "________")
    else
        render.draw_text(entity, sw/2-render.get_text_width(cpfont, "Nort")/2- 11, sh/2+29, color.new(255, 255, 255), "Nort")
       render.draw_text(entity, sw/2-render.get_text_width(cpfont, "sync")/4+ 8, sh/2+29, color.new(0, 0, 0, 50), "sync")
       render.draw_text(entity, sw/2-render.get_text_width(cpfont, "sync")/4+ 8, sh/2+28, color.new(180, 180, 180, 255), "sync")
        render.draw_text(entity, sw/2-render.get_text_width(cpfont, "________")/2, sh/2+32, *****, "________")
            ballchunks = ballchunks + 1
        end
        end
        end
    end
client.add_callback("on_paint",l)
local font = render.create_font("Small Fonts", 12, 150, true, false, true)
local function bindactive(bind)
    if menu.get_key_bind_state(bind) then
        return true
    else
        return false
    end
end
client.add_callback("on_paint", function()
    if menu.get_int("Indicators Type") == 2 then
    local fd = bindactive("anti_aim.fake_duck_key")
    local dmg = bindactive("rage.force_damage_key")
    local body = menu.get_key_bind_state("Body Aim") 
    local dodge = bindactive("misc.slow_walk_key")
    local dt = bindactive("rage.double_tap_key")
    local hs = bindactive("rage.hide_shots_key")
    local ap = bindactive("misc.automatic_peek_key")
    local offset = 2
    local offsety = 35
    local offsetx = -10
    if(dt) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(255, 255, 255), "DT")
    end
    if(hs) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(255, 255, 255), "HS")
    end
    if(fd) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(255, 255, 255), "FD")
    end
    if(dmg) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(255, 255, 255), "DMG")
    end
    if(body) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(255, 255, 255), "BODY")
    end
    if(dodge) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(255, 255, 255), "DODGE")
    end
    if(ap) then
        offsety = offsety + 10
        render.draw_text(font3, engine.get_screen_width()/2 + offsetx, engine.get_screen_height()/2 + offsety, color.new(255, 255, 255), "PEEK")
    end
end
end)

--AA Arrows
local screen_width = engine.get_screen_width()
local screen_x, screen_y = engine.get_screen_width(), engine.get_screen_height()
local localplayer = entitylist.get_local_player()
local font4 = render.create_font("Calibri", 17, 300, true, true, false) --Arrows
local font5 = render.create_font("Calibri", 17, 280, true, true, false) --Backward Arrow
local function bindactive(bind)
    if menu.get_key_bind_state(bind) then
        return true
    else
        return false   
    end
end

client.add_callback("on_paint", function()
    if menu.get_bool("Anti Aim Arrows") then
    local color = menu.get_color("Color Active Manual")
    local right = bindactive("anti_aim.manual_right_key")
    local left = bindactive("anti_aim.manual_left_key")
    local back = bindactive("anti_aim.manual_back_key")
    local desync = menu.get_key_bind_state("anti_aim.invert_desync_key")
    render.draw_text(font4, engine.get_screen_width()/2 + 29, engine.get_screen_height()/2  - 15, color.new(40, 40, 40), ">")
    if(right) then
        render.draw_text(font4, engine.get_screen_width()/2 + 29, engine.get_screen_height()/2  - 15, color, ">")
        end
    render.draw_text(font4, engine.get_screen_width()/2 -39, engine.get_screen_height()/2 -15 , color.new(40, 40, 40), "<")
    if(left) then
        render.draw_text(font4, engine.get_screen_width()/2 -39, engine.get_screen_height()/2 - 15, color, "<")
        end
         if desync then
      render.draw_text(font4, engine.get_screen_width()/2 + 18, engine.get_screen_height()/2 - 15, color, ">")
    else
      render.draw_text(font4, engine.get_screen_width()/2 - 29, engine.get_screen_height()/2 - 15, color, "<")
    end   
end 
end)

local ffi = require("ffi")
ffi.cdef[[
    typedef uintptr_t (__thiscall* GetClientEntity_4242425_t)(void*, int);

    typedef struct _Vector {
        float x,y,z;
    } Vector;

    typedef struct _color_t {
        unsigned char r, g, b;
        signed char exponent;
    } color_t;

    typedef struct _dlight_t {
        int flags;
        Vector origin;
        float radius;
        color_t color;
        float die;
        float decay;
        float minlight;
        int key;
        int style;
        Vector direction;
        float innerAngle;
        float outerAngle;
    } dlight_t;
]]

local entity_list_ptr = ffi.cast("void***", utils.create_interface("client.dll", "VClientEntityList003"))
local get_client_entity_fn = ffi.cast("GetClientEntity_4242425_t", entity_list_ptr[0][3])

local ffi_helpers = {
    get_entity_address = function(ent_index)
        local addr = get_client_entity_fn(entity_list_ptr, ent_index)
        return addr
    end
}
menu.next_line() --to not mess with other features from another script

local effects = ffi.cast(ffi.typeof("void***"), utils.create_interface("engine.dll", "VEngineEffects001"))
local alloc_dlight = ffi.cast(ffi.typeof('dlight_t*(__thiscall*)(void*, int)'), effects[0][4])
local alloc_elight = ffi.cast(ffi.typeof('dlight_t*(__thiscall*)(void*, int)'), effects[0][5])

local function draw(i,pos,clr)
    local dlight = alloc_dlight(effects,i)
    dlight.key = i
    dlight.color.r =clr:r()
    dlight.color.g =clr:g()
    dlight.color.b =clr:b()
    dlight.color.exponent = 5
    dlight.flags = 0x2
    dlight.style = 1
    dlight.direction.x = pos[1]
    dlight.direction.y = pos[2]
    dlight.direction.z = pos[3]
    dlight.origin.x = pos[1]
    dlight.origin.y = pos[2]
    dlight.origin.z = pos[3]
    dlight.radius = 100
    dlight.die = globals.get_curtime() + 0.1
    dlight.decay = 100/5

    local elight = alloc_elight(effects,i)
    elight.key = i
    elight.color.r =clr:r()
    elight.color.g =clr:g()
    elight.color.b =clr:b()
    elight.color.exponent = 5
    elight.flags = 0x0
    elight.style = 1
    elight.direction.x = pos[1]
    elight.direction.y = pos[2]
    elight.direction.z = pos[3]
    elight.origin.x = pos[1]
    elight.origin.y = pos[2]
    elight.origin.z = pos[3]
    elight.radius = 150
    elight.die = globals.get_curtime() + 0.1
    elight.decay = 150/5
end

local old_autopeekcol = menu.get_color( "misc.automatic_peek_clr" )
menu.set_color( "misc.automatic_peek_clr", color.new(255,255,255,255))

o_orig = {0,0,0}

client.add_callback( "on_paint", function()
    if menu.get_bool("Autopeek Dot") then
    if not engine.is_connected() then return end
    if not engine.is_in_game() then return end
    local clr = menu.get_color("Autopeek Color")--cuz bugs exists
    local player = entitylist.get_local_player()
    if not player then return end
   
    local origin = ffi.cast("Vector*",ffi_helpers.get_entity_address(player:get_index())+312)
    if menu.get_key_bind_state( "misc.automatic_peek_key" ) then
        if o_orig[1] == 0 then
            o_orig[1] = math.floor(origin.x)
        end
        if o_orig[2] == 0 then
            o_orig[2] = math.floor(origin.y)
        end
        if o_orig[3] == 0 then
            o_orig[3] = math.floor(origin.z)
        end
        draw(player:get_index(),o_orig,clr)
    else
        o_orig[1] = 0
        o_orig[2] = 0
        o_orig[3] = 0
    end      
end
end)

client.add_callback( "unload", function() 
    menu.set_color( "misc.automatic_peek_clr" , old_autopeekcol)
end)

client.add_callback( "unload", function() 
    menu.set_color( "misc.automatic_peek_clr" , old_autopeekcol)
end)

-- leg breaker
local menu_check_box = menu.add_check_box
local menu_get_bool = menu.get_bool
local menu_set_int = menu.set_int

-- Math
local math_random = math.random

-- Callback / Event
local events_register_event = events.register_event
local client_add_callback = client.add_callback

-- Entitylist
entitylist_get_local_player = entitylist.get_local_player

-- Our menu additions

-- FFI
local ffi = require "ffi"

ffi.cdef[[
    typedef uintptr_t (__thiscall* GetClientEntity_4242425_t)(void*, int);
]]

local entity_list_ptr = ffi.cast("void***", utils.create_interface("client.dll", "VClientEntityList003"))
local get_client_entity_fn = ffi.cast("GetClientEntity_4242425_t", entity_list_ptr[0][3])

local ffi_helpers = {
    get_animstate_offset = function()
        return 14612
    end,

    get_entity_address = function(ent_index)
        local addr = get_client_entity_fn(entity_list_ptr, ent_index)
        return addr
    end
}


-- Lets break our legs!
client_add_callback("on_paint", function()
    if menu_get_bool("Leg Breaker") then
        local localplayer = entitylist_get_local_player()
        if not localplayer then return end
        ffi.cast("float*", ffi_helpers.get_entity_address(localplayer:get_index()) + 10100)[0] = 0

        menu_set_int("misc.leg_movement", math_random(1, 2))
     end
	 end)
	 
-- realev lua
local counter =0
local function legjitter()
if counter>80 then
counter=0
menu.set_int("misc.leg_movement", 2)
else
    counter=counter+menu.get_int("Speed")*10
  menu.set_int("misc.leg_movement", 1)
end
end
client.add_callback( "create_move", legjitter)


-- Avoid Backstab
local function calculateAngle(src, point)
    local angles = vector.new(0, 0, 0)

    local delta = vector.new(src.x - point.x, src.y - point.y, src.z - point.z)
    local hyp = delta:length_2d()

    angles.y = math.atan(delta.y / delta.x) * math.pi
    angles.x = math.atan(-delta.z / hyp) * -math.pi
    angles.z = 0.0
    angles.y = angles.y + 180.0

    return angles
end

function normalize_yaw(y)
    while y > 180 do
        y = y - 360
    end
    while y < -180 do
        y = y + 360
    end
    return y
end

function get_eye_position(player, cmd)
    local origin = player:get_origin()
    return vector.new(origin.x + cmd.viewangles.x, origin.y + cmd.viewangles.y, origin.z + cmd.viewangles.z)
end

function isKnife(weap)
    local idx = weap:get_prop_int("CBaseCombatWeapon", "m_iItemDefinitionIndex")
    if idx == 42 or idx == 500 or idx == 515 or idx == 512 or idx == 505 or idx == 506 or idx == 507 or idx == 508 or idx == 516 or idx == 514 or idx == 59 or idx == 509 or idx == 41 or idx == 80 or idx == 520 or idx == 522 or idx == 519 or idx == 523 or idx == 503 or idx == 518 or idx == 517 or idx == 521 or idx == 525 then
        return true
    end
    return false
end

local backup = {
    did = false,
    yaw = 0,
    pitch = 0,
    target = 0
}

function antiBackstab(cmd)
    local localplayer = entitylist.get_local_player()
    if not localplayer then return end
    if menu.get_bool("Avoid Backstab") == false then return end
    local lorigin = localplayer:get_origin()
    local found_data = {
        found = false,
        best_dist = 0,
        player = nil
    }
    for i = 0,globals.get_maxclients() do
        local ent = entitylist.get_player_by_index(i)
        if ent and ent:is_player() then
            local player = entitylist.entity_to_player(ent)
            if player:get_health() > 0 and player:get_team() ~= localplayer:get_team() then
                local weap = entitylist.get_weapon_by_player(player)
                if isKnife(weap) == true then
                    local origin = player:get_origin()
                    local dist = lorigin:dist_to(origin)
                    if dist < 400 and (dist < found_data.best_dist or found_data.found == false) then
                        found_data.found = true
                        found_data.best_dist = dist
                        found_data.player = player
                    end
                end
            end
        end
    end
    if found_data.found == true then
        if backup.did == false then
            backup.did = true
            backup.yaw = menu.get_int("anti_aim.yaw_offset")
            backup.pitch = menu.get_int("anti_aim.pitch")
            backup.target = menu.get_int("anti_aim.target_yaw")
        end
        local angs = calculateAngle(get_eye_position(localplayer, cmd), found_data.player:get_origin())
        menu.set_int("anti_aim.yaw_offset", normalize_yaw(menu.get_int("anti_aim.yaw_offset") + math.floor(angs.y)))
        menu.set_int("anti_aim.pitch", 0)
        menu.set_int("anti_aim.target_yaw", 1)
    elseif backup.did == true then
        menu.set_int("anti_aim.yaw_offset", backup.yaw)
        menu.set_int("anti_aim.pitch", backup.pitch)
        menu.set_int("anti_aim.target_yaw", backup.target)
        backup.did = false
    end
end

client.add_callback("create_move", antiBackstab)

--slowwalk 
local bit = require("bit")
local function a(cmd)
    if not menu.get_key_bind_state("Custom Slow Walk") then
        return
    end
    if not entitylist.get_local_player() then
        return
    end

    Forward_Flag = bit.band(cmd.buttons, 8) == 8
    Back_Flag = bit.band(cmd.buttons, 16) == 16
    Left_Flag = bit.band(cmd.buttons, 512) == 512
    Right_Flag = bit.band(cmd.buttons, 1024) == 1024

    Movement_Straight = 0
    Movement_Side = 0

    if Forward_Flag then
        Movement_Straight = Movement_Straight + menu.get_int("Custom Slow Walk Speed")
    end

    if Back_Flag then
        Movement_Straight = Movement_Straight - menu.get_int("Custom Slow Walk Speed")
    end

    if Left_Flag then
        Movement_Side = Movement_Side - menu.get_int("Custom Slow Walk Speed")
    end

    if Right_Flag then
        Movement_Side = Movement_Side + menu.get_int("Custom Slow Walk Speed")
    end


    cmd.forwardmove = Movement_Straight
    cmd.sidemove = Movement_Side
    --if()
    --cmd.forwardmove = 300
    --cmd.sidemove = 300
    --client.log(tostring(cmd.forwardmove))
    --client.log(tostring(cmd.sidemove))
    return
end
client.add_callback("create_move",a)

-- thirdperson override
local function thirdperson()

    if menu.get_bool("Third Person Distance") then
        local tpd = menu.get_int("Distance")
            menu.set_int("misc.third_person_distance", tpd)
    end

end

client.add_callback("create_move", thirdperson)

-- Safe Point on autopeek
local v = 1
local function baim()
  if menu.get_bool("Safe Point On Autopeek") then
  local ap = bindactive("misc.automatic_peek_key")
  if(ap) then
    v = 0
    for i=0,8 do
      menu.set_int("rage.weapon[" .. i .. "].body_aim", 1)
    end
  else
    if v == 0 then
    menu.set_int("rage.weapon[0].body_aim", 0)
    menu.set_int("rage.weapon[1].body_aim", 0)
    menu.set_int("rage.weapon[2].body_aim", 0)
    menu.set_int("rage.weapon[3].body_aim", 0)
    menu.set_int("rage.weapon[4].body_aim", 0)
    menu.set_int("rage.weapon[5].body_aim", 0)
    menu.set_int("rage.weapon[6].body_aim", 0)
    menu.set_int("rage.weapon[7].body_aim", 0)
    menu.set_int("rage.weapon[8].body_aim", 0)
    v = 1
    end
  end
end
end

-- Baim on autopeek
local v = 1
local function baim()
  if menu.get_bool("Baim On Autopeek") then
  local ap = bindactive("misc.automatic_peek_key")
  if(ap) then
    v = 0
    for i=0,8 do
      menu.set_int("rage.weapon[" .. i .. "].body_aim", 2)
    end
  else
    if v == 0 then
    menu.set_int("rage.weapon[0].body_aim", 0)
    menu.set_int("rage.weapon[1].body_aim", 0)
    menu.set_int("rage.weapon[2].body_aim", 0)
    menu.set_int("rage.weapon[3].body_aim", 0)
    menu.set_int("rage.weapon[4].body_aim", 0)
    menu.set_int("rage.weapon[5].body_aim", 0)
    menu.set_int("rage.weapon[6].body_aim", 0)
    menu.set_int("rage.weapon[7].body_aim", 0)
    menu.set_int("rage.weapon[8].body_aim", 0)
    v = 1
    end
  end
end
end


--edge yaw 
client.add_callback( "on_paint" , function()
    if menu.get_key_bind_state("Edge Yaw Bind") == true then
        menu.set_bool("anti_aim.edge_yaw", true)
    else
        menu.set_bool("anti_aim.edge_yaw", false)
    end
end)


--safe points
client.add_callback("on_paint", function()
    if not engine.is_in_game() then return end
    
    for nomer = 0, 64 do
        if menu.get_key_bind_state("Body Aim") == true then
            menu.set_bool( "player_list.player_settings[" .. nomer .. "].force_safe_points", true )
        else
            menu.set_bool( "player_list.player_settings[" .. nomer .. "].force_safe_points", false )
        end
    end
end)


-- quick peek
local curpos = vector.new()
function setmovement(xz,yz,cmd)
    local local_player = entitylist.get_local_player()
    local current_pos = local_player:get_origin()
    local yaw = engine.get_view_angles().y

    local vector_forward = { 
        x = current_pos.x - xz,
        y = current_pos.y - yz,
    }
     
    local velocity = {
        x = -(vector_forward.x * math.cos(yaw / 180 * math.pi) + vector_forward.y * math.sin(yaw / 180 * math.pi)),
        y = vector_forward.y * math.cos(yaw / 180 * math.pi) - vector_forward.x * math.sin(yaw / 180 * math.pi),
    }
    cmd.forwardmove = velocity.x * 15
    cmd.sidemove = velocity.y * 15
end;

client.add_callback( "create_move", function(cmd)
    local localplayer = entitylist.get_local_player();
    local forw = bit.band(cmd.buttons, 8) == 8;
    local back = bit.band(cmd.buttons, 16) == 16;
    local righ = bit.band(cmd.buttons, 512) == 512;
    local left = bit.band(cmd.buttons, 1024) == 1024;
    local apeek = menu.get_key_bind_state( "misc.automatic_peek_key" );
    local originalpos = localplayer:get_origin();
    local OnGround = bit.band(localplayer: get_prop_int("CBasePlayer","m_hGroundEntity"), 1);

    if OnGround == 1 or bit.band(cmd.buttons, buttons.in_jump) == buttons.in_jump then -- air check
        air = true
    else
        air = false
    end
    if apeek == false then
        curpos = localplayer:get_origin();
    end
    if menu.get_bool("Quick Peek") then
        if apeek == false then
            menu.set_bool( "misc.fast_stop", true );
        else
            if forw == false and back == false and left == false and righ == false and math.floor(curpos.x) ~= math.floor(originalpos.x) and math.floor(curpos.y) ~= math.floor(originalpos.y) and air == false then
                menu.set_bool( "misc.fast_stop", false );
                setmovement(curpos.x,curpos.y, cmd);
            else
                menu.set_bool( "misc.fast_stop", true );
            end
        end
    end
end)



--legit aa
client.add_callback("on_paint", function()
if menu.get_key_bind_state("Legit AA Bind") then
            menu.set_int("anti_aim.pitch", 0)
            menu.set_int("anti_aim.yaw_offset", 180)
        else
           menu.set_int("anti_aim.pitch", 1)
           menu.set_int("anti_aim.yaw_offset", 0)
        end
end)


--invert
function on_shot(shot_info)
    if menu.get_bool("Anti Bruteforce") then
        if menu.get_int("Anti Bruteforce") == 1 then
            if menu.get_key_bind_state("anti_aim.invert_desync_key") then
                menu.set_bool("anti_aim.invert_desync_key", false)
            else
                menu.set_bool("anti_aim.invert_desync_key", true)
            end
        end

        if menu.get_int("Anti Bruteforce") == 2 then
            if shot_info.result == "Hit" then
                
                if menu.get_key_bind_state("anti_aim.invert_desync_key") then
                    menu.set_bool("anti_aim.invert_desync_key", false)
                else
                    menu.set_bool("anti_aim.invert_desync_key", true)
                end
            end
        end
    end
end
client.add_callback("on_shot", on_shot)


--Viewmodel in scope
local function weapon_scope()
    console.set_int("sv_cheats", 1)
    if menu.get_bool("Viewmodel In Scope") then
        console.execute("fov_cs_debug 90")  
    else
        console.execute("fov_cs_debug 0")
    end
end

local w = engine.get_screen_width()
local h = engine.get_screen_height()

local xcenter = w / 2
local ycenter = h / 2

-- Triangles --
local triange_size = 10

local left_xoffset = -45
local left_yoffset = 0

local right_xoffset = 65
local right_yoffset = 0

-- Triangle Left --
local left_x1 = left_xoffset + xcenter + 0
local left_y1 = left_yoffset + ycenter + triange_size
local left_x2 = left_xoffset + xcenter - triange_size * 2
local left_y2 = left_yoffset + ycenter + 0
local left_x3 = left_xoffset + xcenter + 0
local left_y3 = left_yoffset + ycenter - triange_size

-- Triangle Right --
local right_x1 = right_xoffset + xcenter + 0
local right_y1 = right_yoffset + ycenter + 0
local right_x2 = right_xoffset + xcenter - triange_size * 1.8
local right_y2 = right_yoffset + ycenter + triange_size
local right_x3 = right_xoffset + xcenter - triange_size * 1.8
local right_y3 = right_yoffset + ycenter - triange_size



-- Arrows --
local arrow_size = 2.6

local arrow_left_xoffset = -43
local arrow_left_yoffset = 0

local arrow_right_xoffset = 43
local arrow_right_yoffset = 0

-- Arrow Left --
local arrow_left_x1 = xcenter + arrow_left_xoffset
local arrow_left_y1 = ycenter - triange_size
local arrow_left_x2 = xcenter - xcenter + arrow_size
local arrow_left_y2 = ycenter - ycenter + arrow_size * arrow_size * 3.0

-- Arrow Right --
local arrow_right_x1 = xcenter + arrow_right_xoffset
local arrow_right_y1 = ycenter - triange_size
local arrow_right_x2 = xcenter - xcenter + arrow_size
local arrow_right_y2 = ycenter - ycenter + arrow_size * arrow_size * 3.0




local delta1 = 30
local delta2 = -18

local function aa()
    if menu.get_int("Anti-Aim type") == 0 then

    elseif menu.get_int("Anti-Aim type") == 1 then -- Minimal Jiter

        menu.set_int("anti_aim.desync_type", 1)
        menu.set_int("anti_aim.desync_range", 23)
        menu.set_int("anti_aim.desync_range_inverted", 24)
        menu.set_int("anti_aim.yaw_modifier", 1)
        menu.set_int("anti_aim.yaw_modifier_range", 12)
        menu.set_int("anti_aim.yaw_offset", 0)
        
    elseif menu.get_int("Anti-Aim type") == 2 then -- Static
        menu.set_int("anti_aim.desync_type", 1)
        menu.set_int("anti_aim.yaw_modifier", 0)
        menu.set_int("anti_aim.yaw_modifier_range", 0)
        menu.set_int("anti_aim.desync_range", 40)
        menu.set_int("anti_aim.desync_range_inverted", 45)

    elseif menu.get_int("Anti-Aim type") == 3 then -- Jiter
        menu.set_int("anti_aim.desync_type", 2) 
        menu.set_int("anti_aim.yaw_modifier", 1)
        menu.set_int("anti_aim.yaw_modifier_range", 6)
        menu.set_int("anti_aim.desync_range", 23)
        menu.set_int("anti_aim.desync_range_inverted", 24)

        elseif menu.get_int("Anti-Aim type") == 4 then -- Jiter

            menu.set_int("anti_aim.desync_type", 2)
            menu.set_int("anti_aim.desync_range", 60)
            menu.set_int("anti_aim.desync_range_inverted", 60)
            menu.set_int("anti_aim.yaw_modifier", 0)
	        menu.set_int("anti_aim.yaw_modifier_range", 0)
	        menu.set_int("anti_aim.yaw_offset", 0)

        elseif menu.get_int("Anti-Aim type") == 5 then -- Low Delta

            menu.set_int("anti_aim.desync_type", 1)
            menu.set_int("anti_aim.desync_range", 17)
            menu.set_int("anti_aim.desync_range_inverted", 17)
            menu.set_int("anti_aim.yaw_modifier", 0)
	        menu.set_int("anti_aim.yaw_modifier_range", 0)
	        menu.set_int("anti_aim.yaw_offset", 0)

    
    end
end

local old_yaw_range = menu.get_int("anti_aim.yaw_modifier_range")


local x = 0
local des_old = menu.get_int("anti_aim.desync_range")
local des_r_old =  menu.get_int("anti_aim.desync_range_inverted")



function lowdelta()

	if menu.get_bool("Dodge Bruteforce") then
		if menu.get_key_bind_state("misc.slow_walk_key") then
		menu.set_int("anti_aim.yaw_modifier", 1)
	    menu.set_int("anti_aim.yaw_modifier_range", 0)
	    menu.set_int("anti_aim.yaw_offset", 0)
	    menu.set_int("anti_aim.desync_range", 15)
        menu.set_int("anti_aim.desync_range_inverted", 15)
	    x = 0
	  else
	  	if x == 0 then
	  		menu.set_int("anti_aim.yaw_modifier_range", old_yaw_range)
	    	menu.set_int("anti_aim.yaw_offset", 0)
	    	menu.set_int("anti_aim.desync_range", des_old)
	    	menu.set_int("anti_aim.desync_range_inverted", des_r_old)
	    	x = 1
	  	end
	  end
	  end
end

local font = render.create_font("Franklin Gothic Medium", 19, 400, true, true, false)

client.add_callback("on_paint", function()
    if menu.get_bool("Watermark") then
        local r = math.floor( math.sin( globals.get_realtime() * 2) * 127 + 128 )
        local g =  math.floor( math.sin( globals.get_realtime() * 2 + 2 ) * 127 + 128 )
        local b = math.floor( math.sin( globals.get_realtime() * 2 + 4 ) * 127 + 128 )
        local screen_width = engine.get_screen_width()
        local username = globals.get_username()
        local ping = tostring(globals.get_ping())
		local get_time = os.date("%X", os.time())

        local text
        if engine.is_connected() then
            text = tostring(" Nortsync | " .. username .. " | delay: " .. ping .. "ms | "..get_time.. " ")
        else
            text = tostring(" Nortsync | " .. username .. " | " ..get_time.. " ")
        end
        --
        local width = render.get_text_width(font, text)
        --
        local background_color = color.new(39, 39, 46, 190)        
        local text_color = color.new(255, 255, 255)
        --
        local x = screen_width - 10 - width - 4
        local y = 10
        local w = width + 5

        --
        render.draw_rect_filled(x, y + 0, w, 22, background_color)
        render.draw_text(font, x + 2, y + 2, text_color, text)
        render.draw_rect_filled(x, y - 1, w, 2, color.new( r,g,b, 255 ) )
        

    end
end)

------FFI STUFF

local ffi = require("ffi")

------

ffi.cdef[[
    typedef unsigned char BYTE;
    typedef void *PVOID;
    typedef PVOID HMODULE;
    typedef const char *LPCSTR;
    typedef int *FARPROC;
    
    HMODULE GetModuleHandleA(
        LPCSTR lpModuleName
    );
    
    FARPROC GetProcAddress(
        HMODULE hModule,
        LPCSTR  lpProcName
    );
    
    typedef struct{
        BYTE r, g, b, a;
    } Color;
    
    typedef void(__cdecl *ColorMsgFn)(Color&, const char*);
]]

------HELPFUL FUNCTIONS

local ConsolePrint = function(label, r, g, b, a)
    local ConColorMsg = ffi.cast("ColorMsgFn", ffi.C.GetProcAddress(ffi.C.GetModuleHandleA("tier0.dll"), "?ConColorMsg@@YAXABVColor@@PBDZZ"))
    
    local color = ffi.new("Color")
    color.r = r
    color.g = g
    color.b = b
    color.a = a

    ConColorMsg( color, label )
end




console.execute("clear")


ConsolePrint("[ ", 255, 255, 255, 255)
ConsolePrint("Nort", 255, 0, 253, 255)
ConsolePrint("sync", 255, 255, 255, 255)
ConsolePrint(" ]", 255, 255, 255, 255)
ConsolePrint(" Welcome " .. tostring(globals.get_username()) .. "\n", 230, 230, 230, 255)

ConsolePrint("[ ", 255, 255, 255, 255)
ConsolePrint("Nort", 255, 0, 253, 255)
ConsolePrint("sync", 255, 255, 255, 255)
ConsolePrint(" ]", 255, 255, 255, 255)
ConsolePrint(" Nortsync is loading...\n", 230, 230, 230, 255)

ConsolePrint("[ ", 255, 255, 255, 255)
ConsolePrint("Nort", 255, 0, 253, 255)
ConsolePrint("sync", 255, 255, 255, 255)
ConsolePrint(" ]", 255, 255, 255, 255)
ConsolePrint(" Nortsync Loaded! \n", 230, 230, 230, 255)

ConsolePrint("[ ", 255, 255, 255, 255)
ConsolePrint("Nort", 255, 0, 253, 255)
ConsolePrint("sync", 255, 255, 255, 255)
ConsolePrint(" ]", 255, 255, 255, 255)
ConsolePrint(" Enjoy!\n", 230, 230, 230, 255)





local function logs_hit(shot_info)
    if menu.get_bool("Nortsync Logs") then
        local result = shot_info.result
        local gpinf = engine.get_player_info
        local target = shot_info.target_index
        local target_name = gpinf(target).name
        local boxx = shot_info.client_hitbox
        local boxx2 = shot_info.server_hitbox
        local dama = shot_info.client_damage
        local dama2 = shot_info.server_damage
        local hc_client = shot_info.hitchance
        local backtracks = shot_info.backtrack_ticks
        local safepoints = shot_info.safe
        if result == "Hit" then
ConsolePrint("[ ", 255, 255, 255, 255)
ConsolePrint("Nort", 255, 0, 253, 255)
ConsolePrint("sync", 255, 255, 255, 255)
ConsolePrint(" ]", 255, 255, 255, 255)
ConsolePrint(" Hit", 35, 255, 0, 255)
            print(" [Hit] " .. tostring(target_name) .. " | " .. tostring(boxx) .. " | HP: " .. tostring(dama) .. " | hitchance " .. tostring(hc_client)) 
        end
        if result ~= "Hit" then
            if result == "None" then
ConsolePrint("[ ", 255, 255, 255, 255)
ConsolePrint("Nort", 255, 0, 253, 255)
ConsolePrint("sync", 255, 255, 255, 255)
ConsolePrint(" ]", 255, 255, 255, 255)
ConsolePrint(" Missed", 255, 0, 0, 255)
                print(" [Missed] shot due to ".. "death" .. " in player " .. tostring(target_name) .. " | " .. tostring(boxx) .. " | hitchance " .. tostring(hc_client))
            else
ConsolePrint("[ ", 255, 255, 255, 255)
ConsolePrint("Nort", 255, 0, 253, 255)
ConsolePrint("sync", 255, 255, 255, 255)
ConsolePrint(" ]", 255, 255, 255, 255)
ConsolePrint(" Missed", 255, 0, 0, 255)
                print(" [Missed] shot due to ".. tostring(result) .. " in player " .. tostring(target_name) .. " | " .. tostring(boxx) .. " | hitchance " .. tostring(hc_client))
            end
            
        end
    end
end



local get_hc = menu.get_int("rage.weapon[4].hit_chance   ")
local pt = 0
local to_grass = 0
local vbb = 0

local vel = 0
local target = nil
local dr2 = 1
local lowdelta_angel= {
    38,
    -38,
    32,
    -32,
    25,
    -25,
    -20,
    20
}
local function getTarget(shot_info)
    target = shot_info.target_index
    target = shot_info.target_index
    local result = shot_info.result

    vel = math.floor(entitylist.entity_to_player( entitylist.get_player_by_index(target) ):get_velocity():length_2d())
    
    if vel < 100 then
        if vel > 0 then
            menu.set_bool("player_list.player_settings[" .. target .. "].force_body_yaw", true)
            menu.set_int("player_list.player_settings[" .. target .. "].body_yaw", lowdelta_angel[dr2])
        end
    end
    if vel > 100 then
        if  vel > 900 then
        	client.log("[Nortsync] Prediction error!")
        end
        menu.set_bool("player_list.player_settings[" .. target .. "].force_body_yaw", false)
    end
    if result == "Resolver" then
        dr2 = dr2 + 1
        if dr2 > #lowdelta_angel then
            dr2 = 1
        end
        menu.set_int("player_list.player_settings[" .. target .. "].body_yaw", lowdelta_angel[dr2])
        
    end
end



client.add_callback("on_shot", getTarget)
client.add_callback("on_shot", logs_hit)
client.add_callback("create_move", weapon_scope)
client.add_callback("create_move", aa)
client.add_callback("create_move", lowdelta)
client.add_callback("create_move", baim)

 

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