Advertisement
Guest User

scoreboard

a guest
Jun 22nd, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.62 KB | None | 0 0
  1. local PANEL = {}
  2.  
  3. surface.CreateFont("ScoreboardBig", {
  4. size = ScreenScale(25),
  5. weight = 800,
  6. antialias = true,
  7. font = "Harabara",
  8. outline = true
  9. } )
  10.  
  11. surface.CreateFont("ScoreboardMedium", {
  12. size = ScreenScale(12),
  13. weight = 600,
  14. antialias = true,
  15. font = "Harabara",
  16. outline = true
  17. } )
  18.  
  19. surface.CreateFont("ScoreboardSmall", {
  20. size = ScreenScale(10),
  21. weight = 600,
  22. antialias = false,
  23. font = "Harabara",
  24. outline = true
  25. } )
  26.  
  27. surface.CreateFont("ScoreboardTiny", {
  28. size = ScreenScale(8),
  29. weight = 200,
  30. antialias = true,
  31. font = "Harabara",
  32. } )
  33.  
  34.  
  35. function PANEL:Init()
  36. self:SetSize(ScrW() * 0.44, ScrH() * 0.78)
  37. self:Center()
  38.  
  39. self.body = self:Add("DPanel")
  40. self.body:Dock(FILL)
  41. self.body:DockMargin(5, 5, 5, 5)
  42.  
  43. self.body.Paint = function(body, w, h)
  44. draw.RoundedBox( 4, 0, 0, w, h, Color(255, 255, 255, 20) )
  45. end
  46.  
  47. self.header = self.body:Add("DPanel")
  48. self.header:Dock(TOP)
  49. self.header:SetTall(self:GetTall() * 0.15)
  50. self.header:DockMargin(4, 4, 4, 4)
  51.  
  52. self.footer = self.body:Add("DPanel")
  53. self.footer:Dock(BOTTOM)
  54. self.footer:SetTall(38)
  55. self.footer:DockMargin(4, 4, 4, 4)
  56.  
  57. self.header.Paint = function(header, w, h)
  58. draw.RoundedBox( 4, 0, 0, w, h, Color(37, 85, 132, 200) )
  59. end
  60.  
  61. self.header.title = self.header:Add("DLabel")
  62. self.header.title:SetText("SubZero Deathrun")
  63. self.header.title:SetFont("ScoreboardBig")
  64. self.header.title:SetContentAlignment(5)
  65. self.header.title:Dock(FILL)
  66.  
  67. self.header.hostName = self.header:Add("DLabel")
  68. self.header.hostName:SetText( "A Small Gmod Community" )
  69. self.header.hostName:SetFont("ScoreboardSmall")
  70. self.header.hostName:SetContentAlignment(5)
  71. self.header.hostName:DockMargin(3, 3, 3, 5)
  72. self.header.hostName:Dock(BOTTOM)
  73.  
  74. self.footer.Paint = function(footer, w, h)
  75. draw.RoundedBox( 4, 0, 0,w ,h, Color(37, 85, 132, 200) )
  76. end
  77. self.footer.spectators = self.footer:Add("DLabel")
  78. self.footer.spectators:SetText( "SPECTATORS :" )
  79. self.footer.spectators:SetFont("ScoreboardSmall")
  80. self.footer.spectators:DockMargin(5, 5, 5, 5)
  81. self.footer.spectators:Dock(FILL)
  82.  
  83. self.run = self.body:Add("ScoreboardTeam")
  84. self.run:SetWide( (self:GetWide() * 0.5) - 15 )
  85. self.run:DockMargin(5, 5, 5, 5)
  86. self.run:Dock(LEFT)
  87. self.run:SetTeam(TEAM_RUNNER)
  88.  
  89. self.death = self.body:Add("ScoreboardTeam")
  90. self.death:SetWide( (self:GetWide() * 0.5) - 15 )
  91. self.death:DockMargin(5, 5, 5, 5)
  92. self.death:Dock(RIGHT)
  93. self.death:SetTeam(TEAM_DEATH)
  94. end
  95.  
  96. function PANEL:Paint(w, h)
  97. draw.RoundedBox( 4, 0, 0, w, h, Color(255, 255, 255, 100) ) --BackPanel For Scoreboard (Behind Everything)
  98. end
  99.  
  100. vgui.Register("Scoreboard", PANEL, "DPanel")
  101.  
  102. local PANEL = {}
  103.  
  104. function PANEL:Init()
  105. self.title = self:Add("DLabel")
  106. self.title:Dock(TOP)
  107. self.title:DockMargin(5, 5, 5, 5)
  108. self.title:SetFont("ScoreboardMedium")
  109. self.title:SetText("N/A")
  110. self.title:SizeToContents()
  111.  
  112. self.scroll = self:Add("DScrollPanel")
  113. self.scroll:Dock(FILL)
  114. self.scroll:DockMargin(5, 5, 5, 5)
  115.  
  116. self.scroll.Paint = function(scroll, w, h)
  117. draw.RoundedBox( 4, 0, 0, w, h, Color(255, 255, 255, 200) ) ---Behind Individual Player Tags
  118. end
  119. end
  120.  
  121. function PANEL:SetTeam(index)
  122. self.team = index
  123. self.title:SetTextColor( team.GetColor(index) )
  124. end
  125.  
  126. function PANEL:Think()
  127. if (self.team) then
  128. local players = team.NumPlayers(self.team)
  129. local name = team.GetName(self.team)
  130.  
  131. if (players == 1) then
  132. suffix = " Player"
  133. end
  134.  
  135. self.title:SetText(name)
  136. if self.team == TEAM_RUNNER then
  137. self.title:SetText("RUNNERS")
  138. self.title:SetTextColor( Color(255, 255, 255, 255) )
  139. self.title:SetContentAlignment(5)
  140. elseif self.team == TEAM_DEATH then
  141. self.title:SetText("DEATH")
  142. self.title:SetTextColor( Color(255, 255, 255, 255) )
  143. self.title:SetContentAlignment(5)
  144. end
  145.  
  146. for k, v in SortedPairs( player.GetAll() ) do
  147. if (!IsValid(v.ts_Row) and v:Team() == self.team) then
  148. local row = self.scroll:Add("ScoreboardPlayer")
  149. row:Dock(TOP)
  150. row:DockMargin(3, 3, 3, 0)
  151. row:SetPlayer(v)
  152.  
  153. v.ts_Row = row
  154.  
  155. self.scroll:AddItem(row)
  156. end
  157. end
  158. end
  159. end
  160.  
  161. function PANEL:Paint(w, h)
  162. draw.RoundedBox( 2, 0, 0, w, h, Color(37, 85, 132, 200) )
  163. end
  164.  
  165. vgui.Register("ScoreboardTeam", PANEL, "DPanel")
  166.  
  167.  
  168.  
  169. local PANEL = {}
  170.  
  171. function PANEL:Init()
  172. self:SetTall(36)
  173.  
  174. if self.player:IsUserGroup("owner") then
  175. self.rank = self:Add("DLabel")
  176. self.rank:SetFont("ScoreboardTiny")
  177. self.rank:Dock(FILL)
  178. self.rank:DockMargin(5,5,5,5)
  179. self.rank:SizeToContents()
  180. self.rank:SetTextColor( Color(255, 255, 255, 255))
  181. end
  182.  
  183.  
  184. self.avatar = self:Add("AvatarImage")
  185. self.avatar:Dock(LEFT)
  186. self.avatar:DockMargin(3, 3, 3, 3)
  187. self.avatar:SetSize(32, 32)
  188.  
  189. self.avatar.click = self.avatar:Add("DButton")
  190. self.avatar.click:Dock(FILL)
  191. self.avatar.click:SetText("")
  192.  
  193. self.avatar.click.Paint = function() end
  194.  
  195. self.avatar.click.DoClick = function(avatarButton)
  196. local menu = DermaMenu()
  197.  
  198. menu:AddOption("View Profile", function()
  199. if ( IsValid(self.player) ) then
  200. self.player:ShowProfile()
  201. end
  202. end)
  203.  
  204. local text = "Mute"
  205.  
  206. if (self.player.ts_Muted) then
  207. text = "Unmute"
  208. end
  209.  
  210. menu:AddOption(text, function()
  211. if ( IsValid(self.player) ) then
  212. self.player.ts_Muted = !self.player.ts_Muted
  213. self.player:SetMuted(self.player.ts_Muted)
  214. end
  215. end)
  216.  
  217. menu:Open()
  218. end
  219.  
  220. self.name = self:Add("DLabel")
  221. self.name:SetFont("ScoreboardSmall")
  222. self.name:SetText("N/A")
  223. self.name:Dock(LEFT)
  224. self.name:DockMargin(5, 5, 5, 5)
  225. self.name:SizeToContents()
  226. self.name:SetTextColor( Color(255, 255, 255, 255) )
  227.  
  228. self.ping = self:Add("DLabel")
  229. self.ping:SetFont("ScoreboardMedium")
  230. self.ping:SetText("")
  231. self.ping:DockMargin(5, 5, 5, 5)
  232. self.ping:Dock(RIGHT)
  233. self.ping:SizeToContents()
  234. end
  235.  
  236. function PANEL:SetPlayer(client)
  237. if ( IsValid(client) ) then
  238. self.player = client
  239. self.team = client:Team()
  240. self.avatar:SetPlayer(client)
  241. self.initialized = true
  242. end
  243. end
  244.  
  245. function PANEL:Think()
  246. if ( self.initialized and !IsValid(self.player) ) then
  247. self:Remove()
  248. elseif (self.initialized) then
  249. if ( self.team != self.player:Team() ) then
  250. self:Remove()
  251. end
  252.  
  253. local amount = math.Clamp(self.player:Ping() / 200, 0, 1)
  254.  
  255. self.ping:SetTextColor( Color( (255 * amount), 220 - (255 * amount), (1 - amount) * 75, 200) )
  256. self.ping:SetText( self.player:Ping() )
  257. self.ping:SizeToContents()
  258.  
  259. if ( self.player:Name() != self.name:GetText() ) then
  260. self.name:SetText( self.player:Name() )
  261. self.name:SizeToContents()
  262. end
  263. end
  264. end
  265.  
  266. function PANEL:Paint(w, h)
  267. //draw.RoundedBox( 4, 0, 0, w, h, Color(255, 255, 255, 225) ) --Individual Player Tags
  268. if self.player:IsUserGroup("owner") then
  269. draw.RoundedBox( 4, 0, 0, w, h, Color(0, 0, 0, 200) )
  270. elseif self.player:IsUserGroup("superadmin") then
  271. draw.RoundedBox( 4, 0, 0, w, h, Color(240, 45, 45, 200) )
  272. elseif self.player:IsUserGroup("admin") then
  273. draw.RoundedBox( 4, 0, 0, w, h, Color(45, 123, 240, 200) )
  274. elseif self.player:IsUserGroup("moderator") then
  275. draw.RoundedBox( 4, 0, 0, w, h, Color(45, 240, 84, 200) )
  276. elseif self.player:IsUserGroup("vip")then
  277. draw.RoundedBox( 4, 0, 0, w, h, Color(240, 201, 45, 200) )
  278. elseif self.player:IsUserGroup("user") then
  279. draw.RoundedBox( 4, 0, 0, w, h, Color(255, 255, 255, 200) )
  280. end
  281. end
  282.  
  283. vgui.Register("ScoreboardPlayer", PANEL, "DPanel")
  284.  
  285. local SCOREBOARD
  286.  
  287. function GM:ScoreboardShow()
  288. gui.EnableScreenClicker(true)
  289.  
  290. SCOREBOARD = vgui.Create("Scoreboard")
  291. end
  292.  
  293. function GM:ScoreboardHide()
  294. gui.EnableScreenClicker(false)
  295.  
  296. if not SCOREBOARD then return end
  297.  
  298. SCOREBOARD:Remove()
  299. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement