Advertisement
Exho

Untitled

Jun 1st, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. hook.Add("TTTSettingsTabs", "ScoreboardColorMenu", function(dtabs)
  2.  
  3. local padding = dtabs:GetPadding()
  4.  
  5. padding = padding * 2
  6.  
  7. local dsettings = vgui.Create("DPanelList", dtabs)
  8. dsettings:StretchToParent(0,0,padding,0)
  9. dsettings:EnableVerticalScrollbar(true)
  10. dsettings:SetPadding(10)
  11. dsettings:SetSpacing(10)
  12.  
  13. do
  14.  
  15. -- My Sliders
  16. local Red = vgui.Create( "DNumSlider" ) --Red
  17. Red:SetText( "Red" )
  18. Red:SetTooltip( "The RED value of your color" )
  19. Red:SetMin( 1 )
  20. Red:SetMax( 256 )
  21. Red:SetDecimals( 0 )
  22. dsettings:AddItem( Red )
  23. local Green = vgui.Create( "DNumSlider" ) --Green
  24. Green:SetText( "Green" )
  25. Green:SetTooltip( "The GREEN value of your color" )
  26. Green:SetMin( 1 )
  27. Green:SetMax( 256 )
  28. Green:SetDecimals( 0 )
  29. dsettings:AddItem( Green )
  30. local Blue = vgui.Create( "DNumSlider" ) --Blue
  31. Blue:SetText( "Blue" )
  32. Blue:SetTooltip( "The BLUE value of your color" )
  33. Blue:SetMin( 1 )
  34. Blue:SetMax( 256 )
  35. Blue:SetDecimals( 0 )
  36. dsettings:AddItem( Blue )
  37. -- Check box
  38. local Activate = vgui.Create( "DCheckBoxLabel" )
  39. Activate:SetParent( dsettings )
  40. Activate:SetPos( 25, 200 )
  41. Activate:SetText( "Have Colored Name" )
  42. Activate:SetTooltip( "Enable/Disable having a colored scoreboard name" )
  43. Activate:SetConVar( "" )
  44. Activate:SetValue( 0 )
  45. Activate:SizeToContents()
  46.  
  47. local submit = vgui.Create("Button", self)
  48. submit:SetText("Submit")
  49. submit:SetTooltip( "Change the color of your scoreboard name. Takes effect on the next map" )
  50. submit:SetParent( dsettings )
  51. submit:SetSize( 150,30 )
  52. submit:SetPos( 25, 250 )
  53. -- 220 is a good horizontal middle
  54. submit:SetVisible( true )
  55.  
  56. function submit:OnMousePressed()
  57. -- Retrieve and round all the values that were previously selected
  58. redslide = Red:GetValue()
  59. redslide = math.Round(redslide)
  60. greenslide = Green:GetValue()
  61. greenslide = math.Round(greenslide)
  62. blueslide = Blue:GetValue()
  63. blueslide = math.Round(blueslide)
  64.  
  65. -- Put the values into Convars
  66. CreateClientConVar( "ttt_color_red", redslide, true, true )
  67. CreateClientConVar( "ttt_color_green", greenslide, true, true )
  68. CreateClientConVar( "ttt_color_blue", blueslide, true, true )
  69. CreateClientConVar( "ttt_iscolored", "1", true, true )
  70.  
  71. -- Makes them into strings to be used in the console command
  72. redslide = tostring(redslide)
  73. greenslide = tostring(greenslide)
  74. blueslide = tostring(blueslide)
  75.  
  76. RunConsoleCommand( "ttt_color_red", redslide )
  77. RunConsoleCommand( "ttt_color_green", greenslide )
  78. RunConsoleCommand( "ttt_color_blue", blueslide )
  79.  
  80.  
  81. print(redslide, greenslide, blueslide)
  82. end
  83. end
  84.  
  85.  
  86. -- Adds the menu
  87. dtabs:AddSheet("Name Color", dsettings, "icon16/table_gear.png", false, false, "Scoreboard Name Color Settings")
  88. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement