-------------------misc-----------------------------------
---------------clantag_changer----------------------------
local label1 = ui.new_label("Misc", "Miscellaneous", '[------[MEGASHIT]------]')
local label1 = ui.new_label("Misc", "Miscellaneous", '        >>|MISC|<<')
local client_set_clan_tag, client_set_event_callback, client_system_time, entity_get_local_player, entity_get_player_resource, entity_get_prop, entity_is_alive, globals_curtime, math_floor, string_format, string_rep, table_insert, table_sort, ui_get, ui_new_checkbox, ui_new_combobox, ui_new_slider, ui_new_textbox, ui_set_callback, ui_set_visible, pairs = client.set_clan_tag, client.set_event_callback, client.system_time, entity.get_local_player, entity.get_player_resource, entity.get_prop, entity.is_alive, globals.curtime, math.floor, string.format, string.rep, table.insert, table.sort, ui.get, ui.new_checkbox, ui.new_combobox, ui.new_slider, ui.new_textbox, ui.set_callback, ui.set_visible, pairs

local function collect_keys(tbl, custom)
    local keys = {}
    for k in pairs(tbl) do
        keys[#keys + 1] = k
    end
    table_sort(keys)
    if custom then
        table_insert(keys, 1, "Disabled")
        table_insert(keys, "Custom")
    end
    return keys
end

local tags = {
    ["JoKer"] = "JoKer",
    ["Skeet"] = "skeet.cc",
	["Aimware"] = "AIMWARE.net",
    ["OmniAim"] = "OmniAim.net",
	["NOVOLINEHOOK"] = "NOVOLINEHOOK",
    ["MegaShit"] = "MegaShit",
}

local tag = ""
local tag_index = 0
local tag_length = 0
local tag_reverse = 0
local tag_last_index = 0

local commands = 0

local function static()
    if tag == "Disabled" then
        return
    end
    local local_player  = entity_get_local_player()
    local current_tag   = entity_get_prop(entity_get_player_resource(), "m_szClan", local_player)
    if tag:len() == 0 and current_tag:len() ~= 0 then
        client_set_clan_tag("\0")
    elseif current_tag ~= tag then
        client_set_clan_tag(tag)
    end
end

local function time()
    local h, m, s   = client_system_time()
    local time_tag  = string_format("%d:%02d:%02d", h, m, s)
    client_set_clan_tag(time_tag)
end

local function default()
    if tag_index == tag_last_index then
        return
    end
    client_set_clan_tag(tag_index == 0 and "\0" or tag:sub(1, tag_index))
end

local function reverse()
    if tag_index == tag_last_index then
        return
    end
    if tag_reverse <= tag_length then
        client_set_clan_tag(tag:sub(1, tag_index))
    else
        client_set_clan_tag(tag_length - tag_index == 0 and "\0" or tag:sub(1, tag_length - tag_index))
    end
end

local function loop()
    if tag_index == tag_last_index then
        return
    end
    local result = ""
    local loop_tag = tag
    for i=1, tag_index do
        loop_tag = loop_tag .. loop_tag:sub(1, 1)
        loop_tag = loop_tag:sub(2, loop_tag:len())
    end
    client_set_clan_tag(loop_tag)
end

local animations = {
    ["Static"]  = static,
    ["Time"]    = time,
    ["Default"] = default,
    ["Reverse"] = reverse,
    ["Classic"] = loop,
    ["Loop"]    = loop,
}

local menu = {
    enabled = ui_new_checkbox("misc", "Miscellaneous", "Clan tag changer"),
    tags    = ui_new_combobox("misc", "Miscellaneous", "Tags", collect_keys(tags, true)),
    text    = ui_new_textbox("misc", "Miscellaneous", "Text"),
    styles  = ui_new_combobox("misc", "Miscellaneous", "Animation", collect_keys(animations, false)),
    speed   = ui_new_slider("misc", "Miscellaneous", "Speed", 0, 100, 30, true, "%")
}

local function handle_menu()
    local state = ui_get(menu.enabled)
    local menu_tag = ui_get(menu.tags)
    ui_set_visible(menu.tags, state)
    ui_set_visible(menu.styles, state)
    ui_set_visible(menu.speed, state)
    ui_set_visible(menu.text, state and menu_tag == "Custom")
    if not state then
        client_set_clan_tag("\0")
    end
end

handle_menu()
ui_set_callback(menu.enabled, handle_menu)
ui_set_callback(menu.tags, handle_menu)

local function net_update_end()
    if not ui_get(menu.enabled) then
        return
    end
    local local_player  = entity_get_local_player()
    local menu_tag      = ui_get(menu.tags)
    local tag_style     = ui_get(menu.styles)
    local update_tag    = commands == 0 or entity_is_alive(local_player) == false
    if menu_tag == "Disabled" then
        return
    end
    tag         = menu_tag == "Custom" and ui_get(menu.text) or tags[menu_tag]
    tag         = tag_style == "Loop" and tag .. " " or tag
    tag         = tag_style == "Classic" and tag .. string_rep(" ", math_floor(tag:len() * 2)) or tag
    tag_length  = tag:len()
    tag_index   = math_floor((globals_curtime() * ui_get(menu.speed) / 10) % tag_length + 1)
    tag_reverse = math_floor((globals_curtime() * ui_get(menu.speed) / 10) % (tag_length * 2) + 1) 
    if not update_tag then
        return
    end
    local animation = animations[tag_style]
    animation()
    tag_last_index = tag_index
end

local function run_command(cmd)
    if not ui_get(menu.enabled) then
        return
    end
    commands = cmd.chokedcommands
end

local function shutdown()
    client_set_clan_tag("\0")
end

client_set_event_callback("net_update_end", net_update_end)
client_set_event_callback("run_command", run_command)
client_set_event_callback("shutdown", shutdown)
---------------------------------------------------
---------------------------------------------------
-----------------Auto_report-----------------------
local client_log, client_set_event_callback, entity_get_player_name, entity_get_players, entity_get_steam64, json_parse, panorama_open, plist_get, string_format, ui_get, ui_new_button, ui_new_checkbox, ui_reference, print = client.log, client.set_event_callback, entity.get_player_name, entity.get_players, entity.get_steam64, json.parse, panorama.open, plist.get, string.format, ui.get, ui.new_button, ui.new_checkbox, ui.reference, print
local http = require "gamesense/http"
local js = panorama_open()
local GameStateAPI = js.GameStateAPI
local steamid3 = {}
local report = ui_new_checkbox("Misc", "Miscellaneous", "Auto report cheaters")

client_set_event_callback("paint", function()
    if not ui_get(report) then
        return
    end

    local plists = entity_get_players(true)
    for i = 1, #plists do
        local enemy = plists[i]
        local name = entity_get_player_name(enemy)
        local steamid = entity_get_steam64(enemy)
        local xuid = GameStateAPI.GetPlayerXuidStringFromEntIndex(enemy)

        if steamid3[steamid] then
            return
        end

        if plist_get(enemy, "Correction active") then
            steamid3[steamid] = ""
            GameStateAPI.SubmitPlayerReport(xuid, "wallhack, aimbot, speedhack")
            client_log("[REPORT] Ennemy reported: " .. name)
        end
    end
end)

client_set_event_callback("round_announce_warmup", function()
    steamid3 = {}
end)
--------------------------------------------------
-----------------Bomb_timer-------------------------
local render = ui_new_checkbox("MISC", "Miscellaneous", "Bomb timer")

local function get_bomb_time(bomb)
    local bomb_time = entity.get_prop(bomb, "m_flC4Blow") - globals.curtime()
    if bomb_time == nil then return 0 end
    if bomb_time > 0 then
        return bomb_time
    end
    return 0
end

local function round(num, numDecimalPlaces)
  local mult = 10^(numDecimalPlaces or 0)
  return math.floor(num * mult + 0.5) / mult
end

local function on_paint(c)
    local bomb = entity.get_all("CPlantedC4")[1]
    if bomb == nil then
		return
	end
	local blowtime = round(get_bomb_time(bomb),3)
	local width = renderer.measure_text("",blowtime)
	local x,y,z = entity.get_prop(bomb, "m_vecOrigin")
	local w2x,w2y = renderer.world_to_screen(x,y,z)
	if w2x ~= nil and w2y ~= nil then
    if not ui_get(render) then
        return
    end
renderer.text(w2x - 10,w2y + 18,255, 0, 0, 255,"b",0,"C4")
renderer.rectangle(w2x - 14,w2y + 6, width + 4,12,30,30,30,200)
renderer.text(w2x - 12,w2y + 5,100, 200, 200, 255,"",0,blowtime)
	end
end

client.set_event_callback("paint", on_paint)
--------------------------------------------------
----------------------RQ--------------------------
local function rq()
  client.exec("quit")
end

ui.new_button("Misc", "settings", "RAGE QUIT!", rq)
--------------------------------------------------
--------------------disconnect--------------------
local antipastedbot = ui.new_checkbox("Misc", "Miscellaneous", "leave when match end")

client.set_event_callback("cs_win_panel_match", function ()
  if not ui.get(antipastedbot) then
    return
  end
  client.log("match ended")
  --will disconnect after the match ends
  client.delay_call(3, function()
    client.exec("disconnect")
  end)
end)
--------------------------------------------------
--------------Resolver_override-------------------
client_draw_text, client_draw_indicator, client_set_event_callback, client_screen_size, ui_new_slider, ui_new_combobox, ui_reference, ui_set_visible, ui_is_menu_open, ui_new_color_picker, ui_set_callback, ui_set, ui_new_checkbox, ui_new_hotkey, ui_new_button, ui_new_multiselect, ui_get = client.draw_text, client.draw_indicator, client.set_event_callback, client.screen_size, ui.new_slider, ui.new_combobox, ui.reference, ui.set_visible, ui.is_menu_open, ui.new_color_picker, ui.set_callback, ui.set, ui.new_checkbox, ui.new_hotkey, ui.new_button, ui.new_multiselect, ui.get

override = ui.new_checkbox("MISC", "Miscellaneous", "Resolver override")
override_key = ui.new_hotkey("MISC", "Miscellaneous", "Override key",true)

local function update_menu(visible)
	if ui.get(override, true) then
		ui.set_visible(override_key, true)
	else
		ui.set_visible(override_key, false)
end
end
client.set_event_callback("paint", update_menu)

forceyaw = ui.reference("PLAYERS", "Adjustments", "Force body yaw")
toall = ui.reference("players", "Adjustments", "Apply to all")
yawslider = ui.reference("PLAYERS", "Adjustments", "Force body yaw value")

function setbodyyaw()
	if ui.get(override, true) then
	else
		return
	end
	if ui.get(yawslider) == 0 and key == true then
		ui.set(forceyaw, true)
		ui.set(yawslider, 22)
		ui.set(toall, true)
		key = false
	end
    if ui.get(yawslider) == 22 and key == true then
		ui.set(forceyaw, false)
		ui.set(yawslider, 0)
		ui.set(toall, true)
		key = false
    end
end

function on_paint()
	if ui.get(override, true) then
	else
		return
	end
	if ui.get(override_key) then
		if key == true then
			setbodyyaw()
			key = false
		end
	else
		key = true
	end
end
client.set_event_callback("paint", on_paint)

client.register_esp_flag("lowdelta", 225, 0, 0, function(c)
	if ui.get(yawslider) == 22 then return true end
end)

client.set_event_callback("paint", function()


	local w, h = client_screen_size()
	local center = { w/2, h/2 }
	local y = (center[2])
	
	if ui.get(override, true) then
		if ui.get(yawslider) == 22 then
    renderer.indicator(255, 0, 51, 255, "DANGEROUS")
		elseif ui.get(forceyaw) == false then
    renderer.indicator(245, 19, 215, 255, "DEFAULT")
		end
	end
end)

client.set_event_callback("round_start", function()
	ui.set(yawslider, 0)
	ui.set(forceyaw, false)
	ui.set(toall, true)
end)
----------------------------------------------------------
---------------------------------------------------------
------------------By_bass_valve--------------------------
local ffi = require"ffi"
local client_delay_call, ui_get = client.delay_call, ui.get
local enabled = ui.new_checkbox("MISC", "Miscellaneous", "Load files bypass")
local sv_pure_bypass = ui.reference("MISC", "Miscellaneous", "Disable sv_pure")
local file_system = ffi.cast("int*", client.create_interface("filesystem_stdio.dll", "VFileSystem017") or error("VFileSystem017 not found"))

ui.set_callback(enabled, function()
    if ui.get(enabled) then
        ui.set(sv_pure_bypass, true)
        set_files_is_checked_porperly()
    end
end)

function set_files_is_checked_porperly()
    if ui_get(enabled) then
        file_system[56] = 1
        client_delay_call(0.04, set_files_is_checked_porperly )
    end
end
---------------------------------------------------------
---------------------spectator_list----------------------
local svg_patterns = {}

local function gen_pattern(width, height)
	local svg = [[
<svg width="]] .. width .. [[" height="]] .. height .. [[" viewBox="0 0 ]] .. width .. [[ ]] .. height .. [[">
<rect width="]] .. width .. [[" height="]] .. height .. [[" y="0" x="0" fill="#151515"/>
#pattern
</svg>
]]
	for x=0, width, 4 do
		for y=0, height, 4 do
			local pattern = [[
<rect height="3" width="1" x="]] .. x+1 .. [[" y="]] .. y .. [[" fill="#0d0d0d"/>
<rect height="1" width="1" x="]] .. x+3 .. [[" y="]] .. y .. [[" fill="#0d0d0d"/>
<rect height="2" width="1" x="]] .. x+3 .. [[" y="]] .. y+2 .. [[" fill="#0d0d0d"/>
]]
			svg = svg:gsub("#pattern", pattern .. "#pattern")
		end
	end
	svg = svg:gsub("#pattern\n", "")
	return svg
end

local function rectangle_outline(x, y, w, h, r, g, b, a, s)
	s = s or 1
	renderer.rectangle(x, y, w, s, r, g, b, a) -- top
	renderer.rectangle(x, y+h-s, w, s, r, g, b, a) -- bottom
	renderer.rectangle(x, y+s, s, h-s*2, r, g, b, a) -- left
	renderer.rectangle(x+w-s, y+s, s, h-s*2, r, g, b, a) -- right
end

local function draw_container(x, y, w, h, a)
    a = a or 255
    h = h+10
	rectangle_outline(x, y, w, h, 18, 18, 18, a)
	rectangle_outline(x+1, y+1, w-2, h-2, 62, 62, 62, a)
	rectangle_outline(x+2, y+2, w-4, h-4, 44, 44, 44, a, 3)
	rectangle_outline(x+5, y+5, w-10, h-10, 62, 62, 62, a)


	local rw, ph, lxa, pw = w-12, h-12, 0

	for i=6, 2, -1 do
		pw = 2^i
		if rw % pw < 7 then
			break
		end
	end

	for i=1, 2 do
		if svg_patterns[pw] == nil or svg_patterns[pw][ph] == nil then
			svg_patterns[pw] = svg_patterns[pw] or {}
			svg_patterns[pw][ph] = renderer.load_svg(gen_pattern(pw, ph), pw, ph) or -1
		end

		if svg_patterns[pw][ph] ~= -1 then
			for xa=0, rw-pw, pw do
				renderer.texture(svg_patterns[pw][ph], x+6+xa+lxa, y+6, pw, ph, 255, 255, 255, a)
			end
		end

		if rw % pw == 0 then break end
		lxa, pw = rw - (rw % pw), rw % pw
		rw = pw
	end

	local x, y = x+7, y+7
	local w1, w2 = math.floor((w-14)/2), math.ceil((w-14)/2)

	for i=1, 2 do
		renderer.gradient(x, y, w1, 1, 59, 175, 222, a, 202, 70, 205, a, true)
		renderer.gradient(x+w1, y, w2, 1, 202, 70, 205, a, 201, 227, 58, a, true)
		y, a = y+1, a*0.2
    end
    renderer.text(x+w1, y+5, 255, 255, 255, 255, "c", 0, "Spectator List")
end

local x, y, w = 1200, 15, 300

local function draw_spectator_list()
    local spectators = {}

    for i = 1, 64 do
        if entity.get_prop(i, "m_hObserverTarget") ~= nil and not entity.is_alive(i) then 
            spectators[#spectators+1] = i 
        end
    end
    local h = (24 + #spectators*10)
    draw_container(x, y, w, h, 255)

    for i = 1, #spectators do 
        local r, g, b = 255, 255, 255
        local spectator = spectators[i]
        local targetid = entity.get_prop(spectator, "m_hObserverTarget")

        if targetid == entity.get_local_player() then g, b = 0, 0 end

        local observer = ""

        local obsmode = entity.get_prop(spectator, "m_iObserverMode")
        if obsmode == 4 or obsmode == 5 then 
            observer = entity.get_player_name(entity.get_prop(spectator, "m_hObserverTarget"))
        elseif obsmode == 6 then 
            observer = "Freelook"
            r = 0
        else
            b = 0
        end
        
        renderer.text(x+10, y+13+(i*10), r, g, b, 255, nil, 0, entity.get_player_name(spectator))
        renderer.text(x+10+w/2-14, y+13+(i*10), r, g, b, 255, nil, 0, "->")
        renderer.text(x+10+w-20, y+13+(i*10), r, g, b, 255, "r", 0, observer)
    end

    if ui.is_menu_open() then 
        if client.key_state(1) then 
            local mx, my = ui.mouse_position()
            if (mx > x and mx < x+w) and (my > y and my < y+h)  then 
                x = mx-(w/2)
                y = my-(h/2)
                database.write("spectator_list_coordinates", {x, y})
            end
        end
    end
end

local ui_enabled = ui.new_checkbox("Misc", "Miscellaneous", "Spectator list")
local ui_width = ui.new_slider("Misc", "Miscellaneous", "Width", 150, 600, 300, true, "px")

local function script_toggle()
    local state = ui.get(ui_enabled)
    local update_callback = state and client.set_event_callback or client.unset_event_callback
    update_callback("paint", draw_spectator_list)
    x, y = unpack(database.read("spectator_list_coordinates") or {1200, 15})
    ui.set_visible(ui_width, state)
end

ui.set_callback(ui_width, function() w = ui.get(ui_width) end)
w = ui.get(ui_width)
ui.set_callback(ui_enabled, script_toggle)
script_toggle()
----------------------------------------------------
----------------------------------------------------
local check = ui.new_checkbox("MISC", "Miscellaneous", "Disable Ragebot,Antiaim")
local enabled = ui.reference("AA", "Anti-aimbot angles", "Enabled")
local enabled2 = ui.reference("RAGE", "Aimbot", "Enabled")

client.set_event_callback("cs_win_panel_match", function()
	if ui.get(check) then
		ui.set(enabled, false)
       	ui.set(enabled2, false)
	end
end)

client.set_event_callback("round_announce_match_start", function()
	if ui.get(check) then
		ui.set(enabled, true)
        ui.set(enabled2, true)
	end
end)
----------------------------------------------
------------enemy_desync_indicator------------
local client_register_esp_flag, entity_is_enemy, plist_get = client.register_esp_flag, entity.is_enemy, plist.get

local enaablee = ui.new_checkbox("MISC", "Miscellaneous", "enemy desync indicator")



client_register_esp_flag("desync", 255, 255, 255, function(c)
   if not ui_get(enaablee) then return end
	if entity_is_enemy(c) then
    return plist_get(c, "Correction active")
	end
end)
local label1 = ui.new_label("MISC", "Miscellaneous", '       [MEGASHIT]')
----------------------------------------------------------
-----------------------legit------------------------------
-------------------Trigger_magnet-------------------------
local ref = { ui.reference("LEGIT", "Aimbot", "Enabled") }
local trigger = { ui.reference("LEGIT", "Triggerbot", "Enabled") }
local label1 = ui.new_label("LEGIT", "Other", '[------[MEGASHIT]------]')
local label1 = ui.new_label("LEGIT", "Other", '     >>|legitbot|<<')
local master = ui.new_checkbox("LEGIT", "Other", "Trigger magnet")
local master = ui.new_hotkey("LEGIT", "Other", "Trigger magnet", true)
local hotkey = ui.new_hotkey("LEGIT", "Other", "legit awall", false)
local auto_penetration_ref = ui_reference("LEGIT", "Triggerbot", "Automatic penetration")
local indicatormt = ui.new_checkbox("LEGIT", "Other", "trigger indicator")
local indicatorbox = ui.new_checkbox("LEGIT", "Other", "legit awall indicator")

client.set_event_callback("net_update_end", function()
    if ui.get(master) then
                ui.set(trigger[2], "Always on")
        ui.set(ref[2], "Always on")                    
    else
        ui.set(ref[2], "On hotkey")
        ui.set(trigger[2], "On hotkey")
    end
end)


local ref = { ui.reference("LEGIT", "Aimbot", "Enabled") }
local trigger = { ui.reference("LEGIT", "Triggerbot", "Enabled") }

client.set_event_callback("net_update_end", function()
    if not ui.get(master) then return end
    if ui.get(trigger[2]) then
 
        ui.set(ref[2], "Always on")
       
    else
        ui.set(ref[2], "On hotkey")
    end
end)

client.set_event_callback("paint", function()
	if not ui.get(indicatormt) then
			return
	else 
		if ui.get(trigger[2])	then
			renderer.indicator(124, 195, 13, 255, "MT")
		else
			renderer.indicator(0, 0, 0, 80, "MT")
		end
	end
end)
----------------legit_awll------------------------
function legitawall()
if ui.get(hotkey) then
    ui.set(auto_penetration_ref, true)
    if ui.get(indicatorbox) then
        renderer.indicator(76, 255, 0, 255, "awll")
    end
else
    ui.set(auto_penetration_ref, false)
    if ui.get(indicatorbox) then
         renderer.indicator(255, 0, 0, 255, "awll")
    end
end
end
client.set_event_callback("paint", legitawall)
---------------------------------------------------
--------------------------------------------------
local countries = require("gamesense/countries")
local enabled = ui.new_checkbox("MISC", "Miscellaneous", "Country welcomer")

client.set_event_callback("player_connect_full", function(e)
    if(not countries.server_has_plugin()) then
        return
    end

    if(not ui.get(enabled)) then
        return
    end

    local entindex = client.userid_to_entindex(e.userid)
    if(entindex == entity.get_local_player()) then
        return
    end

    client.delay_call(2, function()
        local player_name = entity.get_player_name(entindex):gsub(";", "")
        local country_code = countries.get_player_country(entindex)
        local country_name = countries.get_country_name(country_code)

        if(country_name ~= "Unknown") then
            client.exec("say ", ("a warm welcome for %s from %s"):format(player_name:lower(), country_name:lower()))
        end
    end)
end)

local checkbox = ui.new_checkbox("MISC", "Miscellaneous", "Gamesense Steam Presence")
local ffi = require("ffi")
ffi.cdef[[
typedef struct
      {
        void* steam_client;
        void* steam_user;
        void* steam_friends;
        void* steam_utils;
        void* steam_matchmaking;
        void* steam_user_stats;
        void* steam_apps;
        void* steam_matchmakingservers;
        void* steam_networking;
        void* steam_remotestorage;
        void* steam_screenshots;
        void* steam_http;
        void* steam_unidentifiedmessages;
        void* steam_controller;
        void* steam_ugc;
        void* steam_applist;
        void* steam_music;
        void* steam_musicremote;
        void* steam_htmlsurface;
        void* steam_inventory;
        void* steam_video;
      } S_steamApiCtx_t;

typedef bool(__thiscall* fnSetRichPresence)(void*, const char*, const char*);
]]

local signature = client.find_signature("client_panorama.dll", "\xFF\x15\xCC\xCC\xCC\xCC\xB9\xCC\xCC\xCC\xCC\xE8\xCC\xCC\xCC\xCC\x6A") or error("invalid interface")
local steam_ctx = ffi.cast("S_steamApiCtx_t**", ffi.cast("char*", signature) + 7)[0] or error("signature not found")
local steam_friends = steam_ctx.steam_friends
local vtable = ffi.cast("void***", steam_friends)[0] or error("steam_friends issue")
local SetRichPresence = ffi.cast("fnSetRichPresence", vtable[43])

local function update()
	if ui.get(checkbox) then
		SetRichPresence(steam_friends, "steam_display", "#bcast_teamvsteammap")
		SetRichPresence(steam_friends, "team1", "gamesense.pub                                          ") -- looks bad, but works
		SetRichPresence(steam_friends, "team2", ".")
		SetRichPresence(steam_friends, "map", "de_dust2")
		SetRichPresence(steam_friends, "game:mode", "competitive")
		SetRichPresence(steam_friends, "system:access", "private")
	end
	client.delay_call(5, update) -- very lame way, but other stuff doesn't really work.
end

update()

--------------------------------------------------
---------------------antiaim----------------------
---------------slowwalk_switch--------------------
local ref_fake = ui.reference("AA", "Other", "Slow motion type")
local label1 = ui.new_label("aa", "anti-aimbot angles", '[------[MEGASHIT]------]')
local enable = ui.new_checkbox("aa", "anti-aimbot angles", "Slowalk switch")
local hkey = ui.new_hotkey("AA", "Anti-aimbot angles", "Slowalk Switch", true)
local label1 = ui.new_label("aa", "anti-aimbot angles", '         [MEGASHIT]')

local function Slow()
if not ui.get(enable) then return end

    if ui.get(hkey) then
        ui.set(ref_fake, "Favor high speed")
        renderer.indicator(255, 0, 0, 255, "Favor HS")
    else
        ui.set(ref_fake, "Favor anti-aim")
        renderer.indicator(76, 255, 0, 255, "Favor AA")
    end
end

client.set_event_callback("paint", Slow)
----------------------------------------------------
-----------------effects----------------------------
---------------cleanscope---------------------------
local get, get_lp, add_event, find_materials, uidtoentindex, checkbox = ui.get, entity.get_local_player, client.set_event_callback, materialsystem.find_materials, client.userid_to_entindex, ui.new_checkbox
local label1 = ui.new_label("visuals", "effects", '[------[MEGASHIT]------]')
local label1 = ui.new_label("visuals", "effects", '     >>|EFFECTS|<<')
local enabled = checkbox("visuals", "effects", "Remove scope lens")
add_event("paint", function(ctx)
	if (enabled) then
		local sleeve = find_materials("overlays/scope_lens")
		for i=#sleeve, 1, -1 do
			sleeve[i]:set_material_var_flag(2, get(enabled))
		end
	end
end)

------------Remove_Danger_Zone_Grass------------
local ui_get, ui_new_checkbox = ui.get,ui.new_checkbox
local find_materials = materialsystem.find_materials
local client_set_event_callback = client.set_event_callback
local remove_grass = ui_new_checkbox("VISUALS", "Effects", "Remove Danger Zone Grass")
local label1 = ui.new_label("visuals", "effects", '         [MEGASHIT]')

local grass_state = false
local function grass_on_update()
	grass_state = false
end
ui.set_callback(remove_grass, grass_on_update)

local function grass_remove()
	local map_name = globals.mapname()
	local bool = ui_get(remove_grass)
	if ( map_name == ("dz_blacksite") ) then
	local grass1 = find_materials("detail/detailsprites_survival")
	for a = 1, #grass1 do
	   grass1[a]:set_material_var_flag(2, bool)
	end

	elseif ( map_name == ("dz_sirocco") ) then
	local grass2 = find_materials("detail/dust_massive_detail_sprites")
	for b = 1, #grass2 do
	   grass2[b]:set_material_var_flag(2, bool)
	end
	--Junglety was removed from the game 
	elseif ( map_name == ("dz_frostbite") ) then
	local grass4 = find_materials("ski/detail/detailsprites_overgrown_ski")
	for c = 1, #grass4 do
	   grass4[c]:set_material_var_flag(2, bool)
	end	
	end
end

client_set_event_callback("net_update_end", function()
	if not grass_state then
		grass_remove()
		grass_state = true
	end
end)

client_set_event_callback("shutdown", function()
	grass_state = false
end)
----------------------------------------------------
---------------*******Help*******-------------------
-----------------steam1d3_check---------------------
----local Player2 = someones steamid3
----if (playersteamid == Player1 or playersteamid == Player2) then
--------------------steamid3------------------------
whitelistsucess = false
local Player1 = 1112042143  --megarage
local Player2 = 454482231  ---mega
------^^steamID3^^-------
local playerid = entity.get_local_player()
if (playerid == nil) then return end
local playersteamid = entity.get_steam64(playerid)
local api = js.MyPersonaAPI
local name = api.GetName()
----add player------------------------------
if (playersteamid == Player1 or playersteamid == Player2 or playersteamid == Player3 or playersteamid == Player4 or playersteamid == Player5 ) then
--------------------------------------------
whitelistsucess = true
client.color_log(180, 238, 0, '   <---<[\0')
client.color_log(180, 0, 0, 'M\0')
client.color_log(180, 238, 0, 'EGA\0')
client.color_log(180, 0, 0, 'S\0')
client.color_log(180, 238,0, 'HIT]\0')
client.color_log(180, 238,0, '>--->')
client.color_log(180, 238, 0, ' Welcome\0' )
client.color_log(255, 77, 44, ' '.. name .. '\0                     ')
client.color_log(180, 238, 0, '!') 
client.color_log(33, 238, 0, ' Last update:\0')
client.color_log(255, 10, 249, ' 31.1.2021')
else
whitelistsucess = false
client.color_log(180, 238, 0, '                     <---<[\0')
client.color_log(180, 0, 0, 'M\0')
client.color_log(180, 238, 0, 'EGA\0')
client.color_log(180, 0, 0, 'S\0')
client.color_log(180, 238,0, 'HIT]\0')
client.color_log(180, 238,0, '>--->')
client.color_log(180, 238,0, 'user not whitelistet contact to: \0')
client.color_log(255, 10, 249, 'Mega#4132\0')
client.color_log(180, 238,0, ' get whitelistet!!')
client.delay_call(10, function()
  client.color_log(255, 200, 0, '            close game after 30 second')
  end)
client.delay_call(40, function()
  client.exec("quit")
  end)
end
-------------------
 
by

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