/*
	(RUSSIAN) AM DENNY =] [65.30.50.13:27005 | STEAM_0:0:40143824]
	GMT_Scripts.txt
*/
print("[GMT Scripts] Loaded")

--[[
==================================================
NOTICE: THIS CODE IS MESSY AS HELL.
I RUSHED THROUGH THIS, I DON'T CARE FOR IT AT ALL
==================================================
]]--

local GMT 	= {};
GMT.funcs 	= {};
GMT.hooks 	= {};

local old_hookadd = hook.Add;
local old_rcc = RunConsoleCommand;

-- quick exploit scripts for GMod tower

function Print(msg)
	print("[GMT Scripts] "..msg)
end

function AddConVar(convar,str,save,data)
	Print("added convar: gmt_"..convar)
	return CreateClientConVar("gmt_"..convar,str,true,false)
end

-- you'll just have to make the file yourself, fuck you.
function Log(msg)
file.Append("GMT_RCCLOG.txt","["..os.date().."]: "..msg.."\n")
end
Log("Loading scripts...")

function GetCvar(cmd)
	return GetConVarNumber(cmd)
end

local function AddHook(Type,Function)
	Name = Type.." | "..math.random(1,1000),math.random(1,2000),math.random(1,3000)
	Print("added hook: "..Type)
	return old_hookadd(Type,Name,Function)
end

function RunConsoleCommand(cmd,...)
	Print("RunConsoleCommand: "..cmd)
	Log("RunConsoleCommand: "..cmd)
	return old_rcc(cmd,...)
end

-- add convars
AddConVar("model",0);
AddConVar("esp",0);
AddConVar("bhop",0);
AddConVar("slots",0);

-- fonts, nigga
surface.CreateFont("ESPFont",{font = "coolvetica", size = 17, weight = 400, antialias = 1});

-- model color changer (makes your player model color change randomly)
function model()
	if GetCvar("gmt_model") == 1 then
		LocalPlayer():ConCommand("cl_playercolor "..math.random(0,5).." "..math.random(0,5).." "..math.random(0,5))
		LocalPlayer():ConCommand("gmt_updateplayercolor");
	end
end

			

-- ESP, for finding your friends or whatever.
function ESP()
	if GetCvar("gmt_esp") == 1 then
		for k, v in pairs( player.GetAll() ) do
			if( v:Alive() && v != LocalPlayer() ) then
				local Pos = ( v:GetPos() + Vector( 0, 0, 100 ) ):ToScreen();
				local dist = v:GetPos():Distance(LocalPlayer():GetPos())
				draw.SimpleTextOutlined(v:Nick(), "ESPFont", Pos.x, Pos.y, Color(255,228,0,255), 4, 1, 1, Color(0,0,0) )
					if v:GetFriendStatus() == "friend" then
						draw.SimpleText("[Friend]", "ESPFont", Pos.x, Pos.y - 12, Color(255,228,0,255), 4, 1, 1, Color(0,0,0) )
					end
			end
		end
	end
end

function BHOP()
	if GetCvar("gmt_bhop") == 1 then
		if input.IsKeyDown(KEY_SPACE) then
			if LocalPlayer():IsOnGround() then
				old_rcc("+Jump")
				timer.Create("Bhop",0.01, 0 ,function()
					old_rcc("-Jump") 
				end)
			end
		end
	end
end

function Slots()
	if GetCvar("gmt_slots") == 1 then
		LocalPlayer():ConCommand("slotm_spin")
	end
end

-- hooks

function hooks_think()
	BHOP()
	model()
	Slots()
end

function hooks_hudpaint()
	ESP()
end

AddHook("HUDPaint",hooks_hudpaint);
AddHook("Think",hooks_think);	
