Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.39 KB | None | 0 0
  1. --local ChosenColor = Color(255, 255, 255, 255)
  2. --local ChosenColor2 = Color(255, 255, 255, 255)
  3. gap = 0
  4. width = 1
  5. size = 10
  6.  
  7. local x_axis = CreateClientConVar("thirdperson_x", "60", true)
  8. local y_axis = CreateClientConVar("thirdperson_y", "10", true)
  9. local z_axis = CreateClientConVar("thirdperson_z", "0", true)
  10.  
  11. local third_person_state = false
  12.  
  13. hook.Add( "HUDShouldDraw", "ThirdPerson.HUDShouldDraw", function( name )
  14. if name == "CHudCrosshair" then return !third_person_state end
  15. end )
  16.  
  17. local function check_player_valid()
  18. local ply = LocalPlayer()
  19. if not ply:Alive() or ply:IsRagdoll() or ply:InVehicle() then
  20. return false
  21. else
  22. return true
  23. end
  24. end
  25.  
  26. hook.Add("CalcView", "ThirdPerson.CalcView", function(ply, pos, angles, fov)
  27. if third_person_state and ply:Alive() then
  28. local view = {}
  29. view.origin = pos-(angles:Forward()*x_axis:GetInt())-(angles:Right()*z_axis:GetInt())-(angles:Up()*y_axis:GetInt())
  30. view.angles = angles
  31. view.fov = fov
  32.  
  33. local traceData = {}
  34. traceData.start = pos
  35. traceData.endpos = traceData.start + angles:Forward() * -x_axis:GetInt()
  36. traceData.endpos = traceData.endpos + angles:Right() * -z_axis:GetInt()
  37. traceData.endpos = traceData.endpos + angles:Up() * y_axis:GetInt()
  38. traceData.filter = ply
  39.  
  40. local trace = util.TraceLine(traceData)
  41.  
  42. pos = trace.HitPos
  43.  
  44. if trace.Fraction < 1.0 then
  45. pos = pos + trace.HitNormal * 5
  46. end
  47.  
  48. view.origin = pos
  49.  
  50. return view
  51.  
  52. end
  53. end)
  54.  
  55. hook.Add("ShouldDrawLocalPlayer", "ThirdPerson.ShouldDrawLocalPlayer", function()
  56. return third_person_state
  57. end)
  58.  
  59. usermessage.Hook("ThirdPerson.Toggle", function(ply, cmd, args)
  60. if not third_person_state then
  61. third_person_state = true
  62. else
  63. third_person_state = false
  64. end
  65. end)
  66. hook.Remove("HUDPaint", "Crosshair")
  67.  
  68. hook.Add("OnPlayerChat", "crossHairChanger", function(ply,strText,bTeam,bDead)
  69. local strText = string.lower(strText)
  70. if(strText == "!settings") then
  71. --Background blur
  72. local blur = Material("pp/blurscreen")
  73.  
  74. local function DrawBlur(panel,amount)
  75. local x, y = panel:LocalToScreen(0,0)
  76. surface.SetDrawColor(255,255,255)
  77. surface.SetMaterial(blur)
  78. for i = 1,3 do
  79. blur:SetFloat("$blur", (i/3) * (amount or 6))
  80. blur:Recompute()
  81. render.UpdateScreenEffectTexture()
  82. surface.DrawTexturedRect(x * -1, y * -1, ScrW(), ScrH())
  83. end
  84. end
  85.  
  86.  
  87.  
  88. --Main settings frame
  89. local SettingFrame = vgui.Create("DFrame")
  90. SettingFrame:SetTitle("Settings")
  91. SettingFrame:SetSize(600,300)
  92. SettingFrame:MakePopup()
  93. SettingFrame:Center()
  94. SettingFrame:SetBackgroundBlur(true)
  95. SettingFrame:SetVisible(true)
  96. SettingFrame:SetDraggable(true)
  97. SettingFrame:ShowCloseButton(false)
  98. SettingFrame.Paint = function(self, w, h)
  99. Derma_DrawBackgroundBlur(self)
  100. draw.RoundedBox(0,0,0,w,h,Color(40,40,40,255))
  101. --DrawBlur(self,2)
  102.  
  103. end
  104.  
  105. local closeButton = vgui.Create( "DButton", SettingFrame )
  106. closeButton:SetText( "X" )
  107. closeButton:SetTextColor( Color( 255, 0, 0 ) )
  108. closeButton:SetPos( SettingFrame:GetWide() - 20, 0 )
  109. closeButton:SetSize( 20, 20 )
  110. closeButton.Paint = function( self, w, h )
  111. draw.RoundedBox( 0, 0, 0, w, h, Color( 50, 50, 50, 255 ) )
  112. end
  113. closeButton.DoClick = function()
  114. SettingFrame:SetVisible(false)
  115. end
  116.  
  117.  
  118.  
  119. local CrossHairTab = vgui.Create("DPropertySheet",SettingFrame)
  120. CrossHairTab:Dock(FILL)
  121. CrossHairTab:AddSheet("Crosshair", CrossHairTab, "icon16/user.png",false,false, "Change your Crosshair")
  122.  
  123. --Crosshair
  124.  
  125.  
  126.  
  127.  
  128. local SizeSlider = vgui.Create( "DNumSlider", CrossHairTab )
  129. SizeSlider:SetPos( 10, 150 ) // Set the position
  130. SizeSlider:SetSize( 200, 15 ) // Set the size
  131. SizeSlider:SetText( "Size" ) // Set the text above the slider
  132. SizeSlider:SetMin( 1 ) // Set the minimum number you can slide to
  133. SizeSlider:SetMax( 100 ) // Set the maximum number you can slide to
  134. SizeSlider:SetValue( size )
  135. SizeSlider:SetDecimals( 0 ) // Decimal places - zero for whole number
  136. SizeSlider.OnValueChanged = function( panel, value )
  137. size = math.Round(value)
  138. end
  139.  
  140. local GapSizeSlider = vgui.Create( "DNumSlider", CrossHairTab )
  141. GapSizeSlider:SetPos(10,210)
  142. GapSizeSlider:SetSize( 200, 15 ) // Set the size
  143. GapSizeSlider:SetText( "Gap Size" ) // Set the text above the slider
  144. GapSizeSlider:SetMin( 0 ) // Set the minimum number you can slide to
  145. GapSizeSlider:SetMax( 100 ) // Set the maximum number you can slide to
  146. GapSizeSlider:SetValue( gap )
  147. GapSizeSlider:SetDecimals( 0 ) // Decimal places - zero for whole number
  148. GapSizeSlider.OnValueChanged = function( panel, value )
  149. gap = math.Round(value)
  150. end
  151.  
  152. local WidthSlider = vgui.Create( "DNumSlider", CrossHairTab )
  153. WidthSlider:SetPos( 10, 180 ) // Set the position
  154. WidthSlider:SetSize( 200, 15 ) // Set the size
  155. WidthSlider:SetText( "Width" ) // Set the text above the slider
  156. WidthSlider:SetMin( 1 ) // Set the minimum number you can slide to
  157. WidthSlider:SetMax( 200 ) // Set the maximum number you can slide to
  158. WidthSlider:SetValue( width )
  159. WidthSlider:SetDecimals( 0 ) // Decimal places - zero for whole number
  160. WidthSlider.OnValueChanged = function( panel, value )
  161. width = math.Round(value)
  162. end
  163.  
  164.  
  165.  
  166.  
  167. local DermaCheckboxone = vgui.Create( "DCheckBoxLabel" , CrossHairTab )// Create the checkbox
  168. DermaCheckboxone:SetPos( 5, 50 )// Set the position
  169. DermaCheckboxone:SetValue(false)
  170. DermaCheckboxone:SetText("Enable Crosshair")
  171.  
  172. /*
  173. local Text = vgui.Create( "DLabel", CrosshairChanger )
  174. Text:SetPos( 25, 50 )
  175. Text:SetSize( 100, 15)
  176. Text:SetText( "Enable Crosshair" )
  177. */
  178. /*
  179. if DermaCheckboxone:GetChecked() == false then
  180. print("Not checked")
  181. end
  182. */
  183.  
  184. local DermaCheckboxtwo = vgui.Create( "DCheckBoxLabel" , CrossHairTab )// Create the checkbox
  185. DermaCheckboxtwo:SetPos( 5, 70 )// Set the position
  186. DermaCheckboxtwo:SetValue(false)
  187. DermaCheckboxtwo:SetText("Rainbow Crosshair")
  188. /*
  189. local Text = vgui.Create( "DLabel", CrosshairChanger )
  190. Text:SetPos( 25, 70 )
  191. Text:SetSize( 100, 15)
  192. Text:SetText( "Rainbow Crosshair" )
  193. */
  194.  
  195. local outline = vgui.Create( "DCheckBoxLabel" , CrossHairTab )// Create the checkbox
  196. outline:SetPos( 5, 90 )// Set the position
  197. outline:SetValue(false)
  198. outline:SetText("Outline")
  199.  
  200.  
  201.  
  202. local ChangeColor = vgui.Create( "DButton", CrossHairTab )
  203. ChangeColor:SetText( "Change Color" )
  204. ChangeColor:SetTextColor( Color( 255, 255, 255 ) )
  205. ChangeColor:SetPos( CrossHairTab:GetWide() / 2 + 100 / 2, 110 )
  206. ChangeColor:SetSize( 100, 30 )
  207. ChangeColor.Paint = function( self, w, h )
  208. draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 255 ) ) -- Draw a blue button
  209. end
  210. ChangeColor.DoClick = function()
  211. --Start creating color changer menu
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222. local Memes = vgui.Create( "DFrame" )
  223. Memes:SetTitle( "Color Changer" )
  224. Memes:SetSize( 300, 300 )
  225. Memes:Center()
  226. Memes:MakePopup()
  227. Memes:ShowCloseButton(false)
  228. Memes.Paint = function( self, w, h )
  229. draw.RoundedBox( 0, 0, 0, w, h, Color( 40, 40, 40, 255 ) )
  230. end
  231.  
  232. local closeButton = vgui.Create( "DButton", Memes )
  233. closeButton:SetText( "X" )
  234. closeButton:SetTextColor( Color( 255, 0, 0 ) )
  235. closeButton:SetPos( CrossHairTab:GetWide() - 20, 0 )
  236. closeButton:SetSize( 20, 20 )
  237. closeButton.Paint = function( self, w, h )
  238. draw.RoundedBox( 0, 0, 0, w, h, Color( 50, 50, 50, 255 ) )
  239. end
  240. closeButton.DoClick = function()
  241. Memes:SetVisible(false)
  242. end
  243.  
  244. --Color Picker
  245.  
  246. local ColorPicker = vgui.Create( "DColorMixer", Memes )
  247. ColorPicker:SetSize( 200, 200 )
  248. ColorPicker:SetPos( 50, 50 )
  249. ColorPicker:SetPalette( true )
  250. ColorPicker:SetAlphaBar( false )
  251. ColorPicker:SetWangs( true )
  252. ColorPicker:SetColor( Color( 255, 255, 255 ) )
  253.  
  254.  
  255. local ConfirmColor = vgui.Create( "DButton", Memes )
  256. ConfirmColor:SetText( "Pick Color" )
  257. ConfirmColor:SetSize( 90, 30 )
  258. ConfirmColor:SetPos( 100, Memes:GetTall() - 40 )
  259. ConfirmColor:SetTextColor(Color (255, 255, 255))
  260. ConfirmColor.Paint = function( self, w, h )
  261. draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 255 ) ) -- Draw a blue button
  262. ConfirmColor.DoClick = function()
  263. ChosenColor = ColorPicker:GetColor() -- Grabs the red, green, blue, and alpha values as a Color object
  264. ChosenColor2 = ColorPicker:GetColor()
  265. end
  266. end
  267. end
  268. -- --Adding Sheets
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277. --Drawing Crosshair
  278.  
  279. hook.Add( "HUDPaint", "Crosshair", function()
  280. if DermaCheckboxone:GetChecked() == true then
  281.  
  282.  
  283. if DermaCheckboxtwo:GetChecked() == true then
  284. ChosenColor = HSVToColor(RealTime()*120%360,1,1)
  285. else if ChosenColor2 != nil then
  286. ChosenColor = ChosenColor2
  287. else
  288. ChosenColor = Color(255, 255, 255, 255)
  289. end
  290. end
  291.  
  292. --draw.RoundedBox( 0, ScrW() / 2 - 1, ScrH() / 2, 5, 5, ChosenColor )
  293.  
  294. /*
  295. surface.DrawCircle( ScrW() / 2, ScrH() / 2, size - 1, 0, 0, 0, 255)
  296. surface.DrawCircle( ScrW() / 2, ScrH() / 2, size + 1, 0, 0, 0, 255)
  297. surface.DrawCircle( ScrW() / 2, ScrH() / 2, size, ChosenColor)
  298. */
  299. surface.SetDrawColor(0, 0, 0, 255)
  300. if outline:GetChecked() == true then
  301. width = width + 2
  302. surface.DrawOutlinedRect( ScrW() / 2 - width / 2, ScrH() / 2 + gap - 1, width, size + 2)
  303. surface.DrawOutlinedRect( ScrW() / 2 - width / 2, ScrH() / 2 - gap - size, width, size + 2)
  304.  
  305. surface.DrawOutlinedRect( ScrW() / 2 + gap - 2, ScrH() / 2 - width / 2 + 1, size + 2, width)
  306. surface.DrawOutlinedRect( ScrW() / 2 - gap - size - 1, ScrH() / 2 - width / 2 + 1, size + 2, width)
  307. width = width - 2
  308. end
  309.  
  310.  
  311.  
  312.  
  313. surface.SetDrawColor( ChosenColor )
  314. surface.DrawRect( ScrW() / 2 - width / 2, ScrH() / 2 + gap, width, size)
  315. surface.DrawRect( ScrW() / 2 - width / 2, ScrH() / 2 - gap - size + 1, width, size)
  316.  
  317. surface.DrawRect( ScrW() / 2 + gap - 1, ScrH() / 2 - width / 2 + 1, size, width)
  318. surface.DrawRect( ScrW() / 2 - gap - size, ScrH() / 2 - width / 2 + 1, size, width)
  319.  
  320.  
  321. end
  322. end)
  323.  
  324.  
  325. local function showcrosshairmenu()
  326. CrossHairTab:SetVisible(true)
  327. end
  328.  
  329. concommand.Add("crosshairchanger", showcrosshairmenu)
  330.  
  331. --Third Person
  332.  
  333. local ThirdPersonTab = vgui.Create("DPanel",CrossHairTab)
  334. ThirdPersonTab:Dock(FILL)
  335. CrossHairTab:AddSheet("Third Person", ThirdPersonTab, "icon16/user.png",false,false, "Change your Third Person Settings")
  336.  
  337. local x_slider = vgui.Create( "DNumSlider", ThirdPersonTab)
  338. x_slider:Dock(TOP)
  339. x_slider:DockMargin(5,0,5,0)
  340. x_slider:SetConVar( "thirdperson_x" )
  341. x_slider:SetMin( -100 )
  342. x_slider:SetMax( 100 )
  343. x_slider:SetText( "X" )
  344. x_slider.Label:SetTextInset( 5, 0 )
  345. x_slider.TextArea:SetTextColor( Color(200, 200, 200, 255) )
  346. x_slider.PerformLayout = function()
  347. x_slider.Label:SizeToContents()
  348. x_slider.Label:SetWide( x_slider.Label:GetWide() +5 )
  349. end
  350.  
  351. local y_slider = vgui.Create( "DNumSlider", ThirdPersonTab)
  352. y_slider:Dock(TOP)
  353. y_slider:DockMargin(5,0,5,0)
  354. y_slider:SetConVar( "thirdperson_y" )
  355. y_slider:SetMin( -100 )
  356. y_slider:SetMax( 100 )
  357. y_slider:SetText( "Y" )
  358. y_slider.Label:SetTextInset( 5, 0 )
  359. y_slider.TextArea:SetTextColor( Color(200, 200, 200, 255) )
  360. y_slider.PerformLayout = function()
  361. y_slider.Label:SizeToContents()
  362. y_slider.Label:SetWide( y_slider.Label:GetWide() +5 )
  363. end
  364.  
  365. local z_slider = vgui.Create( "DNumSlider", ThirdPersonTab)
  366. z_slider:Dock(TOP)
  367. z_slider:DockMargin(5,0,5,0)
  368. z_slider:SetConVar( "thirdperson_z" )
  369. z_slider:SetMin( -100 )
  370. z_slider:SetMax( 100 )
  371. z_slider:SetText( "Z" )
  372. z_slider.Label:SetTextInset( 5, 0 )
  373. z_slider.TextArea:SetTextColor( Color(200, 200, 200, 255) )
  374. z_slider.PerformLayout = function()
  375. z_slider.Label:SizeToContents()
  376. z_slider.Label:SetWide( z_slider.Label:GetWide() +5 )
  377. end
  378.  
  379. local toggle_btn = vgui.Create("DButton", ThirdPersonTab)
  380. toggle_btn:Dock(TOP)
  381. toggle_btn:DockMargin(5,5,5,5)
  382. toggle_btn:SetText("Toggle thirdperson")
  383. toggle_btn.DoClick = function(self)
  384. RunConsoleCommand("gm_showhelp")
  385. end
  386.  
  387.  
  388.  
  389. end
  390.  
  391.  
  392.  
  393. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement