Advertisement
Ralph_von

Untitled

Nov 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.72 KB | None | 0 0
  1. if (!SW.EnableScoreboard) then return end
  2.  
  3. local PANEL = { }
  4. local cl = Material("ggui/star_wars/close.png")
  5. local lowRes = ScrH() <= 720
  6.  
  7. for k , v in pairs(player.GetAll()) do
  8. v.Scoreboard = nil
  9. end
  10.  
  11. function PANEL:Init()
  12. self:SetSize(lowRes and 906 or 1280 , lowRes and 488 or 720)
  13. self:Center()
  14. self:SetTitle("")
  15. self:MakePopup()
  16. self:SetDraggable(false)
  17. self:ShowCloseButton(false)
  18. self.cl = vgui.Create("DButton" , self)
  19. self.cl:SetSize(16 , 16)
  20. self.cl:SetPos(self:GetWide() - 42 , 18)
  21. self.cl:SetText("")
  22.  
  23. self.cl.DoClick = function()
  24. self:Hide()
  25. end
  26.  
  27. self.cl.Paint = function(s , w , h)
  28. surface.SetMaterial(cl)
  29. surface.SetDrawColor(s:IsHovered() and Color(218 , 198 , 0) or Color(0 , 198 , 218))
  30. surface.DrawTexturedRect(0 , 0 , w , h)
  31. end
  32.  
  33. self.List = vgui.Create("DScrollPanel" , self)
  34. self.List:SetSize(lowRes and 860 or 1172 , lowRes and 385 or 550)
  35. self.List:SetPos(lowRes and 24 or 48 , lowRes and 70 or 104)
  36. self.List.Players = { }
  37. self:ReCreate()
  38. self:SkinScrollbar(self.List:GetVBar())
  39. end
  40.  
  41. function PANEL:SkinScrollbar(sbar)
  42. sbar:SetWide(13)
  43.  
  44. function sbar:Paint(w , h)
  45. draw.RoundedBox(0 , 1 , 2 , w , h , Color(20 , 20 , 20 , 20))
  46. end
  47.  
  48. function sbar.btnUp:Paint(w , h)
  49. draw.RoundedBox(0 , 1 , 0 , w , h , Color(3 , 96 , 108))
  50. end
  51.  
  52. function sbar.btnDown:Paint(w , h)
  53. draw.RoundedBox(0 , 1 , 0 , w , h , Color(3 , 95 , 108))
  54. end
  55.  
  56. function sbar.btnGrip:Paint(w , h)
  57. draw.RoundedBox(0 , 1 , 0 , w , h , Color(3 , 65 , 88))
  58. end
  59. end
  60.  
  61. PANEL.NextPos = 0
  62. PANEL.SortMode = 1
  63. PANEL.SortOuts = { "Name" , "Kills" , "Deaths" , "Ping" , "Job" }
  64. PANEL.Inverse = false
  65.  
  66. function PANEL:ReCreate()
  67. self.k = #self.List.Players
  68. self.i = self.k
  69.  
  70. for k , v in pairs(self.List.Players) do
  71. if (v.IsOn) then
  72. v:SetSize(self.List:GetWide() , 24)
  73. v.Avatar:SetPlayer(v.Player , 16)
  74. v.Avatar:SetPos(2 , 3)
  75. v.Avatar:SetSize(16 , 16)
  76. v.IsOn = false
  77. end
  78.  
  79. if (v._selected) then
  80. v._selected = false
  81. v:SetSize(self.List:GetWide() , 64)
  82. v.IsOn = true
  83. self.i = k
  84. end
  85. end
  86.  
  87. for k , v in pairs(self.List.Players) do
  88. v:SetPos(0 , 24 * (k - 1) + (self.i < k and 40 or 0))
  89. end
  90. end
  91.  
  92. PANEL.i = 0
  93.  
  94. function PANEL:Think()
  95. for k , v in pairs(player.GetAll()) do
  96. if (not IsValid(v.Scoreboard)) then
  97. local ply = vgui.Create("swPlayer" , self.List)
  98. ply:SetSize(self:GetParent():GetWide() , 24)
  99. ply:SetPlayer(v)
  100. ply:SetPos(0 , 24 * (k - 1))
  101. v.Scoreboard = ply
  102. table.insert(self.List.Players , ply)
  103. table.sort(self.List.Players , function(a , b)
  104. if IsValid(a.Player) and IsValid(b.Player) && a.Player:Nick() != b.Player:Nick() then
  105. local an,_ = string.gsub(a.Player:Nick(),'%W', '')
  106. local bn,_ = string.gsub(b.Player:Nick(),'%W', '')
  107. return an <= bn
  108. else
  109. return true
  110. end
  111. end)
  112.  
  113. for l , it in pairs(self.List.Players) do
  114. if (it.Player == LocalPlayer()) then
  115. self.List.Players[ l ] = self.List.Players[ 1 ]
  116. self.List.Players[ 1 ] = it
  117. end
  118. end
  119.  
  120. self:ReCreate()
  121.  
  122. return
  123. end
  124. end
  125.  
  126. if (#self.List.Players ~= #player.GetAll()) then
  127. for k , v in pairs(self.List.Players) do
  128. v:Remove()
  129. end
  130.  
  131. self.List.Players = { }
  132. self:ReCreate()
  133. end
  134.  
  135. for k , v in pairs(self.List.Players) do
  136. if (not IsValid(v.Player)) then
  137. v:Remove()
  138. end
  139. end
  140. end
  141.  
  142. local bg = lowRes and Material("ggui/star_wars/sb.png") or surface.GetTextureID("ggui/star_wars/scoreboard")
  143. local rowSize = 0
  144. local initialRow = lowRes and 48 or 72
  145. local bannerTop = lowRes and 53 or 82
  146.  
  147. function PANEL:Paint(w , h)
  148. rowSize = w / 5
  149. surface.SetDrawColor(color_white)
  150.  
  151. if (lowRes) then
  152. surface.SetMaterial(bg)
  153. else
  154. surface.SetTexture(bg)
  155. end
  156.  
  157. surface.DrawTexturedRect(0 , 0 , lowRes and 1024 or 2048 , lowRes and 512 or 1024)
  158. draw.SimpleTextOutlined("Scoreboard" , lowRes and "sw_ui_24" or "sw_ui_32" , w / 2 , lowRes and 16 or 36 , Color(0 , 150 , 0) , TEXT_ALIGN_CENTER , TEXT_ALIGN_CENTER , 1 , Color(0 , 79 , 0))
  159. draw.SimpleTextOutlined(#player.GetAll() .. "/" .. game.MaxPlayers() , "old_republic_24" , w - 38 , h - (lowRes and 22 or 34) , Color(176 , 226 , 235) , TEXT_ALIGN_RIGHT , TEXT_ALIGN_CENTER , 1 , Color(96 , 146 , 155))
  160. draw.SimpleText("Player Name" , "sw_ui_18b" , initialRow , bannerTop , Color(176 , 226 , 235) , TEXT_ALIGN_LEFT , TEXT_ALIGN_CENTER)
  161. draw.SimpleText("Player Name" , "sw_ui_18" , initialRow , bannerTop , Color(176 , 226 , 235) , TEXT_ALIGN_LEFT , TEXT_ALIGN_CENTER)
  162. draw.SimpleText("Kills" , "sw_ui_18b" , initialRow + rowSize , bannerTop , Color(176 , 226 , 235) , TEXT_ALIGN_LEFT , TEXT_ALIGN_CENTER)
  163. draw.SimpleText("Kills" , "sw_ui_18" , initialRow + rowSize , bannerTop , Color(176 , 226 , 235) , TEXT_ALIGN_LEFT , TEXT_ALIGN_CENTER)
  164. draw.SimpleText("Deaths" , "sw_ui_18b" , initialRow + rowSize * 2 , bannerTop , Color(176 , 226 , 235) , TEXT_ALIGN_LEFT , TEXT_ALIGN_CENTER)
  165. draw.SimpleText("Deaths" , "sw_ui_18" , initialRow + rowSize * 2 , bannerTop , Color(176 , 226 , 235) , TEXT_ALIGN_LEFT , TEXT_ALIGN_CENTER)
  166. draw.SimpleText("Job" , "sw_ui_18b" , initialRow + rowSize * 3 , bannerTop , Color(176 , 226 , 235) , TEXT_ALIGN_LEFT , TEXT_ALIGN_CENTER)
  167. draw.SimpleText("Job" , "sw_ui_18" , initialRow + rowSize * 3 , bannerTop , Color(176 , 226 , 235) , TEXT_ALIGN_LEFT , TEXT_ALIGN_CENTER)
  168. draw.SimpleText("Ping" , "sw_ui_18b" , initialRow + rowSize * 4 , bannerTop , Color(176 , 226 , 235) , TEXT_ALIGN_LEFT , TEXT_ALIGN_CENTER)
  169. draw.SimpleText("Ping" , "sw_ui_18" , initialRow + rowSize * 4 , bannerTop , Color(176 , 226 , 235) , TEXT_ALIGN_LEFT , TEXT_ALIGN_CENTER)
  170.  
  171. if(not input.IsKeyDown(KEY_TAB)) then
  172. self:Hide()
  173. end
  174. end
  175.  
  176. derma.DefineControl("swScoreboard" , "Scoreboard" , PANEL , "DFrame")
  177. local PLY = { }
  178. PLY.Name = ""
  179. PLY.Kills = 0
  180. PLY.Deaths = 0
  181. PLY.Job = ""
  182. local dg = surface.GetTextureID("vgui/gradient_down")
  183. local dgb = surface.GetTextureID("vgui/gradient_up")
  184.  
  185. function PLY:Init()
  186. self.Avatar = vgui.Create("AvatarImage" , self)
  187. self.Avatar:SetPos(2 , 3)
  188. self.Avatar:SetSize(16 , 16)
  189. self:SetText("")
  190. end
  191.  
  192. function PLY:SetPlayer(ply , k)
  193. self.Player = ply
  194. self.k = k
  195. self.Avatar:SetPlayer(ply , 16)
  196.  
  197. if (ply:IsBot()) then
  198. self.Name = ply:SteamName()
  199. else
  200. self.Name = ply:getDarkRPVar("rpname" , ply:SteamName())
  201. end
  202. end
  203.  
  204. function PLY:Paint(w , h)
  205. surface.SetDrawColor(82 , 191 , 230 , 10)
  206. surface.DrawRect(4 , h - 2 , w , 1)
  207.  
  208. if (IsValid(self.Player)) then
  209. if (self:IsHovered() or self.IsOn) then
  210. surface.SetTexture(dg)
  211. surface.SetDrawColor(self.IsOn and Color(125 , 100 , 3) or Color(3 , 65 , 88))
  212. surface.DrawTexturedRect(0 , 0 , w , h - 3)
  213. surface.SetTexture(dgb)
  214. surface.SetDrawColor(self.IsOn and Color(125 , 100 , 3 , 100) or Color(3 , 65 , 88 , 100))
  215. surface.DrawTexturedRect(0 , 0 , w , h - 3)
  216. elseif (not self.Player:Alive()) then
  217. surface.SetTexture(dg)
  218. surface.SetDrawColor(Color(48 , 9 , 9))
  219. surface.DrawTexturedRect(0 , 0 , w , h - 3)
  220. surface.SetTexture(dgb)
  221. surface.SetDrawColor(Color(48 , 9 , 9 , 100))
  222. surface.DrawTexturedRect(0 , 0 , w , h - 3)
  223. end
  224.  
  225. draw.SimpleText(self.Player:Nick() , "sw_ui_18b" , initialRow - 24 - (not lowRes and 24 or 0) , 2 , Color(82 , 191 , 230) , TEXT_ALIGN_LEFT , TEXT_ALIGN_TOP)
  226. draw.SimpleText(self.Player:Nick() , "sw_ui_18" , initialRow - 24 - (not lowRes and 24 or 0) , 2 , Color(82 , 191 , 230) , TEXT_ALIGN_LEFT , TEXT_ALIGN_TOP)
  227. draw.SimpleText(self.Kills , "sw_ui_18b" , initialRow - 24 + rowSize - (not lowRes and 8 or 8) , 2 , Color(82 , 191 , 230) , TEXT_ALIGN_CENTER , TEXT_ALIGN_TOP)
  228. draw.SimpleText(self.Kills , "sw_ui_18" , initialRow - 24 + rowSize - (not lowRes and 8 or 8) , 2 , Color(82 , 191 , 230) , TEXT_ALIGN_CENTER , TEXT_ALIGN_TOP)
  229. draw.SimpleText(self.Deaths , "sw_ui_18b" , initialRow - 24 + rowSize * 2 , 2 , Color(82 , 191 , 230) , TEXT_ALIGN_CENTER , TEXT_ALIGN_TOP)
  230. draw.SimpleText(self.Deaths , "sw_ui_18" , initialRow - 24 + rowSize * 2 , 2 , Color(82 , 191 , 230) , TEXT_ALIGN_CENTER , TEXT_ALIGN_TOP)
  231. draw.SimpleText(self.Job , "sw_ui_18b" , initialRow - 32 + rowSize * 3 , 2 , Color(82 , 191 , 230) , TEXT_ALIGN_CENTER , TEXT_ALIGN_TOP)
  232. draw.SimpleText(self.Job , "sw_ui_18" , initialRow - 32 + rowSize * 3 , 2 , Color(82 , 191 , 230) , TEXT_ALIGN_CENTER , TEXT_ALIGN_TOP)
  233. draw.SimpleText(self.Player:Ping() , "sw_ui_18b" , initialRow - 32 + rowSize * 4 , 2 , Color(82 , 191 , 230) , TEXT_ALIGN_CENTER , TEXT_ALIGN_TOP)
  234. draw.SimpleText(self.Player:Ping() , "sw_ui_18" , initialRow - 32 + rowSize * 4 , 2 , Color(82 , 191 , 230) , TEXT_ALIGN_CENTER , TEXT_ALIGN_TOP)
  235.  
  236. if (self.IsOn) then
  237. draw.SimpleText("SteamID:" , "sw_ui_18" , 64 , 22 , Color(255 , 255 , 255) , TEXT_ALIGN_LEFT , TEXT_ALIGN_TOP)
  238. draw.SimpleText("SteamID64:" , "sw_ui_18" , 64 , 38 , Color(255 , 255 , 255) , TEXT_ALIGN_LEFT , TEXT_ALIGN_TOP)
  239. draw.SimpleText(self.Player:SteamID() , "sw_ui_18" , 158 , 22 , Color(255 , 255 , 255 , 100) , TEXT_ALIGN_LEFT , TEXT_ALIGN_TOP)
  240. draw.SimpleText(self.Player:SteamID64() , "sw_ui_18" , 158 , 38 , Color(255 , 255 , 255 , 100) , TEXT_ALIGN_LEFT , TEXT_ALIGN_TOP)
  241. draw.SimpleText("Money:" , "sw_ui_18" , w / 2 , 22 , Color(255 , 255 , 255) , TEXT_ALIGN_LEFT , TEXT_ALIGN_TOP)
  242. draw.SimpleText(DarkRP.formatMoney(self.Player:getDarkRPVar("money" , 0)) , "sw_ui_18" , w / 2 + 58 , 22 , Color(100 , 255 , 100 , 200) , TEXT_ALIGN_LEFT , TEXT_ALIGN_TOP)
  243. draw.SimpleText("Steam Name:" , "sw_ui_18" , w / 2 , 38 , Color(255 , 255 , 255) , TEXT_ALIGN_LEFT , TEXT_ALIGN_TOP)
  244. draw.SimpleText(self.Player:SteamName() , "sw_ui_18" , w / 2 + 105 , 38 , Color(255 , 255 , 100 , 200) , TEXT_ALIGN_LEFT , TEXT_ALIGN_TOP)
  245. end
  246. else
  247. return
  248. end
  249.  
  250. self.Kills = self.Player:Frags()
  251. self.Deaths = self.Player:Deaths()
  252. self.Job = team.GetName(self.Player:Team())
  253. end
  254.  
  255. function PLY:OnMousePressed(c)
  256. if (c == 108 and self.IsOn) then
  257. self:SetSize(806 , 24)
  258. self.Avatar:SetSize(16 , 16)
  259. self.Avatar:SetPos(2 , 3)
  260. self.Avatar:SetPlayer(self.Player , 16)
  261. self:GetParent():GetParent():GetParent():ReCreate()
  262. elseif (c == 107) then
  263. self:DoClick()
  264. end
  265. end
  266.  
  267. function PLY:DoClick()
  268. if (self.IsOn) then
  269. local menu = DermaMenu()
  270.  
  271. menu:AddOption("Copy SteamID" , function()
  272. SetClipboardText(self.Player:SteamID())
  273. end):SetIcon("icon16/book.png")
  274.  
  275. menu:AddOption("Copy SteamID64" , function()
  276. SetClipboardText(self.Player:SteamID64())
  277. end):SetIcon("icon16/computer.png")
  278.  
  279. menu:AddOption("Copy Name" , function()
  280. SetClipboardText(self.Player:SteamName())
  281. end):SetIcon("icon16/user_suit.png")
  282.  
  283. menu:AddOption("Copy RPName" , function()
  284. SetClipboardText(self.Player:Nick())
  285. end):SetIcon("icon16/group.png")
  286.  
  287. menu:AddOption("Open profile" , function()
  288. gui.OpenURL("https://steamcommunity.com/profiles/" .. self.Player:SteamID64())
  289. end):SetIcon("icon16/world.png")
  290.  
  291. menu:Open()
  292.  
  293. return
  294. end
  295.  
  296. self._selected = true
  297. self.Avatar:SetPlayer(self.Player , 32)
  298. self.Avatar:SetSize(32 , 32)
  299. self.Avatar:SetPos(22 , 24)
  300. self:GetParent():GetParent():GetParent():ReCreate()
  301. end
  302.  
  303. derma.DefineControl("swPlayer" , "Scoreboard" , PLY , "DButton")
  304.  
  305. if (IsValid(SW.Score)) then
  306. SW.Score:Remove()
  307. end
  308.  
  309. hook.Add("ScoreboardShow" , "SW.Scoreboard" , function()
  310. if (not IsValid(SW.Score)) then
  311. SW.Score = vgui.Create("swScoreboard")
  312. else
  313. SW.Score:Show()
  314. end
  315.  
  316. return false
  317. end)
  318.  
  319. hook.Add("ScoreboardHide" , "SW.Scoreboard" , function()
  320. if (IsValid(SW.Score)) then
  321. SW.Score:Hide()
  322. end
  323. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement