local Render    = fatality.render
local Config    = fatality.config
local Menu      = fatality.menu
local Thread    = fatality.callbacks
local Input     = fatality.input

-- [[ CSGO BASED *****]]

local Color     = csgo.color
local Vector2   = csgo.vector2
local Engine    = csgo.interface_handler:get_engine_client()
local Entity    = csgo.interface_handler:get_entity_list()
local G_Vars    = csgo.interface_handler:get_global_vars()
local Convars   = csgo.interface_handler:get_cvar()
local Events    = csgo.interface_handler:get_events()
local LocalPed  = Entity:get_localplayer()

local stayfatal_banner

local IndicatorTable = {

    Watermark = {
        name = "NetKing" -- If you want to replace the name put it in to brackets 
    },

    Locals = {
        FPS = 0.0,
        Indi_count = 0,
        Indi_add = 1,
    },

    ColorTable = {
        ["white-r"] = 255,
        ["white-g"] = 255,
        ["white-b"] = 255,
        ["white-a"] = 255,
        ["black-r"] = 1,
        ["black-g"] = 1,
        ["black-b"] = 1,
        ["black-a"] = 180,
        ["inactive-indi-r"] = 255,
        ["inactive-indi-g"] = 255,
        ["inactive-indi-b"] = 255,
        ["inactive-indi-a"] = 20,
        ["active-indi-r"] = 0,
        ["active-indi-g"] = 240,
        ["active-indi-b"] = 255,
        ["active-indi-a"] = 220,
        ["e-peek-r"] = 255,
        ["e-peek-g"] = 0,
        ["e-peek-b"] = 255,
        ["e-peek-a"] = 255,
        ["fatality-r"] = 235,
        ["fatality-g"] = 12,
        ["fatality-b"] = 85,
        ["fatality-a"] = 255,
    },

    ItemTable = {
        KeyBindHandler   = Config:add_item("Ketbinds", 0),
        SkeetindHandler  = Config:add_item("TeamSkeet inds", 0),
        IdealIndHandler  = Config:add_item("Ideal Yaw inds", 0),
        IndicatorHandler = Config:add_item("Indicators", 0),
        RainbowIndicator = Config:add_item("Rainbow Watermark", 0),
        SelectedIndex    = Config:add_item("SelectedIndex", 0),
        DT               = Config:add_item("Double Tap ", 0),
        HS               = Config:add_item("Hide Shots", 0),
        DPA              = Config:add_item("Fake Duck", 0),
        QP               = Config:add_item("Quick Peek", 0),
        HeadS            = Config:add_item("Head Shot Only", 0),
        FS               = Config:add_item("Force Safe point", 0),
        FreeS            = Config:add_item("Freestanding", 0),
        LegitAA          = Config:add_item("Legit AA", 0),
        SkiddedAA        = Config:add_item("SkiddedAA", 0),
        Trashtalker      = Config:add_item("Trashtalk", 0),
        Watermark        = Config:add_item("Watermark", 0),
        RainbowWatermark = Config:add_item("Rainbow Watermark", 0),


    },

    References = {
        Reference_LegitAA     = Menu:get_reference("Rage", "Anti-Aim", "General", "Anti-aim"),
        Reference_Pitch       = Menu:get_reference("Rage", "Anti-Aim", "General", "Pitch"),
        Reference_Yaw         = Menu:get_reference("Rage", "Anti-Aim", "General", "Yaw"),
        Reference_YawAdd      = Menu:get_reference("Rage", "Anti-Aim", "General", "Yaw add"),
        Reference_YawAdd2     = Menu:get_reference("Rage", "Anti-Aim", "General", "Add"),
        Reference_AtFOVtarget = Menu:get_reference("Rage", "Anti-Aim", "General", "At fov target"),
        Reference_FakeType    = Menu:get_reference("Rage", "Anti-Aim", "General", "Fake type"),
        Reference_FakeAmount  = Menu:get_reference("Rage", "Anti-Aim", "General", "Fake amount"),
        Reference_Legslide    = Menu:get_reference("Rage", "Anti-Aim", "General", "Leg slide"),
        Reference_FreestandAA = Menu:get_reference("Rage", "Anti-Aim", "General", "Freestand fake"),
        Reference_FakelagMod  = Menu:get_reference("Rage", "Anti-Aim", "Fakelag", "Mode"),
        Reference_FakelagLimi = Menu:get_reference("Rage", "Anti-Aim", "Fakelag", "Limit"),


        Reference_Doubletap   = Menu:get_reference("Rage", "Aimbot", "Aimbot", "Double tap"),
        Reference_Freestand   = Menu:get_reference("Rage", "Anti-Aim", "General", "Freestand"),
        Reference_Hideshots   = Menu:get_reference("Rage", "Aimbot", "Aimbot", "Hide shot"),
        Reference_Safepoint   = Menu:get_reference("Rage", "Aimbot", "Aimbot", "Force safepoint"),
        Reference_Headonly    = Menu:get_reference("Rage", "Aimbot", "Aimbot", "Headshot only"),
        Reference_Fakeduck    = Menu:get_reference("Misc", "", "Movement", "Fake duck"),
        Reference_QuickPeek   = Menu:get_reference("Misc", "", "Movement", "Peek Assist"),
        Reference_RemoveScope = Menu:get_reference("Visuals", "Misc", "Local", 'Remove scope'),
    },

    Trashtalks = {
        "Cryptonic?",
        "1",
        "ur cheat aa when?",
        "refund that cheat for food dog",
        "1000-7?",
        "Kekma.net the best private cheat!(no inv needed!)",
        "Get 1 by nixware",
        "Cheat?",
        "U use lw3 paste?",
        -- [[ If you want you can add more of your trashtalks ]]
    },

}

-- [[ AA]]

Menu:add_button("ANTI AIM", "LEGIT", "", "Aim assist", stayfatal_banner)
Menu:add_checkbox("Legit AA on E", "LEGIT", "", "Aim assist", IndicatorTable.ItemTable.LegitAA)
Menu:add_checkbox("Dynamic AA", "LEGIT", "", "Aim assist", IndicatorTable.ItemTable.SkiddedAA)

-- [[ INDS ]]

Menu:add_button("INDS", "LEGIT", "", "Aim assist", stayfatal_banner)

-- [[ CHECKBOXES ]]

Menu:add_checkbox("Pred Indicators", "LEGIT", "", "Aim assist", IndicatorTable.ItemTable.IndicatorHandler)
Menu:add_checkbox("Disable Ideal Yaw inds", "LEGIT", "", "Aim assist", IndicatorTable.ItemTable.IdealIndHandler)
Menu:add_checkbox("Disable TeamSkeet inds", "LEGIT", "", "Aim assist", IndicatorTable.ItemTable.SkeetindHandler)

-- [[ COMBO ]]

local IndicatorType = Menu:add_multi_combo("Display Indicators", "LEGIT", "", "Aim assist", IndicatorTable.ItemTable.SelectedIndex)
IndicatorType:add_item("DT", IndicatorTable.ItemTable.DT)
IndicatorType:add_item("HS", IndicatorTable.ItemTable.HS)
IndicatorType:add_item("FREESTAND", IndicatorTable.ItemTable.FreeS)
IndicatorType:add_item("FD", IndicatorTable.ItemTable.DPA)
IndicatorType:add_item("PEEK", IndicatorTable.ItemTable.QP)
IndicatorType:add_item("HS", IndicatorTable.ItemTable.HeadS)
IndicatorType:add_item("BAIM", IndicatorTable.ItemTable.FS)

-- [[ MISC ]]

Menu:add_button("MISC", "LEGIT", "", "Aim assist", stayfatal_banner)
Menu:add_checkbox("Trashtalker", "LEGIT", "", "Aim assist", IndicatorTable.ItemTable.Trashtalker)
Menu:add_checkbox("Watermark", "LEGIT", "", "Aim assist", IndicatorTable.ItemTable.Watermark)
Menu:add_checkbox("KeyBinds", "LEGIT", "", "Aim assist", IndicatorTable.ItemTable.KeyBindHandler)
Menu:add_checkbox("Rainbow Watermark Gradient", "LEGIT", "", "Aim assist", IndicatorTable.ItemTable.RainbowWatermark)


-- [[ LOCALS ]]

local ScreenSize        = Render:screen_size()
local xIndi             = ScreenSize.x / 2 - 7
local Font              = Render:create_font("Verdana", 14, 500, true)
local font              = Render:create_font("Small Fonts", 9, 150, true, false, true)
local fontWK            = Render:create_font("Verdana", 12, 400, true, true, false)
local fontp             = Render:create_font("Verdana", 13, 900, true, false, false)
local font2             = Render:create_font("Verdana", 20, 400, true, false, false)
local font3             = Render:create_font("Verdana", 12, 200, true, false, false)
local fontp1            = Render:create_font("Small Fonts", 10, 150, true, false, true)
local fontideal         = Render:create_font("Verdana", 12, 500, true, true, false)
local Teamind           = Render:create_font("Verdana", 38, 900, true, false, false)
local indFont           = Render:create_font("Verdana", 27, 900, true, false, false)
local color_active      = Color(IndicatorTable.ColorTable["active-indi-r"], IndicatorTable.ColorTable["active-indi-g"], IndicatorTable.ColorTable["active-indi-b"], IndicatorTable.ColorTable["active-indi-a"])
local color_inactive    = Color(IndicatorTable.ColorTable["inactive-indi-r"], IndicatorTable.ColorTable["inactive-indi-g"], IndicatorTable.ColorTable["inactive-indi-b"], IndicatorTable.ColorTable["inactive-indi-a"])
local color_pink        = Color(IndicatorTable.ColorTable["e-peek-r"], IndicatorTable.ColorTable["e-peek-g"], IndicatorTable.ColorTable["e-peek-b"], IndicatorTable.ColorTable["e-peek-a"])
local color_fatality    = Color(IndicatorTable.ColorTable["fatality-r"], IndicatorTable.ColorTable["fatality-g"], IndicatorTable.ColorTable["fatality-b"], IndicatorTable.ColorTable["fatality-a"])
local color_white       = Color(IndicatorTable.ColorTable["white-r"], IndicatorTable.ColorTable["white-g"], IndicatorTable.ColorTable["white-b"], IndicatorTable.ColorTable["white-a"])
local color_black       = Color(IndicatorTable.ColorTable["black-r"], IndicatorTable.ColorTable["black-g"], IndicatorTable.ColorTable["black-b"], IndicatorTable.ColorTable["black-a"])

--[[ FRAME COUNTER ]]

local function GetGameFrames() -- Get Frames from your game client (FPS)
    IndicatorTable.Locals.FPS = 0.9 * IndicatorTable.Locals.FPS + (1.0 - 0.9) * G_Vars.frametime
    return math.floor((1.0 / IndicatorTable.Locals.FPS) + 0.5)
end   

--[[ RAINBOW FREQUENCY ]]

local function rainbowRGB(frequency)
    local result = {}
    local curtime = G_Vars.curtime
    result.r = math.floor(math.sin(curtime * frequency + 0) * 127 + 128)
    result.g = math.floor(math.sin(curtime * frequency + 2) * 127 + 128)
    result.b = math.floor(math.sin(curtime * frequency + 4) * 127 + 128)
    return result
end

--[[ KILL SAY ]]

local function TrashtalkHandler(talk)
    if IndicatorTable.ItemTable.Trashtalker:get_bool() then
        local Enemy_ID = talk:get_int("userid")
        local Attacker_ID = talk:get_int("attacker")
        if Enemy_ID == nil or Attacker_ID == nil then
            return
        end

        local talks = (IndicatorTable.Trashtalks[math.random(#IndicatorTable.Trashtalks)])
        local Local_Ped = Entity:get_localplayer()
        local Enemy_Entity = Entity:get_player_from_id(Enemy_ID)
        local Attacker_Entity = Entity:get_player_from_id(Attacker_ID)
        if Local_Ped == nil or Enemy_Entity == nil or Attacker_Entity == nil then
            return
        end
        if Attacker_Entity:get_index() == Local_Ped:get_index() then
            Engine:client_cmd("say " .. talks)
        end
    end
end

--[[ WATERMARK ]]

local function WatermarkHandler(rainbow)
    if IndicatorTable.ItemTable.Watermark:get_bool() then
        local latency = Engine:get_ping()
        local frames = GetGameFrames()
        local string = "gamesense | "..IndicatorTable.Watermark.name.." | fps: "..frames.." | ping: "..latency.." ms | ".. os.date("%H:%M:%S")
        local TextSize = Render:text_size(Font, string)
        local Spacing = Vector2(10, 10)
        local Size = Vector2(TextSize.x + (2.5 * 2), TextSize.y + (2.5 * 2))
        local Position = Vector2(ScreenSize.x - Size.x - Spacing.x, Spacing.y)
        local RGB = rainbowRGB(2.0)
        local RGB2 = rainbowRGB(2.3)
        local color_rainbow = Color(RGB.r, RGB.g, RGB.b, 255)
        local color_rainbow2 = Color(RGB2.r, RGB2.g, RGB2.b, 255)

        if rainbow then
            Render:rect_fade(Position.x, Position.y, Size.x, Size.y - 18, color_rainbow, color_rainbow2, true)
        else
            Render:rect_fade(Position.x, Position.y, Size.x, Size.y - 18, color_white, color_active, true)
        end
        Render:rect_filled(Position.x, Position.y, Size.x, Size.y, color_black)
        Render:text(fontWK, Position.x + 60, Position.y + 5, string, color_white)
    end
end

-- [[ INDICATOR ]]

local function IndicatorRendering(xIndi, index, name, flip, condition, render, rainbow)
    if condition then
        if condition:get_bool() then
            return
        end
    end
    local rgb = rainbowRGB(1.0)
    local index_rainbow = Color(rgb.r, rgb.g, rgb.b, 255)
    local on_off = index:get_bool()
    if not render and not on_off then
        return
    end
    if flip and on_off then
        on_off = not on_off
    end
    local index_color = on_off and color_active or not on_off and color_inactive
    local index_color_rgb = on_off and index_rainbow or not on_off and color_inactive
    
    local y = ScreenSize.y / 2 + (14 * IndicatorTable.Locals.Indi_count + 5 * 14) + 5

    if rainbow then
        Render:text(Font, xIndi, y, name, index_color_rgb)
    else
        Render:text(Font, xIndi, y, name, index_color)
    end

    IndicatorTable.Locals.Indi_count = IndicatorTable.Locals.Indi_count + IndicatorTable.Locals.Indi_add
end

--[[ INDICATOR RENDERING ]]
local function IndicatorDrawing()
    IndicatorTable.Locals.Indi_count = 0 
if IndicatorTable.ItemTable.SkeetindHandler :get_bool() then
    Render:text(Teamind  , ScreenSize.x / 2 - 105, ScreenSize.y / 2 -21, "<", csgo.color(56, 56, 56, 150))
    Render:text(Teamind , ScreenSize.x / 2 + 83, ScreenSize.y / 2 -21, ">", csgo.color(56, 56, 56, 150))
    Render:text(indFont  , ScreenSize.x / 2 - 83, ScreenSize.y / 2 -15, "l", csgo.color(255, 255, 255, 255))
    Render:text(indFont , ScreenSize.x / 2 + 76, ScreenSize.y / 2 -15, "l", csgo.color(255, 255, 255, 255))
end
end


local function IndicatorDrawing()
    IndicatorTable.Locals.Indi_count = 0 
    if IndicatorTable.ItemTable.IndicatorHandler:get_bool() then
        Render:text(font2, ScreenSize.x / 2-100, ScreenSize.y / 2 -11, "<", csgo.color(255, 255, 255, 255))
        Render:text(font2, ScreenSize.x / 2+90, ScreenSize.y / 2 -11, ">", csgo.color(255, 255, 255, 255))
        Render:text(fontp, ScreenSize.x / 2-35, ScreenSize.y / 2 +19, "predi", csgo.color(255, 255, 255, 255))
        Render:text(fontp, ScreenSize.x / 2-1, ScreenSize.y / 2 +19, "ction", csgo.color(255, 255, 255, 255))
        Render:text(font3, ScreenSize.x / 2+30, ScreenSize.y / 2 +15, "o", csgo.color(255, 255, 255, 255))
        if IndicatorTable.ItemTable.LegitAA:get_bool() and Input:is_key_down(0x45) then 
            Render:text(fontp1, xIndi - 10, ScreenSize.y / 2 + (14 * IndicatorTable.Locals.Indi_count + 4 * 14) + 5, "E-Peek", color_pink)
        end  
        if IndicatorTable.ItemTable.DT:get_bool() then 
            IndicatorRendering(xIndi, IndicatorTable.References.Reference_Doubletap, "DT", IndicatorTable.References.Reference_Fakeduck:get_bool(), false, true, IndicatorTable.ItemTable.RainbowIndicator:get_bool())
        end 
        if IndicatorTable.ItemTable.HS:get_bool() then 
            IndicatorRendering(xIndi - 16, IndicatorTable.References.Reference_Hideshots, "Hideshots", IndicatorTable.References.Reference_Fakeduck:get_bool() or IndicatorTable.References.Reference_Doubletap:get_bool(), false, true, IndicatorTable.ItemTable.RainbowIndicator:get_bool())
        end 
        if IndicatorTable.ItemTable.FreeS:get_bool() then 
            IndicatorRendering(xIndi - 17, IndicatorTable.References.Reference_Freestand, "Freestand", false, false, true, IndicatorTable.ItemTable.RainbowIndicator:get_bool())
        end
        if IndicatorTable.ItemTable.DPA:get_bool() then 
            IndicatorRendering(xIndi - 17, IndicatorTable.References.Reference_Fakeduck, "Fake Duck", false, false, true, IndicatorTable.ItemTable.RainbowIndicator:get_bool())
        end 
        if IndicatorTable.ItemTable.HeadS:get_bool() then 
            IndicatorRendering(xIndi - 17, IndicatorTable.References.Reference_Headonly, "Head Only", false, false, true, IndicatorTable.ItemTable.RainbowIndicator:get_bool())
        end 
        if IndicatorTable.ItemTable.QP:get_bool() then 
            IndicatorRendering(xIndi - 20, IndicatorTable.References.Reference_QuickPeek, "Quick Peek", false, false, true, IndicatorTable.ItemTable.RainbowIndicator:get_bool())
        end 
        if IndicatorTable.ItemTable.FS:get_bool() then 
            IndicatorRendering(xIndi - 19, IndicatorTable.References.Reference_Safepoint, "Safe Point", false, false, true, IndicatorTable.ItemTable.RainbowIndicator:get_bool())
        end
    end
end

-- [[ LEGIT AA ON E ]]

local function Legit_AA()
    if IndicatorTable.ItemTable.LegitAA:get_bool() and Input:is_key_down(0x45) then
        if IndicatorTable.References.Reference_Pitch:get_int() ~= 0 then
            IndicatorTable.References.Reference_Pitch:set_int(0) -- None
        end
        if IndicatorTable.References.Reference_Yaw:get_int() ~= 2 then
            IndicatorTable.References.Reference_Yaw:set_int(2) -- Zero
        end
        IndicatorTable.References.Reference_YawAdd:set_bool(false)
        IndicatorTable.References.Reference_AtFOVtarget:set_bool(false)
        IndicatorTable.References.Reference_FakeAmount:set_int(100)
        if IndicatorTable.References.Reference_Legslide:get_int() ~= 0 then
            IndicatorTable.References.Reference_Legslide:set_int(0) -- Default
        end
    else
        -- else is gonna set this values while you dont hold E - my premade anti aim
        if IndicatorTable.References.Reference_Pitch:get_int() ~= 1 then
            IndicatorTable.References.Reference_Pitch:set_int(1) -- Down
        end
        if IndicatorTable.References.Reference_Yaw:get_int() ~= 1 then
            IndicatorTable.References.Reference_Yaw:set_int(1) -- Backwards
        end
        if IndicatorTable.References.Reference_FakeType:get_int() ~= 2 then
            IndicatorTable.References.Reference_FakeType:set_int(2) -- Real around fake
        end
        if IndicatorTable.References.Reference_FreestandAA:get_int() ~= 2 then
            IndicatorTable.References.Reference_FreestandAA:set_int(2) -- Opposite
        end
        if IndicatorTable.References.Reference_FakelagMod:get_int() ~= 2 then
            IndicatorTable.References.Reference_FakelagMod:set_int(2) -- Adaptive
        end
        IndicatorTable.References.Reference_FakelagLimi:set_int(14)

        IndicatorTable.References.Reference_YawAdd:set_bool(true)
        IndicatorTable.References.Reference_FakeAmount:set_int(100)
        IndicatorTable.References.Reference_AtFOVtarget:set_bool(true)
        if IndicatorTable.References.Reference_Legslide:get_int() ~= 2 then
            IndicatorTable.References.Reference_Legslide:set_int(2) -- Always slide
        end
    end
end

-- [[ ANTI AIM ]]

local function SkiddedAA()
    if IndicatorTable.ItemTable.SkiddedAA:get_bool() then
        IndicatorTable.References.Reference_YawAdd:set_bool(true)
        IndicatorTable.References.Reference_YawAdd2:set_float(math.random(-13, 13)) -- Changing YAW value
    else
        IndicatorTable.References.Reference_YawAdd2:set_float(math.random(3, 4)) -- Return this YAW Value while its OFF
    end
end

-- [[ FUNCTION TO DRAW ALL AT THE SAME TIME ]]

local function Paint()
    if LocalPed:is_alive() and Engine:is_connected() then -- Simple check If I am alive and connected
        IndicatorDrawing()
        Legit_AA()
        SkiddedAA()
    end
    WatermarkHandler(IndicatorTable.ItemTable.RainbowWatermark:get_bool()) -- Without the check
end

-- [[ KILL SAY EVENT ]]

local function OnGameEvent(talk)
    local EventName = talk:get_name()
    if EventName == "player_death" then -- Event to check if the play is death then it will use the function TrashtalkHandler
        TrashtalkHandler(talk)
    end
end

Events:add_event("player_death") -- You need to add this event to make it work
Thread:add("events", OnGameEvent) -- Callback for function
Thread:add("paint", Paint) -- Callback for function

local callbacks = fatality.callbacks
callbacks:add("paint", on_paint)

local entity_list = csgo.interface_handler:get_entity_list()
local render = fatality.render
local menu = fatality.menu
local config = fatality.config
local input = fatality.input
local cvar = csgo.interface_handler:get_cvar()
local global_vars = csgo.interface_handler:get_global_vars()
local events = csgo.interface_handler:get_events()

local freestand = menu:get_reference( "RAGE", "ANTI-AIM", "General", "Freestand")
local headshot_only = menu:get_reference("RAGE", "AIMBOT", "Aimbot", "Headshot only")
local hide = menu:get_reference("RAGE", "AIMBOT", "Aimbot", "Hide shot")
local dt = menu:get_reference("RAGE", "AIMBOT", "Aimbot", "Double tap")
local ax = menu:get_reference("RAGE", "AIMBOT", "Aimbot", "Anti-exploit")
local slide = menu:get_reference( "misc", "", "movement", "slide" );
local fd = menu:get_reference( "misc", "", "movement", "fake duck");
local baim = menu:get_reference( "RAGE", "AIMBOT", "Aimbot", "Force safepoint" )


local master_item = config:add_item("lua_indicators_master", 0)
local master_checkbox = menu:add_checkbox("Indicators", "VISUALS", "MISC", "Various", master_item)
local scale_item = config:add_item("lua_indicators_scale", 100)
local scale_slider = menu:add_slider( "Indicator scale", "VISUALS", "MISC", "Various", scale_item, 70, 150, 1 )
local indicator_list = {}
local font = render:create_font("Verdana", 12, 500, true, true, false)
local last_scale = 0

local function draw_text(font, x, y, text, color)
	
	render:text(font, x, y, text, color)

end

function draw_indicator_with_color(text, color)
	table.insert(indicator_list, {text = string.upper(text), color = color, width = render:text_size(font, string.upper(text)).x})
end

function draw_indicator_with_bool(text, enabled)
	local color = csgo.color(124, 195, 13, 255)
    local color = csgo.color(0, 0, 0, 0)

	
	if (enabled) then
		draw_indicator_with_color(text, color)
	end
end

function render_indicator( text, enabled )
    if(_G['draw_indicator_with_bool'] ~= nil) then
        draw_indicator_with_bool(text, enabled)
    end
end

function render_indicator_color( text, color )
    if(_G['draw_indicator_with_color'] ~= nil) then
        draw_indicator_with_color(text, color)
    end
end

local function weapon_indicator()
	local local_player = entity_list:get_localplayer() 
	local weapon = entity_list:get_from_handle(local_player:get_var_handle("CBaseCombatCharacter->m_hActiveWeapon"))

	if(weapon == nil) then
		return
	end

	local weapon_id = weapon:get_class_id()

	if(weapon_id == 244) or (weapon_id == 238) or (weapon_id == 257) or (weapon_id == 268)  or (weapon_id == 245) or (weapon_id == 257) or (weapon_id == 240) then
		draw_indicator_with_bool("           silent", pistols_silent:get_bool())
        draw_indicator_with_bool("       dt", pistols_doubletap:get_bool())
    elseif (weapon_id == 46) then
    	draw_indicator_with_bool("           silent", heavy_silent:get_bool())
        draw_indicator_with_bool("       dt", heavy_doubletap:get_bool())
    elseif (weapon_id == 266)then 
    	draw_indicator_with_bool("          silent", scout_silent:get_bool())
    elseif (weapon_id == 260) or (weapon_id == 241) then
    	draw_indicator_with_bool("           silent", autosniper_silent:get_bool())
        draw_indicator_with_bool("       dt", autosniper_doubletap:get_bool())
    elseif (weapon_id == 232) then
    	draw_indicator_with_bool("           silent", awp_silent:get_bool())
    elseif not(weapon_id == 107) then
    	draw_indicator_with_bool("           silent", other_silent:get_bool())
        draw_indicator_with_bool("       dt", other_doubletap:get_bool())

    end
end

local function on_paint() 
	local local_player = entity_list:get_localplayer() 
	local screen_size = render:screen_size( )
	local next_item_offset = 0

	if IndicatorTable.ItemTable.IdealIndHandler :get_bool() then
		return
	end

    Render:text(fontideal , ScreenSize.x / 2+2, ScreenSize.y / 2 +25, "IDEAL YAW", csgo.color(220, 135, 49, 255))
    Render:text(fontideal , ScreenSize.x / 2+2, ScreenSize.y / 2 +34, "DYNAMIC", csgo.color(209, 159, 230, 255))

	weapon_indicator()
    
        draw_indicator_with_bool("SLIDE", slide:get_bool())
        if fd:get_bool() then
        Render:text(fontideal , ScreenSize.x / 2+2, ScreenSize.y / 2 +43, "FD", csgo.color(169, 140, 245, 255))
      end
        if headshot_only:get_bool() then
        Render:text(fontideal , ScreenSize.x / 2+2, ScreenSize.y / 2 +61, "HEAD", csgo.color(169, 140, 245, 255))
      end
      if hide:get_bool() then
        Render:text(fontideal , ScreenSize.x / 2+2, ScreenSize.y / 2 +52, "AA", csgo.color(169, 140, 245, 255))
      end
		if dt:get_bool() then
        Render:text(fontideal , ScreenSize.x / 2+2, ScreenSize.y / 2 +43, "DT", csgo.color(25, 255, 25, 255))
      end
	  	if freestand:get_bool() then
        Render:text(fontideal , ScreenSize.x / 2+2, ScreenSize.y / 2 +34, "", csgo.color(255, 255, 255, 255))
      end
      if freestand:get_bool() then
        Render:text(fontideal , ScreenSize.x / 2+2, ScreenSize.y / 2 +34, "", csgo.color(255, 255, 255, 255))
      end
	  	if ax:get_bool() then
        Render:text(fontideal , ScreenSize.x / 2+2, ScreenSize.y / 2 +88, "", csgo.color(169, 140, 245, 255))
      end
      if baim:get_bool() then
        Render:text(fontideal , ScreenSize.x / 2+2, ScreenSize.y / 2 +88, "BAIM", csgo.color(169, 140, 245, 255))
      end

	table.sort( indicator_list,  function (k1, k2) return k1.width < k2.width end)

	for i = 1, #indicator_list
	do
		if not(indicator_list[i] == nil) then
			local text_size = render:text_size(font, indicator_list[i].text)
			draw_text(font, screen_size.x / 2 - text_size.x / 2, screen_size.y / 2 + 10 + next_item_offset, indicator_list[i].text, indicator_list[i].color)
			next_item_offset = next_item_offset + text_size.y

			table.remove(indicator_list, i)
		end
	end
end

local callbacks = fatality.callbacks
callbacks:add("paint", on_paint)

Events:add_event("player_death") -- You need to add this event to make it work
Thread:add("events", OnGameEvent) -- Callback for function
Thread:add("paint", Paint) -- Callback for function 

-- Your name
local localName = "NetKing";
--

local menu = fatality.menu
local config = fatality.config
local render = fatality.render
local callbacks = fatality.callbacks;
local screenSize = render:screen_size();

local slist_x = config:add_item("slist_x", 0);
local guiMarginSlider = menu:add_slider("Spectator List (x)", "visuals", "misc", "various", slist_x, 0, screenSize.x, 1);
local slist_y = config:add_item("slist_y", 55);
local guiMarginSlider = menu:add_slider("Spectator List (y)", "visuals", "misc", "various", slist_y, 0, screenSize.y, 1);
--
local klist_x = config:add_item("klist_x", 0);
local guiMarginSlider = menu:add_slider("Kybinds List (x)", "visuals", "misc", "various", klist_x, 0, screenSize.x, 1);
local klist_y = config:add_item("klist_y", 85);
local guiMarginSlider = menu:add_slider("Kybinds List (y)", "visuals", "misc", "various", klist_y, 0, screenSize.y, 1);

local ConVar = csgo.interface_handler:get_cvar();

local backColor = csgo.color(38, 38, 38, 255); 
local fadeColor = csgo.color(74, 104, 255, 255);
local fadeColor2 = csgo.color(102, 127, 255, 0);
local textColor = csgo.color(235, 235, 235, 255);

local fonts = render:create_font("Verdana", 13, 450, true);

local function get_speclist()
	local spectatorsList = { };
	local longestName = 0;
	
	local entityList = csgo.interface_handler:get_entity_list();
    local localPlayer = entityList:get_localplayer();

    for i = 1, entityList:get_max_players(), 1 do
        local entity = entityList:get_player(i)
		
        if not entity or entity:is_alive() or entity:is_dormant() then
            goto continue;
		end
		
        specHandle = entity:get_var_handle("CBasePlayer->m_hObserverTarget");		
        spectatingPlayer = entityList:get_from_handle(specHandle);
        if not spectatingPlayer then
            goto continue;
		end
		
        if spectatingPlayer:get_index() == localPlayer:get_index() then		
			local textSize = render:text_size(fonts, entity:get_name()).x;
			if longestName == 0 then
				longestName = textSize;
			elseif longestName < textSize then
				longestName = textSize;
			end
				
			table.insert(spectatorsList, entity:get_name());
        end

        ::continue::
    end

	return { longestName, spectatorsList };
end  

local function draw_speclist()
	local spectatorsList = get_speclist();
	
	if not spectatorsList[2][1] then
		return;
	end
	
	local start_x = slist_x:get_int();
	local footerTextSize = render:text_size(fonts, "spectators").x;
	local paddings = 5;
	local size_x = 0;
	
	if footerTextSize * 2.6 + paddings * 2 < spectatorsList[1] + paddings * 2 then
		size_x = spectatorsList[1] + paddings * 2;
	else
		size_x = footerTextSize * 2.6 + paddings * 2;
	end
	local start_y = slist_y:get_int();
	
	render:rect_filled(start_x, start_y, size_x, 23, backColor);
	render:rect_filled(start_x, start_y, size_x, 2, fadeColor);
	render:text(fonts, math.ceil((start_x + size_x / 2) - footerTextSize / 2), start_y + 3, "spectators", textColor);
	start_y = start_y + 18;
	
	render:rect_fade(start_x + paddings, start_y, math.ceil(size_x / 2), 2, fadeColor2, fadeColor, true);
	render:rect_fade(start_x + math.ceil(size_x / 2), start_y, math.ceil(size_x / 2) - paddings, 2, fadeColor, fadeColor2, true);
	start_y = start_y + 5;
	
	for i = 1, #spectatorsList[2] do
		local playerName = spectatorsList[2][i];
		
		render:rect_filled(start_x, start_y, size_x, 15, backColor);
		render:text(fonts, start_x + paddings, start_y, playerName, textColor);
		start_y = start_y + 15;
	end	
	render:rect_filled(start_x, start_y, size_x, 3, backColor);
end

local function get_keylist()
	local keybindsList = { };
	local entityList = csgo.interface_handler:get_entity_list();
	local localPlayer = entityList:get_localplayer();
	local localWeaponId = 0;
	
	if localPlayer and localPlayer:is_alive() then
		local weaponHandle = localPlayer:get_var_handle("CBaseCombatCharacter->m_hActiveWeapon");
		if weaponHandle then
			local eW = entityList:get_from_handle(weaponHandle);
			if eW then
				localWeaponId = eW:get_class_id();
			end
		end
	end
	
	if menu:get_reference("Rage", "Aimbot", "Aimbot", "Force Safepoint"):get_bool() then
		table.insert(keybindsList, "force safepoint");
	end
	
	if menu:get_reference("Rage", "Aimbot", "Aimbot", "Headshot only"):get_bool() then
		table.insert(keybindsList, "headshot only");
	end
	
	if menu:get_reference("Rage", "Anti-aim", "General", "Antiaim override"):get_bool() then
		
		if menu:get_reference("Rage", "Anti-aim", "General", "Back"):get_bool() then
			table.insert(keybindsList, "manual side: normal");
		elseif menu:get_reference("Rage", "Anti-aim", "General", "Left"):get_bool() then
			table.insert(keybindsList, "manual side: left");
		elseif menu:get_reference("Rage", "Anti-aim", "General", "Right"):get_bool() then
			table.insert(keybindsList, "manual side: right");
		end
	end
	
	local currDmg = 0;
	local hideshot = false;
	local doubletap = false;
	
	if localWeaponId == 242 or localWeaponId == 261 then
        activedamage = config:get_weapon_setting("autosniper", "mindmg"):get_int();
		hideshot = config:get_weapon_setting("autosniper", "silent"):get_bool();
		doubletap = config:get_weapon_setting("autosniper", "double_tap"):get_bool();
    elseif localWeaponId == 267 then
		activedamage = config:get_weapon_setting("scout", "mindmg"):get_int();
		hideshot = config:get_weapon_setting("scout", "silent"):get_bool();
		doubletap = config:get_weapon_setting("scout", "double_tap"):get_bool();
    elseif localWeaponId == 233 then
		activedamage = config:get_weapon_setting("awp", "mindmg"):get_int();
		hideshot = config:get_weapon_setting("awp", "silent"):get_bool();
		doubletap = config:get_weapon_setting("awp", "double_tap"):get_bool();
    elseif localWeaponId == 46 then
		activedamage = config:get_weapon_setting("heavy_pistol", "mindmg"):get_int();
		hideshot = config:get_weapon_setting("heavy_pistol", "silent"):get_bool();
		doubletap = config:get_weapon_setting("heavy_pistol", "double_tap"):get_bool();
	elseif localWeaponId == 246 or localWeaponId == 245 or localWeaponId == 239 or localWeaponId == 269 or localWeaponId == 241 or localWeaponId == 258 then
		activedamage = config:get_weapon_setting("pistol", "mindmg"):get_int();
		hideshot = config:get_weapon_setting("pistol", "silent"):get_bool();
		doubletap = config:get_weapon_setting("pistol", "double_tap"):get_bool();
	else
		activedamage = config:get_weapon_setting("other", "mindmg"):get_int();
		hideshot = config:get_weapon_setting("other", "silent"):get_bool();
		doubletap = config:get_weapon_setting("other", "double_tap"):get_bool();
	end
	
	if doubletap then
		table.insert(keybindsList, "double tap");
	elseif hideshot then
		table.insert(keybindsList, "hideshot");
	end
	
	return keybindsList;
end

local function draw_keybinds()
    if IndicatorTable.ItemTable.KeyBindHandler:get_bool() then
	local keybindsList = get_keylist();
	
	local footerTextSize = render:text_size(fonts, "keybinds").x;
	local paddings = 5;
	local size_x = footerTextSize * 3 + paddings * 2;
	local start_x = klist_x:get_int();
	local start_y = klist_y:get_int();
	
	render:rect_filled(start_x, start_y, size_x, 23, backColor);
	render:rect_filled(start_x, start_y, size_x, 2, fadeColor);
	render:text(fonts, math.ceil((start_x + size_x / 2) - footerTextSize / 2), start_y + 3, "keybinds", textColor);
	start_y = start_y + 18;
	
	for i = 1, #keybindsList do
		local bindName = keybindsList[i];
		
		render:rect_filled(start_x, start_y, size_x, 15, backColor);
		render:text(fonts, start_x + paddings, start_y, bindName, textColor);
		start_y = start_y + 15;
	end
	
	render:rect_filled(start_x, start_y, size_x, 3, backColor);
end
end

local function on_paint()
	if not csgo.interface_handler:get_engine_client():is_in_game() then
		return;
	end
	
	draw_speclist();
	draw_keybinds();
end

callbacks:add("paint", on_paint);
 

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