Code:
-- Usage: Get a GLua Loader
-- Inject the .Dll into the game using any Dll injector
-- Press [Home] (Unless you're using a different GLua loader
-- Paste this code into the loader and run it, once done press insert and you're good to go :) (The unload only closes the menu, doesn't actually unload it ;-;)
-- Thanks to SmegHack for teaching me a bit of GLua and giving me some stuff that I can copy (but I wrote it, I didn't paste it ;)
-- Freecam Variables --
local ZESFreecam = {}
ZESFreecam.Options = {}
ZESFreecam.Options["FC_Toggle"] = false
ZESFreecam.Options["FC_NoClipSpeed"] = 10
-- Other Variables --
local MenuOpen = false
local width, height = 200, 150
-- Fonts --
surface.CreateFont("Menu_Title", {font = "coolvetica", size = 25})
surface.CreateFont("Freecam", {font = "Ariel", size = 25})
-- Functions --
function Load(Display)
concommand.Add("ZESFreecamMenu", DrawMenu)
local MenuDelay = false
local FCPos, FCAngles, FCEnabled, FCX, FCY, FCDuck, FCJump = LocalPlayer():EyePos(), LocalPlayer():GetAngles(), false, 0, 0, false, false
-- Hooks --
hook.Add("Think", "Menu", function() -- Menu Hook
if (input.IsKeyDown(KEY_INSERT) && !MenuDelay) then
MenuDelay = true
DrawMenu()
timer.Simple(.5, function() MenuDelay = false end)
end
end)
hook.Add("CalcView", "FreecamKBController", function(ply, Pos, Ang, FOV)
if (ZESFreecam.Options["FC_Toggle"]) then
local FCData = {}
local Speed = ZESFreecam.Options["FC_NoClipSpeed"] / 5
local MouseAngles = Angle(FCY, FCX, 0)
if (LocalPlayer():KeyDown(IN_SPEED)) then
Speed = Speed * 5
end
if (LocalPlayer():KeyDown(IN_FORWARD)) then -- Move Forward --
FCPos = FCPos + (MouseAngles:Forward() * Speed)
end
if (LocalPlayer():KeyDown(IN_BACK)) then -- Move Back --
FCPos = FCPos - (MouseAngles:Forward() * Speed)
end
if (LocalPlayer():KeyDown(IN_MOVELEFT)) then -- Move Left --
FCPos = FCPos - (MouseAngles:Right() * Speed)
end
if (LocalPlayer():KeyDown(IN_MOVERIGHT)) then -- Move Right --
FCPos = FCPos + (MouseAngles:Right() * Speed)
end
if (FCJump) then
FCPos = FCPos + Vector(0, 0, Speed)
end
if (FCDuck) then
FCPos = FCPos - Vector(0, 0, Speed)
end
FCData.origin = FCPos;
FCData.angles = MouseAngles
FCData.fov = FOV
FCData.drawviewer = true
return FCData;
end
end)
hook.Add("CreateMove", "FreecamMouseController", function(ucmd)
if (ZESFreecam.Options["FC_Toggle"]) then
if (FCEnabled == false) then
FCPos, FCAngles = LocalPlayer():EyePos(), ucmd:GetViewAngles()
FCY, FCX = ucmd:GetViewAngles().x, ucmd:GetViewAngles().y
FCEnabled = true
end
ucmd:ClearMovement()
if (ucmd:KeyDown(IN_JUMP)) then
ucmd:RemoveKey(IN_JUMP)
FCJump = true
elseif (FCJump) then
FCJump = false
end
if (ucmd:KeyDown(IN_DUCK)) then
ucmd:RemoveKey(IN_DUCK)
FCDuck = true
elseif (FCDuck) then
FCDuck = false
end
FCX = FCX - (ucmd:GetMouseX() / 50)
if FCY + (ucmd:GetMouseY() / 50) > 89 then FCY = 89 elseif FCY + (ucmd:GetMouseY() / 50) < -89 then FCY = -89 else FCY = FCY + (ucmd:GetMouseY() / 50) end
ucmd:SetViewAngles(FCAngles)
elseif (FCEnabled) then
FCEnabled = false
end
end)
end
function DrawMenu()
if (MenuOpen) then
CloseMenu()
return
end
MenuOpen = true
local Menu = vgui.Create("DFrame")
Menu:SetTitle("")
Menu:ShowCloseButton(false)
Menu:SetDraggable(true)
Menu:SetSize(width, height)
Menu:Center()
Menu:MakePopup()
function Menu:Paint(w, h)
-- Title Bar --
draw.RoundedBox(0, 0, 0, w, 24, Color(0, 0, 0, 255))
draw.RoundedBox(0, 0, 0, w, h, Color(0, 10, 20, 245))
draw.SimpleText("ZESFreecam", "Menu_Title", w/2, 11, Color(255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
AddCheckBox(Menu, "ZESFreecam Enabled", width/2-60, 30, "Enabled/Disabled the Freecamera", "FC_Toggle")
AddSlider(Menu, "FC_NoClipSpeed", width/2-65, 50, 1, 10)
AddGenericButton(Menu, "Unload Hack", 100, 50, width/2-50, height-60, function()
CloseMenu()
Unload(true)
end)
function CloseMenu()
MenuOpen = false
Menu:Close()
end
end
function Unload(Display)
concommand.Remove("ZESFreecamMenu")
end
-- GUI Functions --
function AddLabel(Parent, Text, PosX, PosY)
local AddLabel = vgui.Create("DLabel", Parent)
AddLabel:SetText(Text)
AddLabel:SetPos(PosX, PosY)
AddLabel:SetColor(Color(255, 255, 255, 255))
AddLabel:SizeToContents()
return AddLabel:GetSize()
end
function AddCheckBox( Parent, Text, PosX, PosY, ToolTip, Var, ExtraFunc )
local AddCheckBox = vgui.Create( "DCheckBoxLabel", Parent )
AddCheckBox:SetText( Text )
AddCheckBox:SetPos( PosX, PosY )
AddCheckBox:SetTooltip( ToolTip )
AddCheckBox:SetTextColor( Color(255,255,255,255) )
AddCheckBox:SizeToContents()
AddCheckBox:SetChecked( ZESFreecam.Options[Var] )
AddCheckBox.OnChange = function()
ZESFreecam.Options[Var] = AddCheckBox:GetChecked()
if ExtraFunc != nil then
local IsChecked = AddCheckBox:GetChecked()
ExtraFunc()
end
end
end
function AddSlider( Parent, Var, PosX, PosY, Min, Max, Decimals )
local AddSlider = vgui.Create( "Slider", Parent )
AddSlider:SetSize( 150, 15 )
AddSlider:SetPos( PosX, PosY )
AddSlider:SetMin( Min )
AddSlider:SetMax( Max )
AddSlider:SetDecimals( Decimals )
AddSlider:SetValue( ZESFreecam.Options[Var] )
AddSlider.OnValueChanged = function( Panel, Value )
ZESFreecam.Options[Var] = math.Round( Value, Decimals )
end
AddSlider.Paint = function()
draw.RoundedBox( 0, 0, 0, 135, 15, Color(255,255,255,255) )
surface.SetDrawColor(Color(0,0,0,255))
surface.DrawOutlinedRect( 0, 0, 135, 15 )
surface.DrawLine( 105, 0, 105, 15 )
end
end
function AddGenericButton( Parent, Text, SizeX, SizeY, PosX, PosY, DoClick )
local AddGenericButton = vgui.Create( "DButton", Parent )
AddGenericButton:SetText( Text )
AddGenericButton:SetTextColor( Color(255,255,255) )
AddGenericButton:SetSize( SizeX, SizeY )
AddGenericButton:SetPos( PosX, PosY )
function AddGenericButton:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color(150,150,150,255) )
surface.SetDrawColor( Color(0,0,0,255) )
surface.DrawOutlinedRect( 0, 0, w, h )
end
AddGenericButton.DoClick = DoClick
end
Load(true)