Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function IsSearchValuePlayer( ply, value )
- if string.find( string.lower( ply:Nick() ), string.lower( value ) )
- or string.find( ply:SteamID(), value ) then
- return true
- end
- return false
- end
- local PANEL = {}
- function MetroTAB_Open_Players(Parent)
- local P = vgui.Create("MetroTAB_Players",Parent)
- P:SetSize(Parent:GetWide(),Parent:GetTall())
- return P
- end
- function PANEL:Init()
- self:SetDraggable(false)
- self:ShowCloseButton(false)
- self:SetTitle(" ")
- end
- function PANEL:Paint()
- surface.SetDrawColor( 0,0,0,100 )
- surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
- end
- function PANEL:Install()
- self.ItemList = vgui.Create("DPanelList", self)
- self.ItemList:SetPos(0,2)
- self.ItemList:SetSize( self:GetWide(), self:GetTall() - 36 )
- self.ItemList:SetSpacing(0);
- self.ItemList:SetPadding(0);
- self.ItemList:EnableVerticalScrollbar(true);
- self.ItemList:EnableHorizontal(false);
- self.ItemList:PaintListBarC()
- self.ItemList.Paint = function(slf)
- surface.SetDrawColor( 0,0,0,50 )
- surface.DrawRect( 0, 0, slf:GetWide(), slf:GetTall() )
- end
- self.ItemList.teams = {}
- self.ItemList.Search = function( text )
- self:UpdateList( text )
- end
- local searchBoxBack = vgui.Create( "DPanel", self )
- searchBoxBack:SetSize( 200, 28 )
- searchBoxBack:SetPos( self:GetWide() - 204, self:GetTall() - 31 )
- searchBoxBack.Paint = function( pnl, w, h )
- surface.SetDrawColor( 20, 20, 20 )
- surface.DrawRect( 0, 0, w, h )
- end
- local searchBox = vgui.Create( "DTextEntry", searchBoxBack )
- searchBox:SetSize( searchBoxBack:GetSize() )
- searchBox:SetPos( 0, 0 )
- searchBox:SetText( "search..." )
- searchBox.PaintOver = function( pnl, w, h )
- surface.SetDrawColor( 0, 0, 0 )
- surface.DrawOutlinedRect( 0, 0, w, h )
- end
- searchBox.m_FontName = "default"
- searchBox.m_colText = Color( 255, 255, 255, 255 )
- searchBox.m_colHighlight = Color( 150, 150, 150, 255 )
- searchBox.m_colCursor = Color( 255, 255, 255 )
- searchBox:SetDrawBackground( false )
- searchBox:SetDrawBorder( false )
- --[[
- searchBox.Paint = function( pnl, w, h )
- pnl.frameTime = pnl.frameTime + FrameTime()
- surface.SetDrawColor( 20, 20, 20 )
- surface.DrawRect( 0, 0, w, h )
- surface.SetFont( "default" )
- if pnl:IsEditing() then
- if ( ( pnl.frameTime*1.5 ) % 2 ) < 1 then
- surface.SetDrawColor( 255, 255, 255 )
- else
- surface.SetDrawColor( 255, 255, 255, 0 )
- end
- end
- local tw, th = surface.GetTextSize( pnl:GetValue() )
- if ( tw - ( w - 11 ) ) > 0 then
- surface.SetTextPos( 4 - ( tw - ( w - 11 ) ), ( h/2 ) - ( th/2 ) )
- surface.DrawRect( 4 + tw + 1 - ( tw - ( w - 11 ) ), ( h/2 ) - 6, 2, 12 )
- else
- surface.SetTextPos( 4, ( h/2 ) - ( th/2 ) )
- surface.DrawRect( 4 + tw + 1, ( h/2 ) - 6, 2, 12 )
- end
- surface.SetTextColor( 255, 255, 255 )
- surface.DrawText( pnl:GetValue() )
- surface.SetDrawColor( 20, 20, 20 )
- surface.DrawRect( 0, 0, 4, h )
- surface.DrawRect( w-4, 0, 4, h )
- surface.SetDrawColor( 0, 0, 0 )
- surface.DrawOutlinedRect( 0, 0, w, h )
- return false
- end]]
- searchBox.Think = function( pnl )
- searchBox.m_Skin.Colours.Label.Default = Color( 255, 0, 0, 255 )
- end
- searchBox.OnChange = function( pnl )
- self.ItemList.Search( pnl:GetValue() )
- end
- searchBox.OnGetFocus = function( pnl )
- if searchBox:GetValue() == "search..." then
- searchBox:SetText( "" )
- end
- end
- searchBox.OnLoseFocus = function( pnl )
- if searchBox:GetValue() == "" then
- searchBox:SetText( "search..." )
- end
- end
- self:UpdateList()
- hook.Add( "PlayerInitialSpawn", "MetroTab PlayerInitialSpawn", function()
- self.ItemList.Search( searchBox:GetValue() )
- end)
- hook.Add( "PlayerDisconnected", "MetroTab PlayerDisconnected", function()
- self.ItemList.Search( searchBox:GetValue() )
- end)
- end
- function PANEL:PlayerClick(target,PlayerBGColor)
- self.ItemList:Clear()
- local Nick = target:Nick()
- local function CreateLabel(text)
- local Labels = vgui.Create("DPanel")
- Labels:SetSize(self.ItemList:GetWide()-20,24)
- Labels.Paint = function(slf)
- surface.SetDrawColor( 120,120,120,255 )
- surface.DrawRect( 0, 0, slf:GetWide(), slf:GetTall() )
- draw.SimpleText(text, "RXF2_Treb_S20", 10,2, Color(255,255,255,255))
- end
- self.ItemList:AddItem(Labels)
- return Labels
- end
- local function CreateDarkRPBasicFunc()
- local Count = 0
- for k,v in pairs(FAdmin.ScoreBoard.Player.ActionButtons) do
- if v.Visible == true or (type(v.Visible) == "function" and v.Visible(target) == true) then
- Count = Count + 1
- end
- end
- local BGP = vgui.Create("DPanel")
- BGP:SetSize( self.ItemList:GetWide(), math.ceil(Count/4)*55 )
- BGP.Paint = function() end
- local Count = 0
- for k,v in pairs(FAdmin.ScoreBoard.Player.ActionButtons) do
- if v.Visible == true or (type(v.Visible) == "function" and v.Visible(target) == true) then
- Count = Count + 1
- local ActionButton = vgui.Create("MetroTAB_CommandButton",BGP)
- local name = v.Name
- if type(name) == "function" then name = name(target) end
- ActionButton:SetSize( self.ItemList:GetWide()/4-5, 50 )
- ActionButton:SetPos((Count-1)%4 * (ActionButton:GetWide()+5),math.ceil(Count/4)*55 -50)
- ActionButton:SetTexts(name)
- ActionButton.m_Image = vgui.Create("DImage", ActionButton)
- ActionButton.m_Image:SetPos(2,2)
- ActionButton.m_Image:SetSize(36,36)
- ActionButton.SetImage = function(self,Mat, bckp)
- self.m_Image:SetImage(Mat, bckp)
- end
- ActionButton.m_Image2 = vgui.Create("DImage", ActionButton)
- ActionButton.m_Image2:SetPos(2,2)
- ActionButton.m_Image2:SetSize(36,36)
- ActionButton.SetImage2 = function(self,Mat, bckp)
- self.m_Image2:SetImage(Mat, bckp)
- end
- if type(v.Image) == "string" then
- ActionButton:SetImage(v.Image or "icon16/exclamation")
- elseif type(v.Image) == "table" then
- ActionButton:SetImage(v.Image[1])
- if v.Image[2] then ActionButton:SetImage2(v.Image[2]) end
- elseif type(v.Image) == "function" then
- local img1, img2 = v.Image(LocalPlayer())
- ActionButton:SetImage(img1)
- if img2 then ActionButton:SetImage2(img2) end
- else
- ActionButton:SetImage("icon16/exclamation")
- end
- ActionButton.SetText = function(self,text)
- self:SetTexts(text)
- end
- ActionButton.Click = function(self)
- return v.Action(target, self)
- end
- if v.OnButtonCreated then
- v.OnButtonCreated(target, ActionButton)
- end
- end
- end
- self.ItemList:AddItem(BGP)
- end
- CreateLabel("Manage Player")
- local TNick = target:Nick()
- local BGP = vgui.Create("MetroTAB_DSWButton")
- BGP:SetSize(self.ItemList:GetWide()/2 - 5,50)
- BGP:SetBoarderColor(Color(0,0,0,0))
- BGP.FXCol = Color(120,120,120,50)
- BGP.PaintOverlay = function(slf)
- surface.SetDrawColor( PlayerBGColor )
- surface.DrawRect( 0, 0, slf:GetWide(), slf:GetTall() )
- if target:IsValid() then
- draw.SimpleText(TNick, "RXF2_TrebOut_S30", 80,0, Color(255,255,255,255))
- if slf:IsHovered() then
- draw.SimpleText(target:SteamID(), "RXF2_TrebOut_S20", 80,25, Color(200,200,200,150))
- else
- local UG = target:GetNWString("usergroup")
- draw.SimpleText(team.GetName(target:Team()) .. " , " .. UG, "RXF2_TrebOut_S20", 80,25, Color(200,200,200,150))
- end
- draw.SimpleText(target:Frags() .. " Kills", "RXF2_TrebOut_S20", slf:GetWide()-10,5, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
- draw.SimpleText(target:Deaths() .. " Deaths", "RXF2_TrebOut_S20", slf:GetWide()-10,25, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
- if slf:IsHovered() then
- if LocalPlayer():IsAdmin() or LocalPlayer():IsSuperAdmin() then
- draw.SimpleText("Money", "RXF2_TrebOut_S20", slf:GetWide()-180,5, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
- draw.SimpleText((target.DarkRPVars.Money or 0), "RXF2_TrebOut_S20", slf:GetWide()-180,25, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
- else
- draw.SimpleText("Ping", "RXF2_TrebOut_S20", slf:GetWide()-180,5, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
- draw.SimpleText(target:Ping(), "RXF2_TrebOut_S20", slf:GetWide()-180,25, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
- end
- else
- draw.SimpleText("Ping", "RXF2_TrebOut_S20", slf:GetWide()-180,5, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
- draw.SimpleText(target:Ping(), "RXF2_TrebOut_S20", slf:GetWide()-180,25, Color(0,200,255,255),TEXT_ALIGN_RIGHT)
- end
- end
- end
- local icon = vgui.Create("ModelImage",BGP)
- icon:SetSize(BGP:GetTall(),BGP:GetTall())
- icon:SetModel(target:GetModel())
- self.ItemList:AddItem(BGP)
- CreateLabel("DarkRP Basic")
- CreateDarkRPBasicFunc()
- end
- function PANEL:UpdateList( plysearch )
- self.ItemList:Clear()
- local List = self.ItemList
- local function AddTeam( TEAM, plysearch )
- local TeamName = team.GetName(TEAM)
- local TeamColor = team.GetColor(TEAM)
- local PlayerBGColor = team.GetColor(TEAM)
- local TeamPlayers = table.Count(team.GetPlayers(TEAM))
- if plysearch and plysearch != "" then
- local player = nil
- for _, ply in pairs( team.GetPlayers( TEAM ) ) do
- if IsSearchValuePlayer( ply, plysearch ) then
- player = ply
- end
- end
- if not player then return end
- end
- PlayerBGColor.a = 20
- local BG = vgui.Create("DPanel")
- BG:SetSize(List:GetWide(),32 + 100)
- BG.Paint = function(slf) end
- --[[
- local BGP = vgui.Create("MetroTAB_DSWButton",BG)
- BGP:SetSize(BG:GetWide(),30)
- BGP:SetBoarderColor(Color(0,0,0,0))
- BGP.PaintOverlay = function(slf)
- surface.SetDrawColor( TeamColor )
- surface.DrawRect( 0, 0, slf:GetWide(), slf:GetTall() )
- draw.SimpleText(TeamName .. " ( " .. TeamPlayers .. " ) ", "RXF2_TrebOut_S25", 20,0, Color(255,255,255,255))
- end
- function BGP:Click()
- end
- ]]
- local PlayerList = vgui.Create("DPanel", BG)
- PlayerList:SetPos(0,0)
- PlayerList:SetSize(BG:GetWide(),54)
- PlayerList.list = {}
- PlayerList.Paint = function(slf)
- surface.SetDrawColor( 0,0,0,50 )
- surface.DrawRect( 0, 0, slf:GetWide(), slf:GetTall() )
- end
- function PlayerList:Update()
- local spacing = 0
- local tall = 0
- for _, panel in pairs( self.list ) do
- panel:SetPos( select( 1, panel:GetPos() ), tall )
- tall = tall + panel:GetTall() + spacing
- end
- self:SetTall( tall )
- BG:SetTall( tall )
- local listHeight = 0
- for k, v in pairs( BG:GetParent():GetChildren() ) do
- if ispanel( v ) then
- listHeight = listHeight + v:GetTall()
- end
- end
- BG:GetParent():SetTall( listHeight )
- end
- function PlayerList:AddItem( item )
- if not ispanel( item ) then return end
- if table.HasValue( self.list, item ) then return end
- table.insert( self.list, item )
- item:SetParent( self )
- self:Update()
- end
- for k, target in pairs( team.GetPlayers( TEAM ) ) do
- if plysearch and plysearch != "" then
- if !IsSearchValuePlayer( target, plysearch ) then continue end
- end
- local TNick = target:Nick()
- local BGP = vgui.Create("MetroTAB_DSWButton")
- BGP:SetSize(PlayerList:GetWide() - 4, 32)
- BGP:SetPos(2, 0)
- BGP:SetBoarderColor(Color(0,0,0,0))
- BGP.FXCol = Color(120,120,120,50)
- BGP.Money = target:getDarkRPVar("money") or 0
- if BGP.Money >= 1000000 then
- BGP.Money = string.Comma(math.floor(BGP.Money/1000000)) .. "M"
- else
- if BGP.Money >= 1000 then
- BGP.Money = string.Comma(math.floor(BGP.Money/1000)) .. "K"
- end
- end
- BGP.PaintOverlay = function(slf)
- surface.SetDrawColor( PlayerBGColor )
- surface.DrawRect( 0, 0, slf:GetWide(), slf:GetTall()-2 )
- if target:IsValid() then
- draw.SimpleText(TNick, "RXF2_TrebOut_S26", 80,2, Color(200,200,200,255))
- local UG = target:GetNWString("usergroup")
- draw.SimpleText( team.GetName( target:Team() ), "RXF2_TrebOut_S20", (slf:GetWide()/2), 5, Color(200,200,200,150), TEXT_ALIGN_CENTER )
- draw.SimpleText( "Ping " .. target:Ping(), "RXF2_TrebOut_S20", slf:GetWide() - 15, 5, Color(0,200,255,255), TEXT_ALIGN_RIGHT )
- --if slf:IsHovered() or slf:IsChildHovered( 1 ) then
- if slf.shouldresize then
- draw.SimpleText(target:SteamID(), "RXF2_TrebOut_S20", 80,25, Color(200,200,200,150))
- draw.SimpleText( UG, "RXF2_TrebOut_S20", (slf:GetWide()/2), 25, Color(200,200,200,150), TEXT_ALIGN_CENTER )
- 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 )
- draw.SimpleText("Wallet $" .. slf.Money, "RXF2_TrebOut_S20", slf:GetWide() - (slf:GetWide()/4), 5, Color(0,200,255,255), TEXT_ALIGN_CENTER)
- end
- end
- end
- BGP.OnMousePressed = function(slf,mc)
- if mc == MOUSE_RIGHT then
- local DM = DermaMenu()
- DM:AddOption("Copy Nickname",function() SetClipboardText(target:Nick()) end)
- DM:AddOption("Copy SteamID",function() SetClipboardText(target:SteamID()) end)
- DM:AddOption("Open Steam Profile page",function() target:ShowProfile() end)
- DM:Open()
- end
- if mc == MOUSE_LEFT then
- --self:PlayerClick(target,PlayerBGColor)
- if slf:IsHovered() or slf:IsChildHovered( 1 ) then
- if not slf.shouldresize then
- slf:SetActive( true )
- slf.shouldresize = true
- else
- slf:SetActive( false )
- slf.shouldresize = false
- end
- end
- end
- end
- BGP.playericon = ""
- local icon = vgui.Create( "DPanel", BGP )
- icon:SetSize( 16, 16 )
- icon:SetPos( 58, 7 )
- icon.Paint = function( pnl, w, h )
- if BGP.playericon and BGP.playericon != "" then
- surface.SetDrawColor( 255, 255, 255, 255 )
- surface.SetMaterial( Material( BGP.playericon ) )
- surface.DrawTexturedRect( 0, 0, 16, 16 )
- end
- end
- local avatar = vgui.Create( "AvatarImage",BGP )
- BGP.avatar = avatar
- avatar:SetSize( BGP:GetTall()-2, BGP:GetTall()-2 )
- avatar:SetPos( BGP:GetPos() )
- avatar:SetPlayer( target, 64 )
- function BGP:SetActive( state )
- if state then
- self:SetSize( PlayerList:GetWide() - 4, 52 )
- local posX, posY = self:GetPos()
- self:SetPos( posX, posY + 20 )
- else
- self:SetSize( PlayerList:GetWide() - 4, 32 )
- end
- self:Update()
- PlayerList:Update()
- end
- function BGP:Update()
- avatar:SetSize( self:GetTall()-2, BGP:GetTall()-2 )
- avatar:SetPos( 0, 0 )
- if MetroTAB_Config then
- BGP.playericon = MetroTAB_Config.Player_Icons[target:SteamID()] or MetroTAB_Config.Rank_Icons[target:GetUserGroup()] or ""
- end
- end
- --[[BGP.Think = function(slf)
- if slf:IsHovered() or slf:IsChildHovered( 1 ) then
- if not slf.shouldresize then
- slf:SetActive( true )
- slf.shouldresize = true
- end
- else
- if slf.shouldresize then
- slf:SetActive( false )
- slf.shouldresize = false
- end
- end
- end]]
- PlayerList:AddItem( BGP )
- BGP:SetActive( false )
- end
- List:AddItem(BG)
- end
- local TBIns = {}
- for k,v in pairs(player.GetAll()) do
- table.insert(TBIns,{P=v,T=v:Team()})
- end
- table.SortByMember(TBIns, T, function(a, b) return a > b end)
- local TeamsTable = team.GetAllTeams()
- TeamsTable[0] = nil
- TeamsTable[1001] = nil
- TeamsTable[1002] = nil
- local AvailaleTeams = {}
- for k,v in pairs(TeamsTable) do
- if table.Count(team.GetPlayers(k)) > 0 then
- AvailaleTeams[k] = table.Count(team.GetPlayers(k))
- end
- end
- for Team,PlayersAmount in pairs( AvailaleTeams ) do
- AddTeam( Team, plysearch )
- end
- end
- vgui.Register("MetroTAB_Players",PANEL,"DFrame")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement