Advertisement
Guest User

awdadw

a guest
Feb 28th, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.13 KB | None | 0 0
  1. local function IsSearchValuePlayer( ply, value )
  2.  
  3. if string.find( string.lower( ply:Nick() ), string.lower( value ) )
  4. or string.find( ply:SteamID(), value ) then
  5. return true
  6. end
  7. return false
  8.  
  9. end
  10.  
  11. local PANEL = {}
  12.  
  13. function MetroTAB_Open_Players(Parent)
  14. local P = vgui.Create("MetroTAB_Players",Parent)
  15. P:SetSize(Parent:GetWide(),Parent:GetTall())
  16. return P
  17. end
  18. function PANEL:Init()
  19. self:SetDraggable(false)
  20. self:ShowCloseButton(false)
  21. self:SetTitle(" ")
  22. end
  23. function PANEL:Paint()
  24. surface.SetDrawColor( 0,0,0,100 )
  25. surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
  26. end
  27.  
  28. function PANEL:Install()
  29.  
  30. self.ItemList = vgui.Create("DPanelList", self)
  31. self.ItemList:SetPos(0,2)
  32. self.ItemList:SetSize( self:GetWide(), self:GetTall() - 36 )
  33. self.ItemList:SetSpacing(0);
  34. self.ItemList:SetPadding(0);
  35. self.ItemList:EnableVerticalScrollbar(true);
  36. self.ItemList:EnableHorizontal(false);
  37. self.ItemList:PaintListBarC()
  38. self.ItemList.Paint = function(slf)
  39. surface.SetDrawColor( 0,0,0,50 )
  40. surface.DrawRect( 0, 0, slf:GetWide(), slf:GetTall() )
  41. end
  42.  
  43. self.ItemList.teams = {}
  44.  
  45. self.ItemList.Search = function( text )
  46.  
  47. self:UpdateList( text )
  48.  
  49. end
  50.  
  51. local searchBoxBack = vgui.Create( "DPanel", self )
  52. searchBoxBack:SetSize( 200, 28 )
  53. searchBoxBack:SetPos( self:GetWide() - 204, self:GetTall() - 31 )
  54. searchBoxBack.Paint = function( pnl, w, h )
  55.  
  56. surface.SetDrawColor( 20, 20, 20 )
  57. surface.DrawRect( 0, 0, w, h )
  58.  
  59. end
  60.  
  61. local searchBox = vgui.Create( "DTextEntry", searchBoxBack )
  62. searchBox:SetSize( searchBoxBack:GetSize() )
  63. searchBox:SetPos( 0, 0 )
  64. searchBox:SetText( "search..." )
  65.  
  66. searchBox.PaintOver = function( pnl, w, h )
  67.  
  68. surface.SetDrawColor( 0, 0, 0 )
  69. surface.DrawOutlinedRect( 0, 0, w, h )
  70.  
  71. end
  72.  
  73. searchBox.m_FontName = "default"
  74. searchBox.m_colText = Color( 255, 255, 255, 255 )
  75. searchBox.m_colHighlight = Color( 150, 150, 150, 255 )
  76. searchBox.m_colCursor = Color( 255, 255, 255 )
  77.  
  78. searchBox:SetDrawBackground( false )
  79. searchBox:SetDrawBorder( false )
  80.  
  81. --[[
  82. searchBox.Paint = function( pnl, w, h )
  83.  
  84. pnl.frameTime = pnl.frameTime + FrameTime()
  85.  
  86. surface.SetDrawColor( 20, 20, 20 )
  87. surface.DrawRect( 0, 0, w, h )
  88.  
  89. surface.SetFont( "default" )
  90.  
  91. if pnl:IsEditing() then
  92.  
  93. if ( ( pnl.frameTime*1.5 ) % 2 ) < 1 then
  94. surface.SetDrawColor( 255, 255, 255 )
  95. else
  96. surface.SetDrawColor( 255, 255, 255, 0 )
  97. end
  98.  
  99. end
  100.  
  101. local tw, th = surface.GetTextSize( pnl:GetValue() )
  102.  
  103. if ( tw - ( w - 11 ) ) > 0 then
  104. surface.SetTextPos( 4 - ( tw - ( w - 11 ) ), ( h/2 ) - ( th/2 ) )
  105. surface.DrawRect( 4 + tw + 1 - ( tw - ( w - 11 ) ), ( h/2 ) - 6, 2, 12 )
  106. else
  107. surface.SetTextPos( 4, ( h/2 ) - ( th/2 ) )
  108. surface.DrawRect( 4 + tw + 1, ( h/2 ) - 6, 2, 12 )
  109. end
  110.  
  111. surface.SetTextColor( 255, 255, 255 )
  112. surface.DrawText( pnl:GetValue() )
  113.  
  114. surface.SetDrawColor( 20, 20, 20 )
  115. surface.DrawRect( 0, 0, 4, h )
  116. surface.DrawRect( w-4, 0, 4, h )
  117.  
  118. surface.SetDrawColor( 0, 0, 0 )
  119. surface.DrawOutlinedRect( 0, 0, w, h )
  120.  
  121. return false
  122. end]]
  123.  
  124. searchBox.Think = function( pnl )
  125.  
  126. searchBox.m_Skin.Colours.Label.Default = Color( 255, 0, 0, 255 )
  127. end
  128.  
  129. searchBox.OnChange = function( pnl )
  130.  
  131. self.ItemList.Search( pnl:GetValue() )
  132.  
  133. end
  134.  
  135. searchBox.OnGetFocus = function( pnl )
  136. if searchBox:GetValue() == "search..." then
  137. searchBox:SetText( "" )
  138. end
  139. end
  140.  
  141. searchBox.OnLoseFocus = function( pnl )
  142. if searchBox:GetValue() == "" then
  143. searchBox:SetText( "search..." )
  144. end
  145. end
  146.  
  147. self:UpdateList()
  148.  
  149. hook.Add( "PlayerInitialSpawn", "MetroTab PlayerInitialSpawn", function()
  150.  
  151. self.ItemList.Search( searchBox:GetValue() )
  152.  
  153. end)
  154.  
  155. hook.Add( "PlayerDisconnected", "MetroTab PlayerDisconnected", function()
  156.  
  157. self.ItemList.Search( searchBox:GetValue() )
  158.  
  159. end)
  160.  
  161. end
  162.  
  163.  
  164. function PANEL:PlayerClick(target,PlayerBGColor)
  165. self.ItemList:Clear()
  166. local Nick = target:Nick()
  167.  
  168. local function CreateLabel(text)
  169. local Labels = vgui.Create("DPanel")
  170. Labels:SetSize(self.ItemList:GetWide()-20,24)
  171. Labels.Paint = function(slf)
  172. surface.SetDrawColor( 120,120,120,255 )
  173. surface.DrawRect( 0, 0, slf:GetWide(), slf:GetTall() )
  174. draw.SimpleText(text, "RXF2_Treb_S20", 10,2, Color(255,255,255,255))
  175. end
  176. self.ItemList:AddItem(Labels)
  177. return Labels
  178. end
  179.  
  180. local function CreateDarkRPBasicFunc()
  181.  
  182. local Count = 0
  183. for k,v in pairs(FAdmin.ScoreBoard.Player.ActionButtons) do
  184. if v.Visible == true or (type(v.Visible) == "function" and v.Visible(target) == true) then
  185. Count = Count + 1
  186. end
  187. end
  188.  
  189. local BGP = vgui.Create("DPanel")
  190. BGP:SetSize( self.ItemList:GetWide(), math.ceil(Count/4)*55 )
  191. BGP.Paint = function() end
  192.  
  193. local Count = 0
  194. for k,v in pairs(FAdmin.ScoreBoard.Player.ActionButtons) do
  195. if v.Visible == true or (type(v.Visible) == "function" and v.Visible(target) == true) then
  196. Count = Count + 1
  197. local ActionButton = vgui.Create("MetroTAB_CommandButton",BGP)
  198. local name = v.Name
  199. if type(name) == "function" then name = name(target) end
  200. ActionButton:SetSize( self.ItemList:GetWide()/4-5, 50 )
  201. ActionButton:SetPos((Count-1)%4 * (ActionButton:GetWide()+5),math.ceil(Count/4)*55 -50)
  202. ActionButton:SetTexts(name)
  203.  
  204. ActionButton.m_Image = vgui.Create("DImage", ActionButton)
  205. ActionButton.m_Image:SetPos(2,2)
  206. ActionButton.m_Image:SetSize(36,36)
  207. ActionButton.SetImage = function(self,Mat, bckp)
  208. self.m_Image:SetImage(Mat, bckp)
  209. end
  210.  
  211. ActionButton.m_Image2 = vgui.Create("DImage", ActionButton)
  212. ActionButton.m_Image2:SetPos(2,2)
  213. ActionButton.m_Image2:SetSize(36,36)
  214. ActionButton.SetImage2 = function(self,Mat, bckp)
  215. self.m_Image2:SetImage(Mat, bckp)
  216. end
  217.  
  218. if type(v.Image) == "string" then
  219. ActionButton:SetImage(v.Image or "icon16/exclamation")
  220. elseif type(v.Image) == "table" then
  221. ActionButton:SetImage(v.Image[1])
  222. if v.Image[2] then ActionButton:SetImage2(v.Image[2]) end
  223. elseif type(v.Image) == "function" then
  224. local img1, img2 = v.Image(LocalPlayer())
  225. ActionButton:SetImage(img1)
  226. if img2 then ActionButton:SetImage2(img2) end
  227. else
  228. ActionButton:SetImage("icon16/exclamation")
  229. end
  230.  
  231. ActionButton.SetText = function(self,text)
  232. self:SetTexts(text)
  233. end
  234. ActionButton.Click = function(self)
  235. return v.Action(target, self)
  236. end
  237. if v.OnButtonCreated then
  238. v.OnButtonCreated(target, ActionButton)
  239. end
  240. end
  241.  
  242.  
  243. end
  244. self.ItemList:AddItem(BGP)
  245. end
  246.  
  247.  
  248.  
  249. CreateLabel("Manage Player")
  250.  
  251. local TNick = target:Nick()
  252. local BGP = vgui.Create("MetroTAB_DSWButton")
  253. BGP:SetSize(self.ItemList:GetWide()/2 - 5,50)
  254. BGP:SetBoarderColor(Color(0,0,0,0))
  255. BGP.FXCol = Color(120,120,120,50)
  256. BGP.PaintOverlay = function(slf)
  257. surface.SetDrawColor( PlayerBGColor )
  258. surface.DrawRect( 0, 0, slf:GetWide(), slf:GetTall() )
  259. if target:IsValid() then
  260. draw.SimpleText(TNick, "RXF2_TrebOut_S30", 80,0, Color(255,255,255,255))
  261.  
  262. if slf:IsHovered() then
  263. draw.SimpleText(target:SteamID(), "RXF2_TrebOut_S20", 80,25, Color(200,200,200,150))
  264. else
  265. local UG = target:GetNWString("usergroup")
  266. draw.SimpleText(team.GetName(target:Team()) .. " , " .. UG, "RXF2_TrebOut_S20", 80,25, Color(200,200,200,150))
  267. end
  268. draw.SimpleText(target:Frags() .. " Kills", "RXF2_TrebOut_S20", slf:GetWide()-10,5, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
  269. draw.SimpleText(target:Deaths() .. " Deaths", "RXF2_TrebOut_S20", slf:GetWide()-10,25, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
  270.  
  271. if slf:IsHovered() then
  272. if LocalPlayer():IsAdmin() or LocalPlayer():IsSuperAdmin() then
  273. draw.SimpleText("Money", "RXF2_TrebOut_S20", slf:GetWide()-180,5, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
  274. draw.SimpleText((target.DarkRPVars.Money or 0), "RXF2_TrebOut_S20", slf:GetWide()-180,25, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
  275. else
  276. draw.SimpleText("Ping", "RXF2_TrebOut_S20", slf:GetWide()-180,5, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
  277. draw.SimpleText(target:Ping(), "RXF2_TrebOut_S20", slf:GetWide()-180,25, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
  278. end
  279. else
  280. draw.SimpleText("Ping", "RXF2_TrebOut_S20", slf:GetWide()-180,5, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
  281. draw.SimpleText(target:Ping(), "RXF2_TrebOut_S20", slf:GetWide()-180,25, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
  282. end
  283. end
  284. end
  285.  
  286. local icon = vgui.Create("ModelImage",BGP)
  287. icon:SetSize(BGP:GetTall(),BGP:GetTall())
  288. icon:SetModel(target:GetModel())
  289.  
  290. self.ItemList:AddItem(BGP)
  291.  
  292.  
  293. CreateLabel("DarkRP Basic")
  294. CreateDarkRPBasicFunc()
  295.  
  296. end
  297.  
  298. function PANEL:UpdateList( plysearch )
  299.  
  300. self.ItemList:Clear()
  301. local List = self.ItemList
  302.  
  303. local function AddTeam( TEAM, plysearch )
  304.  
  305. local TeamName = team.GetName(TEAM)
  306. local TeamColor = team.GetColor(TEAM)
  307. local PlayerBGColor = team.GetColor(TEAM)
  308. local TeamPlayers = table.Count(team.GetPlayers(TEAM))
  309.  
  310. if plysearch and plysearch != "" then
  311. local player = nil
  312. for _, ply in pairs( team.GetPlayers( TEAM ) ) do
  313. if IsSearchValuePlayer( ply, plysearch ) then
  314. player = ply
  315. end
  316. end
  317. if not player then return end
  318. end
  319.  
  320. PlayerBGColor.a = 20
  321.  
  322. local BG = vgui.Create("DPanel")
  323. BG:SetSize(List:GetWide(),32 + 100)
  324. BG.Paint = function(slf) end
  325.  
  326. --[[
  327. local BGP = vgui.Create("MetroTAB_DSWButton",BG)
  328. BGP:SetSize(BG:GetWide(),30)
  329. BGP:SetBoarderColor(Color(0,0,0,0))
  330. BGP.PaintOverlay = function(slf)
  331. surface.SetDrawColor( TeamColor )
  332. surface.DrawRect( 0, 0, slf:GetWide(), slf:GetTall() )
  333.  
  334. draw.SimpleText(TeamName .. " ( " .. TeamPlayers .. " ) ", "RXF2_TrebOut_S25", 20,0, Color(255,255,255,255))
  335. end
  336.  
  337. function BGP:Click()
  338. end
  339. ]]
  340.  
  341. local PlayerList = vgui.Create("DPanel", BG)
  342. PlayerList:SetPos(0,0)
  343. PlayerList:SetSize(BG:GetWide(),54)
  344. PlayerList.list = {}
  345. PlayerList.Paint = function(slf)
  346. surface.SetDrawColor( 0,0,0,50 )
  347. surface.DrawRect( 0, 0, slf:GetWide(), slf:GetTall() )
  348. end
  349.  
  350. function PlayerList:Update()
  351.  
  352. local spacing = 0
  353. local tall = 0
  354.  
  355. for _, panel in pairs( self.list ) do
  356.  
  357. panel:SetPos( select( 1, panel:GetPos() ), tall )
  358.  
  359. tall = tall + panel:GetTall() + spacing
  360.  
  361. end
  362.  
  363. self:SetTall( tall )
  364. BG:SetTall( tall )
  365.  
  366. local listHeight = 0
  367.  
  368. for k, v in pairs( BG:GetParent():GetChildren() ) do
  369.  
  370. if ispanel( v ) then
  371. listHeight = listHeight + v:GetTall()
  372. end
  373.  
  374. end
  375. BG:GetParent():SetTall( listHeight )
  376.  
  377. end
  378.  
  379. function PlayerList:AddItem( item )
  380.  
  381. if not ispanel( item ) then return end
  382. if table.HasValue( self.list, item ) then return end
  383.  
  384. table.insert( self.list, item )
  385. item:SetParent( self )
  386.  
  387. self:Update()
  388.  
  389. end
  390.  
  391. for k, target in pairs( team.GetPlayers( TEAM ) ) do
  392.  
  393. if plysearch and plysearch != "" then
  394. if !IsSearchValuePlayer( target, plysearch ) then continue end
  395. end
  396.  
  397. local TNick = target:Nick()
  398. local BGP = vgui.Create("MetroTAB_DSWButton")
  399. BGP:SetSize(PlayerList:GetWide() - 4, 32)
  400. BGP:SetPos(2, 0)
  401. BGP:SetBoarderColor(Color(0,0,0,0))
  402. BGP.FXCol = Color(120,120,120,50)
  403. BGP.Money = target:getDarkRPVar("money") or 0
  404. if BGP.Money >= 1000000 then
  405. BGP.Money = string.Comma(math.floor(BGP.Money/1000000)) .. "M"
  406. else
  407. if BGP.Money >= 1000 then
  408. BGP.Money = string.Comma(math.floor(BGP.Money/1000)) .. "K"
  409. end
  410. end
  411.  
  412. BGP.PaintOverlay = function(slf)
  413. surface.SetDrawColor( PlayerBGColor )
  414. surface.DrawRect( 0, 0, slf:GetWide(), slf:GetTall()-2 )
  415.  
  416. if target:IsValid() then
  417. draw.SimpleText(TNick, "RXF2_TrebOut_S26", 80,2, Color(200,200,200,255))
  418.  
  419. local UG = target:GetNWString("usergroup")
  420.  
  421. draw.SimpleText( team.GetName( target:Team() ), "RXF2_TrebOut_S20", (slf:GetWide()/2), 5, Color(200,200,200,150), TEXT_ALIGN_CENTER )
  422.  
  423. draw.SimpleText( "Ping " .. target:Ping(), "RXF2_TrebOut_S20", slf:GetWide() - 15, 5, Color(0,200,255,255), TEXT_ALIGN_RIGHT )
  424.  
  425. --if slf:IsHovered() or slf:IsChildHovered( 1 ) then
  426. if slf.shouldresize then
  427.  
  428. draw.SimpleText(target:SteamID(), "RXF2_TrebOut_S20", 80,25, Color(200,200,200,150))
  429.  
  430. draw.SimpleText( UG, "RXF2_TrebOut_S20", (slf:GetWide()/2), 25, Color(200,200,200,150), TEXT_ALIGN_CENTER )
  431.  
  432. draw.SimpleText( "Kills " .. target:Frags() .. " / " .. target:Deaths() .. " Deaths", "RXF2_TrebOut_S20", slf:GetWide() - (self:GetWide()/4), 25, Color(0,200,255,255), TEXT_ALIGN_CENTER )
  433.  
  434. draw.SimpleText("Wallet $" .. slf.Money, "RXF2_TrebOut_S20", slf:GetWide() - (slf:GetWide()/4), 5, Color(0,200,255,255), TEXT_ALIGN_CENTER)
  435.  
  436. end
  437.  
  438. end
  439. end
  440.  
  441. BGP.OnMousePressed = function(slf,mc)
  442. if mc == MOUSE_RIGHT then
  443. local DM = DermaMenu()
  444. DM:AddOption("Copy Nickname",function() SetClipboardText(target:Nick()) end)
  445. DM:AddOption("Copy SteamID",function() SetClipboardText(target:SteamID()) end)
  446. DM:AddOption("Open Steam Profile page",function() target:ShowProfile() end)
  447. DM:Open()
  448. end
  449. if mc == MOUSE_LEFT then
  450. --self:PlayerClick(target,PlayerBGColor)
  451.  
  452. if slf:IsHovered() or slf:IsChildHovered( 1 ) then
  453. if not slf.shouldresize then
  454. slf:SetActive( true )
  455. slf.shouldresize = true
  456. else
  457. slf:SetActive( false )
  458. slf.shouldresize = false
  459. end
  460. end
  461.  
  462. end
  463. end
  464.  
  465. BGP.playericon = ""
  466. local icon = vgui.Create( "DPanel", BGP )
  467. icon:SetSize( 16, 16 )
  468. icon:SetPos( 58, 7 )
  469. icon.Paint = function( pnl, w, h )
  470.  
  471. if BGP.playericon and BGP.playericon != "" then
  472. surface.SetDrawColor( 255, 255, 255, 255 )
  473. surface.SetMaterial( Material( BGP.playericon ) )
  474. surface.DrawTexturedRect( 0, 0, 16, 16 )
  475. end
  476.  
  477. end
  478.  
  479. local avatar = vgui.Create( "AvatarImage",BGP )
  480. BGP.avatar = avatar
  481. avatar:SetSize( BGP:GetTall()-2, BGP:GetTall()-2 )
  482. avatar:SetPos( BGP:GetPos() )
  483. avatar:SetPlayer( target, 64 )
  484.  
  485. function BGP:SetActive( state )
  486.  
  487. if state then
  488.  
  489. self:SetSize( PlayerList:GetWide() - 4, 52 )
  490.  
  491. local posX, posY = self:GetPos()
  492. self:SetPos( posX, posY + 20 )
  493.  
  494. else
  495.  
  496. self:SetSize( PlayerList:GetWide() - 4, 32 )
  497.  
  498. end
  499.  
  500. self:Update()
  501. PlayerList:Update()
  502.  
  503. end
  504.  
  505. function BGP:Update()
  506.  
  507. avatar:SetSize( self:GetTall()-2, BGP:GetTall()-2 )
  508. avatar:SetPos( 0, 0 )
  509.  
  510. if MetroTAB_Config then
  511.  
  512. BGP.playericon = MetroTAB_Config.Player_Icons[target:SteamID()] or MetroTAB_Config.Rank_Icons[target:GetUserGroup()] or ""
  513.  
  514. end
  515.  
  516. end
  517.  
  518. --[[BGP.Think = function(slf)
  519.  
  520. if slf:IsHovered() or slf:IsChildHovered( 1 ) then
  521. if not slf.shouldresize then
  522. slf:SetActive( true )
  523. slf.shouldresize = true
  524. end
  525. else
  526. if slf.shouldresize then
  527. slf:SetActive( false )
  528. slf.shouldresize = false
  529. end
  530. end
  531.  
  532. end]]
  533.  
  534. PlayerList:AddItem( BGP )
  535. BGP:SetActive( false )
  536.  
  537. end
  538.  
  539. List:AddItem(BG)
  540.  
  541. end
  542.  
  543. local TBIns = {}
  544. for k,v in pairs(player.GetAll()) do
  545. table.insert(TBIns,{P=v,T=v:Team()})
  546. end
  547. table.SortByMember(TBIns, T, function(a, b) return a > b end)
  548.  
  549.  
  550. local TeamsTable = team.GetAllTeams()
  551. TeamsTable[0] = nil
  552. TeamsTable[1001] = nil
  553. TeamsTable[1002] = nil
  554.  
  555. local AvailaleTeams = {}
  556.  
  557. for k,v in pairs(TeamsTable) do
  558. if table.Count(team.GetPlayers(k)) > 0 then
  559. AvailaleTeams[k] = table.Count(team.GetPlayers(k))
  560. end
  561. end
  562.  
  563. for Team,PlayersAmount in pairs( AvailaleTeams ) do
  564. AddTeam( Team, plysearch )
  565. end
  566.  
  567. end
  568.  
  569. vgui.Register("MetroTAB_Players",PANEL,"DFrame")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement