//== Because Trollaux can't make a half decent base I decided to make this. ==//
//==                   I don't care what you do with this                   ==//


--// A couple notes //--

//== I made a CreateMove example that snaps your aiming angles to 0, 0, 0 ==//
//== I made a HUDPaint example that draws the name of your cheat in the top left corner ==//
//== I will add a ESP, Aimbot and menu example later == //
//== The HUDPaint and CreateMove hooks can be detected easily == //

local A = {} // Localized table for our cheat, we'll put our functions and variables in here for tidiness

// A.Variables [table]
// Purpose: Store useful variables we'll use later in the cheat
// Process: Create table, specify what we would like inside the table

A.Variables = {
	stringexample = "string example", // First index of our A.Variables table is a string
	boolexample = true, // Second one is a bool, you can either do true or false
	floatexample = 1, // Third one is a float, can be any number
	GlobalColor = Color( 153, 0, 0, 255 ), // Fourth index is our color we are going to be using in the hack.
	CheatName = "OurCheat" // Fifth index is a string, the name of our cheat. Change if you want.
}

// A.PrintChat [function]
// Purpose: Print stuff in chat for us, useful for notifying the user
// Process: Adds to chat the text with the color GlobalColor, concate the
//          string, then we put inside our two brackets the variable
//          CheatName, revert back to white color, then use txt for
//          the remainder of the string

function A.PrintChat( txt ) // Create the function, accept the argument txt
	chat.AddText( A.Variables.GlobalColor, "[", A.Variables.CheatName, "] ", Color( 255, 255, 255, 255 ), txt ) // Use the function AddText in the library chat to print things into chat
end

// A.PrintConsole [function]
// Purpose: Print stuff in console like hooks added and other various things so debugging is easier
// Process: Same process as A.PrintChat, except we use a gray color and we use the newline character
//          at the end of the string so the messages don't overlap

function A.PrintConsole( txt ) // Create the function, accept the argument txt
	MsgC( Color( 112, 128, 144 ), "[", A.Variables.CheatName, "] ", txt .. "\n" ) // Use the function MsgC in the global table to create a message in console
end

// A.RandomString [function]
// Purpose: Makes us a random string that we use later in the A.AddHook function
// Process: Make a localized variable that is a blank string, create a for loop
//          and add onto our str string with a random letter/number/character,
//			as many times as it is specified in our first argument amt

function A.RandomString( amt ) 
	local str = "" // Localized blank string
		for i = 1, amt do // For loop starting at 1 ending at amt, run the for loop
			str = str .. string.char( math.random( 97, 122 ) ) // Add onto str a random letter/number/character
		end // end our for loop
	return str // return our string full of random letters/numbers/characters, exit the scope
end

// A.HookFunction [function]
// Purpose: Make hooks with randomly generated names so anticheats cant use hook.GetTable[ "CreateMove" ][ "Aimbot" ]
// Process: Make a localized variable that gets a random string of 15 length from our function A.RandomString, then we
//          create our hook with hook.Add. After doing that we print in console using A.PrintConsole that we hooked a
// 			function with the type of the hook and the name of the hook

function A.HookFunction( typ, func )
	local str = A.RandomString( 15 ) // Grab a random string of 15 length from A.RandomString
	hook.Add( typ, str, func ) // Note: hook.Add can be detected VERY EASILY, I recommend you dig around some other cheats to see how they hook things
	A.PrintConsole( "Hooked a function with the type: " .. typ .. " with the name: " .. str ) // Print in console that we hooked a function
end

// A.CreateMove [function] [hooked]
// Purpose: Help us make things like bunny hop automation, aimbots, spinbots and other fun stuff
// Process: Store our angle in the user command with the angle we specified using the function SetViewAngles

function A.CreateMove( cmd )
	cmd:SetViewAngles( Angle( 0, 0, 0 ) ) // Stores the angle 0, 0, 0 in the user command which gets sent to the server later
end

// A.HUDPaint [function] [hooked]
// Purpose: Our function we draw our ESP and other various stuff in
// Process: Uses the function DrawText in the draw library to make text.
//          We are using the text of our variable A.VariableA.CheatName,
//          using the font Default with the location on our screen of
//			X: 10 Y: 10 with the color A.VariableA.GlobalColor

function A.HUDPaint()
	local CheatName = A.Variables.CheatName // We could localize the other things like GlobalColor if we wanted to, for now I'll just localize A.VariableA.CheatName
	draw.DrawText( CheatName, "Default", 5, 5, A.Variables.GlobalColor ) // Use the function DrawText from the draw library with our specified arguments
end

function A.HookedFunctionsCreateMove( cmd )
	A.CreateMove( cmd ) // Call our function A.CreateMove with one argument being pushed, which is the user command set of functions
end

A.HookFunction( "CreateMove", A.HookedFunctionsCreateMove ) // Hook the function A.HookedFunctionsCreateMove with CreateMove which calls all our functions that need to be ran every tick and pushes into them the user command set of functions

function A.HookedFunctionsHUDPaint()
	A.HUDPaint() // Call our function A.HUDPaint
end

A.HookFunction( "HUDPaint", A.HookedFunctionsHUDPaint ) // Hook the function A.HookedFunctionsHUDPaint with HUDPaint which runs everything fast but not every tick

A.PrintChat( "Cheat successfully loaded!" ) // Print in chat that the cheat has been loaded