Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --local ChosenColor = Color(255, 255, 255, 255)
- --local ChosenColor2 = Color(255, 255, 255, 255)
- gap = 0
- width = 1
- size = 10
- local x_axis = CreateClientConVar("thirdperson_x", "60", true)
- local y_axis = CreateClientConVar("thirdperson_y", "10", true)
- local z_axis = CreateClientConVar("thirdperson_z", "0", true)
- local third_person_state = false
- hook.Add( "HUDShouldDraw", "ThirdPerson.HUDShouldDraw", function( name )
- if name == "CHudCrosshair" then return !third_person_state end
- end )
- local function check_player_valid()
- local ply = LocalPlayer()
- if not ply:Alive() or ply:IsRagdoll() or ply:InVehicle() then
- return false
- else
- return true
- end
- end
- hook.Add("CalcView", "ThirdPerson.CalcView", function(ply, pos, angles, fov)
- if third_person_state and ply:Alive() then
- local view = {}
- view.origin = pos-(angles:Forward()*x_axis:GetInt())-(angles:Right()*z_axis:GetInt())-(angles:Up()*y_axis:GetInt())
- view.angles = angles
- view.fov = fov
- local traceData = {}
- traceData.start = pos
- traceData.endpos = traceData.start + angles:Forward() * -x_axis:GetInt()
- traceData.endpos = traceData.endpos + angles:Right() * -z_axis:GetInt()
- traceData.endpos = traceData.endpos + angles:Up() * y_axis:GetInt()
- traceData.filter = ply
- local trace = util.TraceLine(traceData)
- pos = trace.HitPos
- if trace.Fraction < 1.0 then
- pos = pos + trace.HitNormal * 5
- end
- view.origin = pos
- return view
- end
- end)
- hook.Add("ShouldDrawLocalPlayer", "ThirdPerson.ShouldDrawLocalPlayer", function()
- return third_person_state
- end)
- usermessage.Hook("ThirdPerson.Toggle", function(ply, cmd, args)
- if not third_person_state then
- third_person_state = true
- else
- third_person_state = false
- end
- end)
- hook.Remove("HUDPaint", "Crosshair")
- hook.Add("OnPlayerChat", "crossHairChanger", function(ply,strText,bTeam,bDead)
- local strText = string.lower(strText)
- if(strText == "!settings") then
- --Background blur
- local blur = Material("pp/blurscreen")
- local function DrawBlur(panel,amount)
- local x, y = panel:LocalToScreen(0,0)
- surface.SetDrawColor(255,255,255)
- surface.SetMaterial(blur)
- for i = 1,3 do
- blur:SetFloat("$blur", (i/3) * (amount or 6))
- blur:Recompute()
- render.UpdateScreenEffectTexture()
- surface.DrawTexturedRect(x * -1, y * -1, ScrW(), ScrH())
- end
- end
- --Main settings frame
- local SettingFrame = vgui.Create("DFrame")
- SettingFrame:SetTitle("Settings")
- SettingFrame:SetSize(600,300)
- SettingFrame:MakePopup()
- SettingFrame:Center()
- SettingFrame:SetBackgroundBlur(true)
- SettingFrame:SetVisible(true)
- SettingFrame:SetDraggable(true)
- SettingFrame:ShowCloseButton(false)
- SettingFrame.Paint = function(self, w, h)
- Derma_DrawBackgroundBlur(self)
- draw.RoundedBox(0,0,0,w,h,Color(40,40,40,255))
- --DrawBlur(self,2)
- end
- local closeButton = vgui.Create( "DButton", SettingFrame )
- closeButton:SetText( "X" )
- closeButton:SetTextColor( Color( 255, 0, 0 ) )
- closeButton:SetPos( SettingFrame:GetWide() - 20, 0 )
- closeButton:SetSize( 20, 20 )
- closeButton.Paint = function( self, w, h )
- draw.RoundedBox( 0, 0, 0, w, h, Color( 50, 50, 50, 255 ) )
- end
- closeButton.DoClick = function()
- SettingFrame:SetVisible(false)
- end
- local CrossHairTab = vgui.Create("DPropertySheet",SettingFrame)
- CrossHairTab:Dock(FILL)
- CrossHairTab:AddSheet("Crosshair", CrossHairTab, "icon16/user.png",false,false, "Change your Crosshair")
- --Crosshair
- local SizeSlider = vgui.Create( "DNumSlider", CrossHairTab )
- SizeSlider:SetPos( 10, 150 ) // Set the position
- SizeSlider:SetSize( 200, 15 ) // Set the size
- SizeSlider:SetText( "Size" ) // Set the text above the slider
- SizeSlider:SetMin( 1 ) // Set the minimum number you can slide to
- SizeSlider:SetMax( 100 ) // Set the maximum number you can slide to
- SizeSlider:SetValue( size )
- SizeSlider:SetDecimals( 0 ) // Decimal places - zero for whole number
- SizeSlider.OnValueChanged = function( panel, value )
- size = math.Round(value)
- end
- local GapSizeSlider = vgui.Create( "DNumSlider", CrossHairTab )
- GapSizeSlider:SetPos(10,210)
- GapSizeSlider:SetSize( 200, 15 ) // Set the size
- GapSizeSlider:SetText( "Gap Size" ) // Set the text above the slider
- GapSizeSlider:SetMin( 0 ) // Set the minimum number you can slide to
- GapSizeSlider:SetMax( 100 ) // Set the maximum number you can slide to
- GapSizeSlider:SetValue( gap )
- GapSizeSlider:SetDecimals( 0 ) // Decimal places - zero for whole number
- GapSizeSlider.OnValueChanged = function( panel, value )
- gap = math.Round(value)
- end
- local WidthSlider = vgui.Create( "DNumSlider", CrossHairTab )
- WidthSlider:SetPos( 10, 180 ) // Set the position
- WidthSlider:SetSize( 200, 15 ) // Set the size
- WidthSlider:SetText( "Width" ) // Set the text above the slider
- WidthSlider:SetMin( 1 ) // Set the minimum number you can slide to
- WidthSlider:SetMax( 200 ) // Set the maximum number you can slide to
- WidthSlider:SetValue( width )
- WidthSlider:SetDecimals( 0 ) // Decimal places - zero for whole number
- WidthSlider.OnValueChanged = function( panel, value )
- width = math.Round(value)
- end
- local DermaCheckboxone = vgui.Create( "DCheckBoxLabel" , CrossHairTab )// Create the checkbox
- DermaCheckboxone:SetPos( 5, 50 )// Set the position
- DermaCheckboxone:SetValue(false)
- DermaCheckboxone:SetText("Enable Crosshair")
- /*
- local Text = vgui.Create( "DLabel", CrosshairChanger )
- Text:SetPos( 25, 50 )
- Text:SetSize( 100, 15)
- Text:SetText( "Enable Crosshair" )
- */
- /*
- if DermaCheckboxone:GetChecked() == false then
- print("Not checked")
- end
- */
- local DermaCheckboxtwo = vgui.Create( "DCheckBoxLabel" , CrossHairTab )// Create the checkbox
- DermaCheckboxtwo:SetPos( 5, 70 )// Set the position
- DermaCheckboxtwo:SetValue(false)
- DermaCheckboxtwo:SetText("Rainbow Crosshair")
- /*
- local Text = vgui.Create( "DLabel", CrosshairChanger )
- Text:SetPos( 25, 70 )
- Text:SetSize( 100, 15)
- Text:SetText( "Rainbow Crosshair" )
- */
- local outline = vgui.Create( "DCheckBoxLabel" , CrossHairTab )// Create the checkbox
- outline:SetPos( 5, 90 )// Set the position
- outline:SetValue(false)
- outline:SetText("Outline")
- local ChangeColor = vgui.Create( "DButton", CrossHairTab )
- ChangeColor:SetText( "Change Color" )
- ChangeColor:SetTextColor( Color( 255, 255, 255 ) )
- ChangeColor:SetPos( CrossHairTab:GetWide() / 2 + 100 / 2, 110 )
- ChangeColor:SetSize( 100, 30 )
- ChangeColor.Paint = function( self, w, h )
- draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 255 ) ) -- Draw a blue button
- end
- ChangeColor.DoClick = function()
- --Start creating color changer menu
- local Memes = vgui.Create( "DFrame" )
- Memes:SetTitle( "Color Changer" )
- Memes:SetSize( 300, 300 )
- Memes:Center()
- Memes:MakePopup()
- Memes:ShowCloseButton(false)
- Memes.Paint = function( self, w, h )
- draw.RoundedBox( 0, 0, 0, w, h, Color( 40, 40, 40, 255 ) )
- end
- local closeButton = vgui.Create( "DButton", Memes )
- closeButton:SetText( "X" )
- closeButton:SetTextColor( Color( 255, 0, 0 ) )
- closeButton:SetPos( CrossHairTab:GetWide() - 20, 0 )
- closeButton:SetSize( 20, 20 )
- closeButton.Paint = function( self, w, h )
- draw.RoundedBox( 0, 0, 0, w, h, Color( 50, 50, 50, 255 ) )
- end
- closeButton.DoClick = function()
- Memes:SetVisible(false)
- end
- --Color Picker
- local ColorPicker = vgui.Create( "DColorMixer", Memes )
- ColorPicker:SetSize( 200, 200 )
- ColorPicker:SetPos( 50, 50 )
- ColorPicker:SetPalette( true )
- ColorPicker:SetAlphaBar( false )
- ColorPicker:SetWangs( true )
- ColorPicker:SetColor( Color( 255, 255, 255 ) )
- local ConfirmColor = vgui.Create( "DButton", Memes )
- ConfirmColor:SetText( "Pick Color" )
- ConfirmColor:SetSize( 90, 30 )
- ConfirmColor:SetPos( 100, Memes:GetTall() - 40 )
- ConfirmColor:SetTextColor(Color (255, 255, 255))
- ConfirmColor.Paint = function( self, w, h )
- draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 255 ) ) -- Draw a blue button
- ConfirmColor.DoClick = function()
- ChosenColor = ColorPicker:GetColor() -- Grabs the red, green, blue, and alpha values as a Color object
- ChosenColor2 = ColorPicker:GetColor()
- end
- end
- end
- -- --Adding Sheets
- --Drawing Crosshair
- hook.Add( "HUDPaint", "Crosshair", function()
- if DermaCheckboxone:GetChecked() == true then
- if DermaCheckboxtwo:GetChecked() == true then
- ChosenColor = HSVToColor(RealTime()*120%360,1,1)
- else if ChosenColor2 != nil then
- ChosenColor = ChosenColor2
- else
- ChosenColor = Color(255, 255, 255, 255)
- end
- end
- --draw.RoundedBox( 0, ScrW() / 2 - 1, ScrH() / 2, 5, 5, ChosenColor )
- /*
- surface.DrawCircle( ScrW() / 2, ScrH() / 2, size - 1, 0, 0, 0, 255)
- surface.DrawCircle( ScrW() / 2, ScrH() / 2, size + 1, 0, 0, 0, 255)
- surface.DrawCircle( ScrW() / 2, ScrH() / 2, size, ChosenColor)
- */
- surface.SetDrawColor(0, 0, 0, 255)
- if outline:GetChecked() == true then
- width = width + 2
- surface.DrawOutlinedRect( ScrW() / 2 - width / 2, ScrH() / 2 + gap - 1, width, size + 2)
- surface.DrawOutlinedRect( ScrW() / 2 - width / 2, ScrH() / 2 - gap - size, width, size + 2)
- surface.DrawOutlinedRect( ScrW() / 2 + gap - 2, ScrH() / 2 - width / 2 + 1, size + 2, width)
- surface.DrawOutlinedRect( ScrW() / 2 - gap - size - 1, ScrH() / 2 - width / 2 + 1, size + 2, width)
- width = width - 2
- end
- surface.SetDrawColor( ChosenColor )
- surface.DrawRect( ScrW() / 2 - width / 2, ScrH() / 2 + gap, width, size)
- surface.DrawRect( ScrW() / 2 - width / 2, ScrH() / 2 - gap - size + 1, width, size)
- surface.DrawRect( ScrW() / 2 + gap - 1, ScrH() / 2 - width / 2 + 1, size, width)
- surface.DrawRect( ScrW() / 2 - gap - size, ScrH() / 2 - width / 2 + 1, size, width)
- end
- end)
- local function showcrosshairmenu()
- CrossHairTab:SetVisible(true)
- end
- concommand.Add("crosshairchanger", showcrosshairmenu)
- --Third Person
- local ThirdPersonTab = vgui.Create("DPanel",CrossHairTab)
- ThirdPersonTab:Dock(FILL)
- CrossHairTab:AddSheet("Third Person", ThirdPersonTab, "icon16/user.png",false,false, "Change your Third Person Settings")
- local x_slider = vgui.Create( "DNumSlider", ThirdPersonTab)
- x_slider:Dock(TOP)
- x_slider:DockMargin(5,0,5,0)
- x_slider:SetConVar( "thirdperson_x" )
- x_slider:SetMin( -100 )
- x_slider:SetMax( 100 )
- x_slider:SetText( "X" )
- x_slider.Label:SetTextInset( 5, 0 )
- x_slider.TextArea:SetTextColor( Color(200, 200, 200, 255) )
- x_slider.PerformLayout = function()
- x_slider.Label:SizeToContents()
- x_slider.Label:SetWide( x_slider.Label:GetWide() +5 )
- end
- local y_slider = vgui.Create( "DNumSlider", ThirdPersonTab)
- y_slider:Dock(TOP)
- y_slider:DockMargin(5,0,5,0)
- y_slider:SetConVar( "thirdperson_y" )
- y_slider:SetMin( -100 )
- y_slider:SetMax( 100 )
- y_slider:SetText( "Y" )
- y_slider.Label:SetTextInset( 5, 0 )
- y_slider.TextArea:SetTextColor( Color(200, 200, 200, 255) )
- y_slider.PerformLayout = function()
- y_slider.Label:SizeToContents()
- y_slider.Label:SetWide( y_slider.Label:GetWide() +5 )
- end
- local z_slider = vgui.Create( "DNumSlider", ThirdPersonTab)
- z_slider:Dock(TOP)
- z_slider:DockMargin(5,0,5,0)
- z_slider:SetConVar( "thirdperson_z" )
- z_slider:SetMin( -100 )
- z_slider:SetMax( 100 )
- z_slider:SetText( "Z" )
- z_slider.Label:SetTextInset( 5, 0 )
- z_slider.TextArea:SetTextColor( Color(200, 200, 200, 255) )
- z_slider.PerformLayout = function()
- z_slider.Label:SizeToContents()
- z_slider.Label:SetWide( z_slider.Label:GetWide() +5 )
- end
- local toggle_btn = vgui.Create("DButton", ThirdPersonTab)
- toggle_btn:Dock(TOP)
- toggle_btn:DockMargin(5,5,5,5)
- toggle_btn:SetText("Toggle thirdperson")
- toggle_btn.DoClick = function(self)
- RunConsoleCommand("gm_showhelp")
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement