Advertisement
Guest User

Crosshair

a guest
Aug 18th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.52 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. hook.Remove("HUDPaint", "Crosshair")
  8.  
  9.  
  10. local CrosshairChanger = vgui.Create( "DFrame" )
  11. CrosshairChanger:SetTitle( "Crosshair Customizer" )
  12. CrosshairChanger:SetSize( 300, 300 )
  13. CrosshairChanger:Center()
  14. CrosshairChanger:MakePopup()
  15. CrosshairChanger:ShowCloseButton(false)
  16. CrosshairChanger:SetVisible(false)
  17. CrosshairChanger.Paint = function( self, w, h )
  18. draw.RoundedBox( 0, 0, 0, w, h, Color( 40, 40, 40, 255 ) )
  19. end
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. local closeButton = vgui.Create( "DButton", CrosshairChanger )
  29. closeButton:SetText( "X" )
  30. closeButton:SetTextColor( Color( 255, 0, 0 ) )
  31. closeButton:SetPos( CrosshairChanger:GetWide() - 20, 0 )
  32. closeButton:SetSize( 20, 20 )
  33. closeButton.Paint = function( self, w, h )
  34. draw.RoundedBox( 0, 0, 0, w, h, Color( 50, 50, 50, 255 ) )
  35. end
  36. closeButton.DoClick = function()
  37. CrosshairChanger:SetVisible(false)
  38. end
  39.  
  40. local SizeSlider = vgui.Create( "DNumSlider", CrosshairChanger )
  41. SizeSlider:SetPos( 10, 150 ) // Set the position
  42. SizeSlider:SetSize( 200, 15 ) // Set the size
  43. SizeSlider:SetText( "Size" ) // Set the text above the slider
  44. SizeSlider:SetMin( 1 ) // Set the minimum number you can slide to
  45. SizeSlider:SetMax( 100 ) // Set the maximum number you can slide to
  46. SizeSlider:SetValue( size )
  47. SizeSlider:SetDecimals( 0 ) // Decimal places - zero for whole number
  48. SizeSlider.OnValueChanged = function( panel, value )
  49. size = math.Round(value)
  50. end
  51.  
  52. local GapSizeSlider = vgui.Create( "DNumSlider", CrosshairChanger )
  53. GapSizeSlider:SetPos( 10, 165 ) // Set the position
  54. GapSizeSlider:SetSize( 200, 15 ) // Set the size
  55. GapSizeSlider:SetText( "Gap Size" ) // Set the text above the slider
  56. GapSizeSlider:SetMin( 0 ) // Set the minimum number you can slide to
  57. GapSizeSlider:SetMax( 100 ) // Set the maximum number you can slide to
  58. GapSizeSlider:SetValue( gap )
  59. GapSizeSlider:SetDecimals( 0 ) // Decimal places - zero for whole number
  60. GapSizeSlider.OnValueChanged = function( panel, value )
  61. gap = math.Round(value)
  62. end
  63.  
  64. local WidthSlider = vgui.Create( "DNumSlider", CrosshairChanger )
  65. WidthSlider:SetPos( 10, 180 ) // Set the position
  66. WidthSlider:SetSize( 200, 15 ) // Set the size
  67. WidthSlider:SetText( "Width" ) // Set the text above the slider
  68. WidthSlider:SetMin( 1 ) // Set the minimum number you can slide to
  69. WidthSlider:SetMax( 200 ) // Set the maximum number you can slide to
  70. WidthSlider:SetValue( width )
  71. WidthSlider:SetDecimals( 0 ) // Decimal places - zero for whole number
  72. WidthSlider.OnValueChanged = function( panel, value )
  73. width = math.Round(value)
  74. end
  75.  
  76.  
  77.  
  78.  
  79. local DermaCheckboxone = vgui.Create( "DCheckBoxLabel" , CrosshairChanger )// Create the checkbox
  80. DermaCheckboxone:SetPos( 5, 50 )// Set the position
  81. DermaCheckboxone:SetValue(false)
  82. DermaCheckboxone:SetText("Enable Crosshair")
  83.  
  84. /*
  85. local Text = vgui.Create( "DLabel", CrosshairChanger )
  86. Text:SetPos( 25, 50 )
  87. Text:SetSize( 100, 15)
  88. Text:SetText( "Enable Crosshair" )
  89. */
  90. /*
  91. if DermaCheckboxone:GetChecked() == false then
  92. print("Not checked")
  93. end
  94. */
  95.  
  96. local DermaCheckboxtwo = vgui.Create( "DCheckBoxLabel" , CrosshairChanger )// Create the checkbox
  97. DermaCheckboxtwo:SetPos( 5, 70 )// Set the position
  98. DermaCheckboxtwo:SetValue(false)
  99. DermaCheckboxtwo:SetText("Rainbow Crosshair")
  100. /*
  101. local Text = vgui.Create( "DLabel", CrosshairChanger )
  102. Text:SetPos( 25, 70 )
  103. Text:SetSize( 100, 15)
  104. Text:SetText( "Rainbow Crosshair" )
  105. */
  106.  
  107. local outline = vgui.Create( "DCheckBoxLabel" , CrosshairChanger )// Create the checkbox
  108. outline:SetPos( 5, 90 )// Set the position
  109. outline:SetValue(false)
  110. outline:SetText("Outline")
  111.  
  112.  
  113.  
  114. local ChangeColor = vgui.Create( "DButton", CrosshairChanger )
  115. ChangeColor:SetText( "Change Color" )
  116. ChangeColor:SetTextColor( Color( 255, 255, 255 ) )
  117. ChangeColor:SetPos( CrosshairChanger:GetWide() / 2 - 100 / 2, 110 )
  118. ChangeColor:SetSize( 100, 30 )
  119. ChangeColor.Paint = function( self, w, h )
  120. draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 255 ) ) -- Draw a blue button
  121. end
  122. ChangeColor.DoClick = function()
  123. --Start creating color changer menu
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. local Memes = vgui.Create( "DFrame" )
  135. Memes:SetTitle( "Color Changer" )
  136. Memes:SetSize( 300, 300 )
  137. Memes:Center()
  138. Memes:MakePopup()
  139. Memes:ShowCloseButton(false)
  140. Memes.Paint = function( self, w, h )
  141. draw.RoundedBox( 0, 0, 0, w, h, Color( 40, 40, 40, 255 ) )
  142. end
  143.  
  144. local closeButton = vgui.Create( "DButton", Memes )
  145. closeButton:SetText( "X" )
  146. closeButton:SetTextColor( Color( 255, 0, 0 ) )
  147. closeButton:SetPos( CrosshairChanger:GetWide() - 20, 0 )
  148. closeButton:SetSize( 20, 20 )
  149. closeButton.Paint = function( self, w, h )
  150. draw.RoundedBox( 0, 0, 0, w, h, Color( 50, 50, 50, 255 ) )
  151. end
  152. closeButton.DoClick = function()
  153. Memes:SetVisible(false)
  154. end
  155.  
  156.  
  157.  
  158. local ColorPicker = vgui.Create( "DColorMixer", Memes )
  159. ColorPicker:SetSize( 200, 200 )
  160. ColorPicker:SetPos( 50, 50 )
  161. ColorPicker:SetPalette( true )
  162. ColorPicker:SetAlphaBar( false )
  163. ColorPicker:SetWangs( true )
  164. ColorPicker:SetColor( Color( 255, 255, 255 ) )
  165.  
  166. local ConfirmColor = vgui.Create( "DButton", Memes )
  167. ConfirmColor:SetText( "Pick Color" )
  168. ConfirmColor:SetSize( 90, 30 )
  169. ConfirmColor:SetPos( 100, Memes:GetTall() - 40 )
  170. ConfirmColor:SetTextColor(Color (255, 255, 255))
  171. ConfirmColor.Paint = function( self, w, h )
  172. draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 255 ) ) -- Draw a blue button
  173. ConfirmColor.DoClick = function()
  174. ChosenColor = ColorPicker:GetColor() -- Grabs the red, green, blue, and alpha values as a Color object
  175. ChosenColor2 = ColorPicker:GetColor()
  176. end
  177. end
  178. end
  179.  
  180.  
  181. hook.Add( "HUDPaint", "Crosshair", function()
  182. if DermaCheckboxone:GetChecked() == true then
  183.  
  184.  
  185. if DermaCheckboxtwo:GetChecked() == true then
  186. ChosenColor = HSVToColor(RealTime()*120%360,1,1)
  187. else if ChosenColor2 != nil then
  188. ChosenColor = ChosenColor2
  189. else
  190. ChosenColor = Color(255, 255, 255, 255)
  191. end
  192. end
  193.  
  194. --draw.RoundedBox( 0, ScrW() / 2 - 1, ScrH() / 2, 5, 5, ChosenColor )
  195.  
  196. /*
  197. surface.DrawCircle( ScrW() / 2, ScrH() / 2, size - 1, 0, 0, 0, 255)
  198. surface.DrawCircle( ScrW() / 2, ScrH() / 2, size + 1, 0, 0, 0, 255)
  199. surface.DrawCircle( ScrW() / 2, ScrH() / 2, size, ChosenColor)
  200. */
  201. surface.SetDrawColor(0, 0, 0, 255)
  202. if outline:GetChecked() == true then
  203. width = width + 2
  204. surface.DrawOutlinedRect( ScrW() / 2 - width / 2, ScrH() / 2 + gap - 1, width, size + 2)
  205. surface.DrawOutlinedRect( ScrW() / 2 - width / 2, ScrH() / 2 - gap - size, width, size + 2)
  206.  
  207. surface.DrawOutlinedRect( ScrW() / 2 + gap - 2, ScrH() / 2 - width / 2 + 1, size + 2, width)
  208. surface.DrawOutlinedRect( ScrW() / 2 - gap - size - 1, ScrH() / 2 - width / 2 + 1, size + 2, width)
  209. width = width - 2
  210. end
  211.  
  212.  
  213.  
  214.  
  215. surface.SetDrawColor( ChosenColor )
  216. surface.DrawRect( ScrW() / 2 - width / 2, ScrH() / 2 + gap, width, size)
  217. surface.DrawRect( ScrW() / 2 - width / 2, ScrH() / 2 - gap - size + 1, width, size)
  218.  
  219. surface.DrawRect( ScrW() / 2 + gap - 1, ScrH() / 2 - width / 2 + 1, size, width)
  220. surface.DrawRect( ScrW() / 2 - gap - size, ScrH() / 2 - width / 2 + 1, size, width)
  221.  
  222.  
  223. end
  224. end)
  225.  
  226.  
  227. local function showcrosshairmenu()
  228. CrosshairChanger:SetVisible(true)
  229. end
  230.  
  231. concommand.Add("crosshairchanger", showcrosshairmenu)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement