Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ---------------------------------------------------
- // Scoreboard 99% created by Jackool/Alex Frison
- // www.AlexFrison.us www.Devolved.us community
- // ---------------------------------------------------
- surface.CreateFont( "SB_TTT_Title", {
- font = "Arial",
- size = 37,
- weight = 900,
- blursize = 0,
- scanlines = 0,
- antialias = true,
- underline = false,
- italic = false,
- strikeout = false,
- symbol = false,
- rotary = false,
- shadow = false,
- additive = false,
- outline = true
- } )
- surface.CreateFont( "SB_TTT_Mute", {
- font = "Arial",
- size = 20,
- weight = 600,
- blursize = 0,
- scanlines = 0,
- antialias = true,
- underline = false,
- italic = false,
- strikeout = false,
- symbol = false,
- rotary = false,
- shadow = true,
- additive = false,
- outline = true
- } )
- surface.CreateFont( "SB_TTT_Map", {
- font = "Arial",
- size = 19,
- weight = 900,
- blursize = 0,
- scanlines = 0,
- antialias = true,
- underline = false,
- italic = false,
- strikeout = false,
- symbol = false,
- rotary = false,
- shadow = false,
- additive = false,
- outline = true
- } )
- surface.CreateFont( "SB_TTT_Header", {
- font = "coolvetica",
- size = 21,
- weight = 20,
- blursize = 0,
- scanlines = 0,
- antialias = true,
- underline = false,
- italic = false,
- strikeout = false,
- symbol = false,
- rotary = false,
- shadow = false,
- additive = false,
- outline = true
- } )
- surface.CreateFont( "SB_TTT_Ply", {
- font = "Arial",
- size = 20,
- weight = 640,
- blursize = 0,
- scanlines = 0,
- antialias = true,
- underline = false,
- italic = false,
- strikeout = false,
- symbol = false,
- rotary = false,
- shadow = false,
- additive = false,
- outline = false
- } )
- surface.CreateFont( "SB_TTT_PInfo", {
- font = "Arial",
- size = 17,
- weight = 640,
- blursize = 0,
- scanlines = 0,
- antialias = true,
- underline = false,
- italic = false,
- strikeout = false,
- symbol = false,
- rotary = false,
- shadow = false,
- additive = false,
- outline = false
- } )
- surface.CreateFont( "SB_TTT_Lvl", {
- font = "Arial",
- size = 15,
- weight = 650,
- blursize = 0,
- scanlines = 0,
- antialias = false,
- underline = false,
- italic = false,
- strikeout = false,
- symbol = false,
- rotary = false,
- shadow = false,
- additive = false,
- outline = true
- } )
- surface.CreateFont( "SB_TTT_GraphNum", {
- font = "Arial",
- size = 12,
- weight = 0,
- blursize = 0,
- scanlines = 0,
- antialias = true,
- underline = false,
- italic = false,
- strikeout = false,
- symbol = false,
- rotary = false,
- shadow = false,
- additive = false,
- outline = false
- } )
- surface.CreateFont( "SB_TTT_TopTxt", {
- font = "Arial",
- size = 18,
- weight = 650,
- blursize = 0,
- scanlines = 0,
- antialias = true,
- underline = false,
- italic = false,
- strikeout = false,
- symbol = false,
- rotary = false,
- shadow = false,
- additive = false,
- outline = true
- } )
- // This part is from the TTT scoreboard
- GROUP_TERROR = 1
- GROUP_NOTFOUND = 2
- GROUP_FOUND = 3
- GROUP_SPEC = 4
- local function ScoreGroup(p)
- if not IsValid(p) then return -1 end -- will not match any group panel
- if DetectiveMode() then
- if (p:IsSpec() and (not p:Alive())) or p.DeathDM then
- if p:GetNWBool("body_found", false) then
- return GROUP_FOUND
- else
- local client = LocalPlayer()
- -- To terrorists, missing players show as alive
- if client:IsSpec() or
- client:IsActiveTraitor() or
- client.DeathDM or
- ((GAMEMODE.round_state != ROUND_ACTIVE) and client:IsTerror()) then
- return GROUP_NOTFOUND
- else
- return GROUP_TERROR
- end
- end
- end
- end
- return (p:IsTerror() and GROUP_TERROR) or (p.DeathDM and ((!p:GetNWBool("body_found") and ((LocalPlayer():IsTraitor() and GROUP_NOTFOUND) or GROUP_TERROR)) or GROUP_FOUND)) or GROUP_SPEC
- end
- // The rest created by Jackool/Alex Frison
- // www.Devolved.us
- local Dev = {}
- function Dev.ViewStats(ply)
- net.Start("Dev_OpenStats")
- net.WriteEntity(ply)
- net.SendToServer()
- end
- function Dev.ViewPT(ply)
- net.Start("Dev_OpenPlaytime")
- net.WriteEntity(ply)
- net.SendToServer()
- end
- Dev.NiceStatNames = {tkills = "T Kills",maprate = "Maps Rated",scratch = "Scratch Cards Scratched",crateopen = "Crates Unlocked",cratefound="Crate Drops Found",postalive = "Post Survivals",postround = "Post Round Kills",drunkkill = "Drunk Kills",specdm = "Spec DM Kills",headshot = "Headshot Kills",lstand = "Last Stands",beers = "Beers Consumed",jihad = "Jihads",bucks="DevBucks",harda="Hard Alcohol Consumed"}
- function Dev.StatsWindow(size)
- local who,stats = net.ReadEntity(),net.ReadTable()
- if who and who:IsValid() and stats then
- local Count = 0
- for k,v in pairs(stats) do Count = Count+1 end
- // Stats frame (right click > view stats on SB)
- local Stats,SizeY = vgui.Create("DFrame"),(Count*15+38)
- Stats:SetSize(200,SizeY)
- Stats:MakePopup()
- Stats:SetPos(ScrW()*.5-100,ScrH()+SizeY+10)
- Stats:MoveTo(ScrW()*.5-100,ScrH()*.5-(SizeY*.5),.26,0,.3)
- Stats:SetTitle("Stats for: " .. who:Name())
- Stats.Paint = function(s,w,h)
- draw.RoundedBox(0,0,0,w,h,Color(0,0,0,250))
- draw.RoundedBox(0,2,2,w-4,h-4,Color(80,80,80,140))
- draw.RoundedBox(0,2,2,w-4,24,Color(120,120,120,140))
- end
- // Total level first
- local stat = vgui.Create("DLabel",Stats)
- stat:SetPos(9,30)
- stat:SetText("Total Level: " .. stats.totallvl)
- stat:SizeToContents()
- stat:SetColor(Color(200,0,0))
- // Then DevBucks
- local stat = vgui.Create("DLabel",Stats)
- stat:SetPos(9,45)
- stat:SetText("DevBucks: " .. stats.bucks)
- stat:SizeToContents()
- stat:SetColor(Color(0,200,0))
- local num = 1
- for k,v in pairs(stats) do
- if k == "totallvl" or k == "bucks" then continue end
- num = num+1
- local stat = vgui.Create("DLabel",Stats)
- stat:SetPos(9,num*15+30)
- stat:SetText((Dev.NiceStatNames[k] or k) .. ": " .. v)
- stat:SizeToContents()
- end
- end
- end
- net.Receive("Dev_SendStats",Dev.StatsWindow)
- Dev.GraphDot = Material("Devolved/graph_dot.png","nocull")
- Dev.GraphDotLrg = Material("Devolved/graph_dot_lrg.png","nocull")
- function Dev.SendPlaytime(size)
- local Year,Month,Day,Hour = net.ReadFloat(),net.ReadFloat(),net.ReadFloat(),net.ReadFloat()
- local PT = net.ReadTable()
- local B = {TopTxt = "",TotalTime = 0}
- B.Display = "Week"
- local WindowW,WindowH = math.Clamp(900,0,ScrW()),math.Clamp(250,0,ScrH())
- B.BG = vgui.Create("DFrame")
- B.BG:SetSize(WindowW,WindowH)
- B.BG:MakePopup()
- B.BG:Center()
- B.BG.Paint = function(s,w,h)
- draw.RoundedBox(0,0,0,w,h,Color(0,0,0,250))
- draw.RoundedBox(0,2,2,w-4,h-4,Color(80,80,80,140))
- draw.RoundedBox(0,2,2,w-4,24,Color(120,120,120,140))
- draw.DrawText(B.TopTxt .. B.TotalTime .. " minutes", "SB_TTT_TopTxt", w*.5, 32, Color(255,255,255,200),TEXT_ALIGN_CENTER)
- end
- B.BG:SetTitle("Playtime graph for " .. net.ReadString())
- B.BG:SetPos(ScrW()*.5-(WindowW*.5),ScrH()+WindowH*.5)
- B.BG:MoveTo(ScrW()*.5-(WindowW*.5),ScrH()*.5-(WindowH*.5),.26,0,.3)
- local function GeneratePlots(Days)
- B.TotalTime = 0
- B.GraphDivide = 1440
- B.Graph = {}
- local Before = Day-Days
- if Before <= 0 then
- Before = Days+Before
- local PlotNum = 1
- local NewYear = (Month-1 <= 0 and Year-1) or Year
- local NewMonth = (Month-1 <= 0 and 12+(Month-1)) or (Month-1)
- for i=Before,Days do
- local check = 0
- if PT[NewYear] and PT[NewYear][NewMonth-1] and PT[NewYear][NewMonth-1][i] then
- for k,v in pairs(PT[NewYear][NewMonth-1][i]) do check=check+v end
- end
- B.Graph[PlotNum] = {}
- B.Graph[PlotNum].time = check
- B.Graph[PlotNum].str = NewMonth .. "/" .. i .. "/" .. NewYear
- PlotNum = PlotNum+1
- B.TotalTime = B.TotalTime+check
- end
- for i=1,Day do
- local check = 0
- if PT[Year] and PT[Year][Month] and PT[Year][Month][i] then
- for k,v in pairs(PT[Year][Month][i]) do check=check+v end
- end
- B.Graph[PlotNum] = {}
- B.Graph[PlotNum].time = check
- B.Graph[PlotNum].str = Month .. "/" .. i .. "/" .. Year
- PlotNum = PlotNum+1
- B.TotalTime = B.TotalTime+check
- end
- else
- local PlotNum = 1
- for i=Before,Day do
- local check = 0
- if PT[Year] and PT[Year][Month] and PT[Year][Month][i] then
- for k,v in pairs(PT[Year][Month][i]) do check = check+v end
- end
- B.Graph[PlotNum] = {}
- B.Graph[PlotNum].time = check
- B.Graph[PlotNum].str = Month .. "/" .. i
- B.TotalTime = B.TotalTime+check
- PlotNum = PlotNum+1
- end
- end
- end
- local function GeneratePlotsHour(Hrs)
- B.TotalTime = 0
- B.GraphDivide = 60
- B.Graph = {}
- local Before = Hour-Hrs
- if Before <= 0 then
- Before = 23+Before
- local PlotNum = 1
- local datetbl = os.time({year = Year,month = Month, day=Day-1})
- local NewYear = tonumber(os.date("%Y",datetbl))
- local NewMonth = tonumber(os.date("%m",datetbl))
- local NewDay = tonumber(os.date("%d",datetbl))
- for i=Before+1,24 do
- local check = 0
- if PT[NewYear] and PT[NewYear][NewMonth] and PT[NewYear][NewMonth][NewDay] and PT[NewYear][NewMonth][NewDay][i] then
- check = PT[NewYear][NewMonth][NewDay][i]
- end
- B.Graph[PlotNum] = {}
- B.Graph[PlotNum].time = check
- B.Graph[PlotNum].str = NewMonth .. "/" .. NewDay .. "\n" .. os.date("%I %p",os.time({year = NewYear,month = NewMonth, day=NewDay, hour=i}))
- PlotNum = PlotNum+1
- B.TotalTime = B.TotalTime+check
- end
- for i=1,(Hrs-(23-Before)) do
- local check = 0
- if PT[Year] and PT[Year][Month] and PT[Year][Month][Day] and PT[Year][Month][Day][i] then
- check = PT[Year][Month][Day][i]
- end
- B.Graph[PlotNum] = {}
- B.Graph[PlotNum].time = check
- B.Graph[PlotNum].str = Month .. "/" .. Day .. "\n" .. os.date("%I %p",os.time({year = Year,month = Month, day=Day, hour=i}))
- PlotNum = PlotNum+1
- B.TotalTime = B.TotalTime+check
- end
- else
- local PlotNum = 1
- for i=0,23 do
- local check = 0
- if PT[Year] and PT[Year][Month] and PT[Year][Month][Day] and PT[Year][Month][Day][i] then
- check = PT[Year][Month][Day][i]
- end
- B.Graph[PlotNum] = {}
- B.Graph[PlotNum].time = check
- B.Graph[PlotNum].str = Month .. "/" .. i .. "\n" .. i .. ":00"
- B.TotalTime = B.TotalTime+check
- PlotNum = PlotNum+1
- end
- end
- end
- B.LastMonth = vgui.Create("DButton",B.BG)
- B.LastMonth:SetPos(6,30)
- B.LastMonth:SetSize(65,20)
- B.LastMonth:SetText("Last Month")
- B.LastMonth.DoClick = function()
- GeneratePlots(31)
- B.TopTxt = "Last Month: "
- end
- B.Last2Week = vgui.Create("DButton",B.BG)
- B.Last2Week:SetPos(73,30)
- B.Last2Week:SetSize(74,20)
- B.Last2Week:SetText("Last 2 Weeks")
- B.Last2Week.DoClick = function()
- GeneratePlots(14)
- B.TopTxt = "Last 2 Weeks: "
- end
- B.LastWeek = vgui.Create("DButton",B.BG)
- B.LastWeek:SetPos(149,30)
- B.LastWeek:SetSize(65,20)
- B.LastWeek:SetText("Last Week")
- B.LastWeek.DoClick = function()
- GeneratePlots(7)
- B.TopTxt = "Last Week: "
- end
- B.LastDay = vgui.Create("DButton",B.BG)
- B.LastDay:SetPos(216,30)
- B.LastDay:SetSize(65,20)
- B.LastDay:SetText("Last Day")
- B.LastDay.DoClick = function()
- B.TopTxt = "Last Day: "
- GeneratePlotsHour(24)
- end
- GeneratePlots(7)
- B.TopTxt = "Last Week: "
- //ply.DTTT.playtime[Year] = ply.DTTT.playtime[Year] or {}
- //ply.DTTT.playtime[Year][Day] = ply.DTTT.playtime[Year][Day] or {}
- //ply.DTTT.playtime[Year][Day][Hour] = ply.DTTT.playtime[Year][Day][Hour] or 0
- local GraphW,GraphH = WindowW-12,WindowH-60
- local LineH = GraphH-2
- B.GraphDisplay = vgui.Create("DPanel",B.BG)
- B.GraphDisplay:SetPos(6,54)
- B.GraphDisplay:SetSize(GraphW,GraphH)
- B.GraphDisplay.Paint = function(s,w,h)
- draw.RoundedBox(0,0,0,w,h,Color(120,120,120,140))
- local MaxNum = table.Count(B.Graph)
- local Pts = (1/(MaxNum-1))*GraphW
- local CurPt = 0
- local mX,mY = gui.MousePos()
- local addX,addY = B.GraphDisplay:LocalToScreen()
- for k,v in pairs(B.Graph) do
- local nexttotal = (B.Graph[k+1] and B.Graph[k+1].time) or 0
- surface.SetDrawColor(Color(0,0,0))
- surface.DrawLine(CurPt*Pts,LineH-(LineH*(v.time/B.GraphDivide)),CurPt*Pts+Pts,LineH-(LineH*(nexttotal/B.GraphDivide)))
- //surface.DrawCircle(CurPt*Pts,LineH-(LineH*(total/B.GraphDivide)),1,Color(0,0,0))
- /*
- surface.DrawRect((CurPt*Pts)-3,(LineH-(LineH*(v.time/B.GraphDivide)))-1,6,6)
- */
- local dotX,dotY = (CurPt*Pts)-3,(LineH-(LineH*(v.time/B.GraphDivide)))-3
- local DotX,DotY = addX+dotX,addY+dotY
- if (mX >= DotX-9 and mX <= DotX+17 and mY >= DotY-8 and mY <= DotY+16) then
- surface.SetDrawColor( 255, 255, 255, 255 )
- surface.SetMaterial(Dev.GraphDotLrg)
- surface.DrawTexturedRect((CurPt*Pts)-5,(LineH-(LineH*(v.time/B.GraphDivide)))-5, 13, 13 )
- local TxtY = (LineH-(LineH*(v.time/B.GraphDivide)))-38
- if TxtY <= 10 then TxtY = 10 end
- draw.DrawText(v.str .. "\n" .. v.time .. " min.", "SB_TTT_GraphNum", dotX+8-(k == MaxNum and 10 or 0), TxtY, Color(255,255,255),(k == MaxNum and TEXT_ALIGN_RIGHT) or TEXT_ALIGN_LEFT)
- else
- surface.SetDrawColor( 255, 255, 255, 255 )
- surface.SetMaterial(Dev.GraphDot)
- surface.DrawTexturedRect(dotX,dotY, 8, 8 )
- end
- CurPt = CurPt+1
- end
- end
- end
- net.Receive("Dev_SendPlaytime",Dev.SendPlaytime)
- // Rules
- function RulesBrowser()
- local Frame = vgui.Create("web_browser")
- Frame:SetSize(ScrW()*.9,ScrH()*.9)
- Frame:SetZPos(-50)
- Frame:SetDrawOnTop(true)
- Frame:MoveToFront()
- Frame:MakePopup()
- Frame.Paint = function(s,w,h)
- draw.RoundedBox(4,0,0,w,h,Color(255,255,255,40))
- draw.RoundedBox(4,2,2,w-4,h-4,Color(0,0,0,200))
- end
- Frame:Center()
- Frame:OpenURL("http://devolved.us/forum/index.php?topic=1674")
- Frame:SetTitle("Devolved.us TTT Rules")
- end
- function LookupBans(name,sid)
- local Frame = vgui.Create("web_browser")
- Frame:SetSize(ScrW()*.9,ScrH()*.9)
- Frame:SetZPos(-50)
- Frame:SetDrawOnTop(true)
- Frame:MoveToFront()
- Frame:MakePopup()
- Frame.Paint = function(s,w,h)
- draw.RoundedBox(4,0,0,w,h,Color(255,255,255,40))
- draw.RoundedBox(4,2,2,w-4,h-4,Color(0,0,0,200))
- end
- Frame:Center()
- Frame:OpenURL("http://devolved.us/bans/search/" .. sid .. "/")
- Frame:SetTitle("Looking up bans for user: " .. name)
- end
- function SteamProfile(sid,name)
- local Frame = vgui.Create("web_browser")
- Frame:SetSize(ScrW()*.9,ScrH()*.9)
- Frame:SetZPos(-50)
- Frame:SetDrawOnTop(true)
- Frame:MoveToFront()
- Frame:MakePopup()
- Frame.Paint = function(s,w,h)
- draw.RoundedBox(4,0,0,w,h,Color(255,255,255,40))
- draw.RoundedBox(4,2,2,w-4,h-4,Color(0,0,0,200))
- end
- Frame:Center()
- Frame:OpenURL("steamcommunity.com/profiles/" .. sid .. "/")
- Frame:SetTitle("Viewing Steam Profile for: " .. name)
- end
- COLOR_GREEN = Color(0,255,0)
- COLOR_YELLOW = Color(200,200,0)
- COLOR_RED = Color(255,0,0)
- COLOR_WHITE = Color(255,255,255)
- COLOR_BLACK = Color(0,0,0)
- // Player tags (on click)
- Dev.Tags = {
- {txt="FRIEND",clr=COLOR_GREEN},
- {txt="SUSPECT",clr=COLOR_YELLOW},
- {txt="AVOID",clr=Color(255, 150, 0, 255)},
- {txt="KILL",clr=COLOR_RED},
- {txt="MISSING",clr=Color(130, 190, 130, 255)}
- }
- local SBText = "Devolved.us TTT West"
- hook.Add("InitPostEntity","Change scoreboard text to east",function()
- if string.find(string.lower(GetHostName()),"east") then
- SBText = "Devolved.us TTT East"
- end
- end)
- local FirstSend,DoMuteAll
- Dev.SB_Logo = Material("Devolved/sb_ttt_logo.png")
- Dev.SB_Top = Material("Devolved/sb_ttt_top.png")
- Dev.SB_Header = Material("Devolved/sb_ttt_header.png")
- Dev.SB_BG = Material("Devolved/sb_ttt_bg.png")
- Dev.SB_Ply = Material("Devolved/sb_ttt_ply.png")
- function Dev.CreateSB()
- if Dev.SB and Dev.SB:IsValid() then Dev.SB:Close() end
- if Dev_SB and Dev_SB:IsValid() then Dev_SB:Close() end
- local function SB_AddPlayer() end
- local function SB_AddHeader() end
- local function SB_RefreshPList() end
- if !FirstSend then
- FirstSend = true
- net.Start("Dev_SendPlysInfo")
- net.SendToServer()
- end
- // Restore last mouse position
- if Dev.MouseX and Dev.MouseY then
- gui.SetMousePos(Dev.MouseX,Dev.MouseY)
- end
- local B = {} // vgui element table
- local W,H = ScrW(),ScrH()
- local SB_W,SB_H = math.Clamp(940,0,W),H*.94
- if W < 1300 then SB_W = math.Clamp(750,0,W) end
- local BG_Space = 96
- // This holds all the elements
- Dev.SB = vgui.Create("DFrame")
- Dev.SB:SetSize(SB_W,SB_H)
- Dev.SB.Paint = function(s,w,h)
- // Main BG
- draw.RoundedBox(0,0,61,SB_W,BG_Space,Color(0,0,0,220))
- // Map change text
- draw.DrawText("Map vote in " .. (5-(DevRound or 0)) .. " rounds (or type !rtv)", "SB_TTT_Map", w*.5, 132, Color(255,255,255,200),TEXT_ALIGN_CENTER)
- draw.DrawText("Mute all players", "SB_TTT_Mute", w-21, 39, Color(255,255,255,190),TEXT_ALIGN_RIGHT)
- end
- Dev.SB:SetTitle("")
- Dev.SB:SetDraggable(false)
- Dev.SB:ShowCloseButton(false)
- Dev.SB:SetDrawOnTop(false)
- Dev.SB:SetZPos(-100)
- Dev.SB:MoveToBack()
- local oldClose = Dev.SB.Close
- Dev.SB.Close = function(...)
- if B.Opts and B.Opts:IsValid() then B.Opts:Remove() end
- return oldClose(...)
- end
- Dev_SB = Dev.SB
- B.Rules = vgui.Create("DButton",Dev.SB)
- B.Rules:SetSize(150,24)
- B.Rules:SetText("Click here to view the rules")
- B.Rules.Paint = function(s,w,h)
- draw.RoundedBox(0,0,0,w,h,Color(0,0,0,120+(s.In and 80 or 0)))
- draw.RoundedBox(0,2,2,w-4,h-4,Color(255,255,255,150-(s.In and 40 or 0)))
- end
- B.Rules.OnCursorEntered = function(s) s.In = true end
- B.Rules.OnCursorExited = function(s) s.In = false end
- B.Rules.DoClick = function(s) RulesBrowser() end
- B.Rules:SetPos(SB_W-158,130)
- // Title/header element
- B.HeaderAm = math.ceil((SB_W-4)/60)-1
- B.Header = vgui.Create("DPanel",Dev.SB)
- B.Header:SetPos(2,62)
- B.Header:SetSize(SB_W-4,64)
- B.Header.Paint = function(s,w,h)
- // Header BG
- draw.RoundedBox(0,0,0,w,h,Color(0,0,0,246))
- for i=0,B.HeaderAm do
- surface.SetDrawColor( 255, 255, 255, 255 )
- surface.SetMaterial(Dev.SB_Top)
- surface.DrawTexturedRect( i*60, 2, 60, 60 )
- end
- // Get title font width
- local TitleW = 0
- surface.SetFont("SB_TTT_Title")
- TitleW = surface.GetTextSize(SBText)
- // Title and title BG
- draw.RoundedBox(4,(w-12)-TitleW-4-2,14,TitleW+12,38,Color(0,0,0,150))
- draw.RoundedBox(4,(w-12)-TitleW-4,16,TitleW+8,34,Color(160,160,160,120))
- draw.DrawText(SBText, "SB_TTT_Title", w-12, 14, Color(255,255,255,200),TEXT_ALIGN_RIGHT)
- end
- // Top left logo image
- B.Logo = vgui.Create("DPanel",Dev.SB)
- B.Logo:SetPos(2,6)
- B.Logo:SetSize(176,152)
- B.Logo.Paint = function()
- surface.SetDrawColor( 255, 255, 255, 255 )
- surface.SetMaterial(Dev.SB_Logo)
- surface.DrawTexturedRect( 0, 0, 175.5, 151.2 )
- end
- // Mute everyone top right
- B.Mute = vgui.Create("DCheckBox",Dev.SB)
- B.Mute:SetPos(SB_W-18,42)
- B.Mute:SetSize(16,16)
- B.Mute.Paint = function(s,w,h)
- draw.RoundedBox(0,0,0,w,h,Color(0,0,0,200))
- local val = s:GetChecked()
- if val then
- draw.RoundedBox(0,2,2,w-4,h-4,Color(0,255,0,80))
- else
- draw.RoundedBox(0,2,2,w-4,h-4,Color(255,255,255,50))
- end
- end
- B.Mute.OnChange = function(s)
- DoMuteAll = s:GetChecked()
- net.Start("Dev_MuteAll")
- if DoMuteAll then net.WriteFloat(1) else net.WriteFloat(0) end
- net.SendToServer()
- end
- B.Mute:SetChecked(DoMuteAll or false)
- // Team section player lists ===============================
- // Content BG (invisible)
- B.Players = vgui.Create("DPanelList",Dev.SB)
- B.Players:SetSize(SB_W,SB_H-153)
- B.Players:SetPos(0,153)
- B.Players.Paint = function() end
- B.Players:SetSpacing(0)
- B.Players:SetPadding(0)
- B.Players:EnableVerticalScrollbar(true)
- local BDG_X = SB_W*.6 // Store the position to start badges
- // Add a player row (for under header/titles)
- SB_AddPlayer = function(ply)
- if !ply:IsValid() then return end
- local PLY_W = B.Players:GetWide()
- // Devolved player badges ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- local badges = {}
- if ply.lvl then
- table.insert(badges,{
- txt = ply.lvl,
- img = "icon16/shield.png"
- })
- end
- if ply.TTTPlaytime then
- table.insert(badges,{
- txt = "TTT Playtime: " .. ply.TTTPlaytime .. " minutes",
- img = "icon16/clock.png"
- })
- end
- if ply.PostRank then
- table.insert(badges,{
- txt = "Forum Post Rank: " .. ply.PostRank .. " (" .. ply.PostCount .. " posts)" .. (ply.JoinDate and "\nForum Join Date: " .. ply.JoinDate or ""),
- img = "Devolved/postrank.png"
- })
- end
- if table.HasValue(ply.Ranks,"Gold Member") then
- table.insert(badges,{
- txt = "This player is a gold member.",
- img = "icon16/award_star_gold_1.png"
- })
- elseif ply.ForumRank == "Silver Member" then
- table.insert(badges,{
- txt = "This player is a silver member.",
- img = "icon16/award_star_silver_1.png"
- })
- elseif ply.ForumRank == "Member" then
- table.insert(badges,{
- txt = "This player is a forum member.",
- img = "icon16/user.png"
- })
- elseif ply.ForumRank == "Donator" then
- table.insert(badges,{
- txt = "This player is a donator.",
- img = "icon16/user_gray.png"
- })
- end
- if table.HasValue(ply.Ranks,"Platinum Member") then
- table.insert(badges,{
- txt = "This player is a platinum member.",
- img = "Devolved/icon_plat.png"
- })
- end
- if ply.Reserved then
- table.insert(badges,{
- txt = "This player has a reserved slot.",
- img = "icon16/key.png"
- })
- end
- if ply.Ranks then
- for k,v in pairs(DA_SH.GroupIcons) do
- if table.HasValue(ply.Ranks,k) then
- table.insert(badges,{
- txt = "This player has the rank '" .. k .. "'",
- img = v
- })
- end
- end
- // DevolvedAdmin icon support here
- end
- local NumBadge = #badges
- local BadgeW = (NumBadge*22)
- // End finding badges ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // Color gradient if T/D
- local Extra,Extras = (ply:IsTraitor() and Color(255,0,0)) or (ply:IsDetective() and Color(0,0,255))
- if Extra then
- Extras = math.ceil((PLY_W)/200)-1
- end
- // Player main BG and player info
- local P,Entered,Exited = vgui.Create("DButton")
- P:SetSize(PLY_W,24)
- P.Paint = function(s,w,h)
- if !ply:IsValid() then SB_RefreshPList() return end
- // Background
- draw.RoundedBox(0,0,0,w,h,Color(0,0,0,230))
- draw.RoundedBox(0,2,0,w-4,h-2,Color(100,100,100,90))
- if Entered or Exited then
- local clamped = math.Clamp((Entered and (CurTime()-Entered)/.06) or (Exited and (CurTime()-Exited)/.06),0,1)
- draw.RoundedBox(0,2,0,w-4,h-2,Color(255,255,255,19*(Exited and 1-clamped or clamped)))
- if Exited and CurTime()-Exited > .06 then Exited = nil end
- end
- // BG For T/D
- if Extras then
- for i=0,Extras do
- surface.SetDrawColor( Extra.r, Extra.g, Extra.b, 60 )
- surface.SetMaterial(Dev.SB_Ply)
- surface.DrawTexturedRect( i*200, 0, 200, h-2 )
- end
- end
- // Name
- draw.DrawText(ply:Name(), "SB_TTT_Ply", 32, 2, Color(255,255,255,190),TEXT_ALIGN_LEFT)
- // Ping
- draw.RoundedBox(0,w-79,0,39,h-2,Color(0,0,0,150))
- draw.DrawText(ply:Ping(), "SB_TTT_PInfo", w-60, 3, Color(255,255,255,190),TEXT_ALIGN_CENTER)
- // Deaths
- draw.DrawText(ply:Deaths(), "SB_TTT_PInfo", w-111, 3, Color(255,255,255,190),TEXT_ALIGN_CENTER)
- // Score
- draw.RoundedBox(0,w-191,0,49,h-2,Color(0,0,0,150))
- draw.DrawText(ply:Frags(), "SB_TTT_PInfo", w-167, 3, Color(255,255,255,190),TEXT_ALIGN_CENTER)
- // Karma
- draw.DrawText(math.Round(ply:GetBaseKarma()), "SB_TTT_PInfo", w-219, 3, Color(255,255,255,190),TEXT_ALIGN_CENTER)
- // SB Tags
- local SBTag = ply.sb_tag
- if SBTag then
- draw.DrawText(SBTag.txt, "SB_TTT_PInfo", w-282, 3, SBTag.clr,TEXT_ALIGN_CENTER)
- end
- // Badge BG
- if NumBadge > 0 then
- draw.RoundedBox(0,BDG_X-BadgeW-4,0,BadgeW+2,h-2,Color(0,0,0,150))
- end
- end
- function P:Think() if !ply or !ply:IsValid() then SB_RefreshPList() end end
- P:SetText("")
- P.OnCursorEntered = function() Exited = nil Entered = CurTime() end
- P.OnCursorExited = function() Entered = nil Exited = CurTime() end
- P.DoClick = function()
- local g = ScoreGroup(ply)
- if g == GROUP_FOUND or g == GROUP_NOTFOUND then
- ply.ShowInfo = !ply.ShowInfo
- SB_RefreshPList()
- surface.PlaySound("Devolved/sb_click.wav")
- return
- end
- if ply == LocalPlayer() then return end
- surface.PlaySound("Devolved/sb_click.wav")
- ply.SBTag = (ply.SBTag and ply.SBTag+1) or 1
- if ply.SBTag > #Dev.Tags then ply.SBTag = nil end
- ply.sb_tag = ply.SBTag and Dev.Tags[ply.SBTag]
- end
- P.DoRightClick = function()
- surface.PlaySound("Devolved/sb_rclick.wav")
- if ply == LocalPlayer() then
- B.Opts = DermaMenu()
- B.Opts:AddOption("View Stats",function() Dev.ViewStats(ply) end)
- B.Opts:AddOption("View Playtime",function() Dev.ViewPT(ply) end)
- B.Opts:AddOption("Lookup Bans",function()
- LookupBans(ply:Name(),ply:SteamID())
- end)
- B.Opts:AddOption("View Steam Profile",function()
- SteamProfile(ply:SteamID64(),ply:Name())
- end)
- if LocalPlayer().Ranks and (table.HasValue(LocalPlayer().Ranks,"Moderator") or table.HasValue(LocalPlayer().Ranks,"Administrator") or table.HasValue(LocalPlayer().Ranks,"Manager")) then
- B.Opts:AddOption("View Bans",function()
- for k,v in pairs(DA_SH.Plugins) do
- if v.Name == "ViewBans" then
- net.Start("DA2_RunCMD")
- net.WriteFloat(k)
- net.WriteEntity(ply)
- net.SendToServer()
- break
- end
- end
- end)
- end
- B.Opts:Open()
- return
- end
- B.Opts = DermaMenu()
- // Set tag
- local TagOpts = B.Opts:AddSubMenu("Set Tag")
- TagOpts:AddOption("NONE",function() ply.SBTag = nil ply.sb_tag = nil surface.PlaySound("Devolved/sb_click.wav") end)
- for k,v in pairs(Dev.Tags) do
- TagOpts:AddOption(v.txt,function() ply.SBTag = k ply.sb_tag = Dev.Tags[ply.SBTag] surface.PlaySound("Devolved/sb_click.wav") end)
- end
- // Send trade
- B.Opts:AddOption("Send Trade",function() net.Start("Dev_Trade_Send") net.WriteEntity(ply) net.SendToServer() end)
- B.Opts:AddOption("View Stats",function() Dev.ViewStats(ply) end)
- B.Opts:AddOption("View Playtime",function() Dev.ViewPT(ply) end)
- B.Opts:AddOption("Lookup Bans",function()
- LookupBans(ply:Name(),ply:SteamID())
- end)
- B.Opts:AddOption("View Steam Profile",function()
- SteamProfile(ply:SteamID64(),ply:Name())
- end)
- if LocalPlayer().Ranks and (table.HasValue(LocalPlayer().Ranks,"Moderator") or table.HasValue(LocalPlayer().Ranks,"Administrator") or table.HasValue(LocalPlayer().Ranks,"Manager")) then
- B.Opts:AddOption("View Bans",function()
- for k,v in pairs(DA_SH.Plugins) do
- if v.Name == "ViewBans" then
- net.Start("DA2_RunCMD")
- net.WriteFloat(k)
- net.WriteEntity(ply)
- net.SendToServer()
- break
- end
- end
- end)
- end
- B.Opts:Open()
- end
- for k,v in pairs(badges) do
- local BDG = vgui.Create("DImageButton", P)
- BDG:SetPos(BDG_X-(k*22),3)
- BDG:SetImage(v.img)
- BDG:SetSize(16,16)
- BDG.DoClick = P.DoClick
- BDG.DoRightClick = P.DoRightClick
- // Draw level over shield icon
- if v.img == "icon16/shield.png" then
- BDG:SetTooltip("TTT Level " .. v.txt)
- BDG.PaintOver = function(s,w,h)
- draw.DrawText(v.txt, "SB_TTT_Lvl", 9, 1, Color(255,255,255,230),TEXT_ALIGN_CENTER)
- end
- else
- BDG:SetTooltip(v.txt)
- end
- end
- // End badges -------------------------------
- // Player avatar
- local Av = vgui.Create("AvatarImage",P)
- Av:SetPos(2,0)
- Av:SetSize(22,22)
- Av:SetPlayer(ply)
- // Mute player
- if ply != LocalPlayer() then // No point in muting self
- local Mute = vgui.Create("DButton",P)
- Mute:SetPos(-100,0)
- timer.Simple(.02,function() if Mute:IsValid() then Mute:SetPos(P:GetWide()-24,0) end end)
- timer.Simple(.2,function() if Mute:IsValid() then Mute:SetPos(P:GetWide()-24,0) end end)
- Mute:SetSize(22,22)
- Mute.DoClick = function()
- local muted = ply:IsMuted()
- ply:SetMuted(!muted)
- Mute.img = (!ply:IsMuted() and Material("icon16/sound_mute.png") or ply:IsMuted() and Material("icon16/sound.png"))
- end
- Mute.img = (!ply:IsMuted() and Material("icon16/sound_mute.png") or Material("icon16/sound.png"))
- Mute.Paint = function(s,w,h)
- surface.SetDrawColor( 255, 255, 255, 250 )
- surface.SetMaterial(Mute.img)
- surface.DrawTexturedRect( 3, 3, 16, 16 )
- end
- Mute:SetText("")
- end
- B.Players:AddItem(P)
- // For left click menu in vanilla TTT
- if ply.ShowInfo then
- local Info
- local g = ScoreGroup(ply)
- if g == GROUP_FOUND or g == GROUP_NOTFOUND then
- Info = vgui.Create("TTTScorePlayerInfoSearch")
- Info:SetPlayer(ply)
- Info:SetSize(PLY_W,70)
- Info:UpdatePlayerData()
- end
- if Info then
- B.Players:AddItem(Info)
- BG_Space = BG_Space+Info:GetTall()
- end
- end
- BG_Space = BG_Space+24
- end
- // Add a header/title (for teams)
- SB_AddHeader = function(Text,Clr)
- local H,PLY_W = vgui.Create("DPanel"),B.Players:GetWide()
- H:SetSize(PLY_W,28)
- H.Paint = function(s,w,h)
- draw.RoundedBox(0,0,4,w,h-4,Color(0,0,0,200))
- // Small header BG
- for i=0,B.HeaderAm do
- surface.SetDrawColor( Clr.r, Clr.g, Clr.b, 200 )
- surface.SetMaterial(Dev.SB_Header)
- surface.DrawTexturedRect( i*200, 6, 200, 20 )
- end
- draw.DrawText(Text, "SB_TTT_Header", 9, 6, Color(255,255,255,190),TEXT_ALIGN_LEFT)
- // Ping
- draw.RoundedBox(0,w-79,6,39,h-8,Color(0,0,0,150))
- draw.DrawText("Ping", "SB_TTT_PInfo", w-60, 7, Color(255,255,255,190),TEXT_ALIGN_CENTER)
- // Deaths
- draw.RoundedBox(0,w-140,6,59,h-8,Color(0,0,0,150))
- draw.DrawText("Deaths", "SB_TTT_PInfo", w-111, 7, Color(255,255,255,190),TEXT_ALIGN_CENTER)
- // Score
- draw.RoundedBox(0,w-191,6,49,h-8,Color(0,0,0,150))
- draw.DrawText("Score", "SB_TTT_PInfo", w-167, 7, Color(255,255,255,190),TEXT_ALIGN_CENTER)
- // Karma
- draw.RoundedBox(0,w-246,6,53,h-8,Color(0,0,0,150))
- draw.DrawText("Karma", "SB_TTT_PInfo", w-219, 7, Color(255,255,255,190),TEXT_ALIGN_CENTER)
- // Badges
- draw.RoundedBox(0,BDG_X-60,6,58,h-8,Color(0,0,0,150))
- draw.DrawText("Badges", "SB_TTT_PInfo", BDG_X-4, 7, Color(255,255,255,190),TEXT_ALIGN_RIGHT)
- end
- B.Players:AddItem(H)
- BG_Space = BG_Space+28
- end
- SB_RefreshPList = function()
- BG_Space = 96
- B.Players:Clear()
- local PLYS = {TERROR = {},NOTFOUND = {},FOUND = {},SPEC = {},DS = {},TS = {},DMERS = {}}
- // So we can show DMers
- local SelfGroup = ScoreGroup(SelfDead)
- local SelfDead = LocalPlayer().DeathDM or LocalPlayer():IsSpec() or (SelfGroup == GROUP_SPEC) or (SelfGroup == GROUP_FOUND) or (SelfGroup == GROUP_NOTFOUND)
- for k,v in pairs(player.GetAll()) do
- if !v:IsValid() then continue end
- v.ScoreGroup = ScoreGroup(v)
- if SelfDead and v.DeathDM then table.insert(PLYS.DMERS,v) end
- if v.ScoreGroup == GROUP_TERROR then
- if v:IsDetective() then
- table.insert(PLYS.DS,v)
- elseif (v:IsTraitor() and (LocalPlayer():Alive() and !LocalPlayer():IsSpec() and !LocalPlayer().DeathDM)) then
- table.insert(PLYS.TS,v)
- else
- table.insert(PLYS.TERROR,v)
- end
- elseif v.ScoreGroup == GROUP_FOUND then
- table.insert(PLYS.FOUND,v)
- elseif v.ScoreGroup == GROUP_NOTFOUND then
- table.insert(PLYS.NOTFOUND,v)
- elseif v.ScoreGroup == GROUP_SPEC then
- table.insert(PLYS.SPEC,v)
- end
- end
- for k,v in pairs(PLYS) do
- table.sort(PLYS[k],function(a,b) return a:Frags() > b:Frags() end)
- end
- // Terrorist player list ----------------------
- if #PLYS.TERROR > 0 or #PLYS.TS > 0 or #PLYS.DS > 0 then
- // Terrorist header
- SB_AddHeader("Terrorists (" .. (#PLYS.TERROR)+(#PLYS.DS)+(#PLYS.TS) .. ")",Color(0, 190, 0))
- // Players
- for k,v in pairs(PLYS.DS) do SB_AddPlayer(v) end
- for k,v in pairs(PLYS.TS) do SB_AddPlayer(v) end
- for k,v in pairs(PLYS.TERROR) do SB_AddPlayer(v) end
- end
- // Missing in action list ------------------
- if #PLYS.NOTFOUND > 0 then
- // MIC header
- SB_AddHeader("Missing in Action (" .. #PLYS.NOTFOUND .. ")",Color(255, 205, 0))
- // Players
- for k,v in pairs(PLYS.NOTFOUND) do SB_AddPlayer(v) end
- end
- // Confirmed Dead list ------------------
- if #PLYS.FOUND > 0 then
- // CD header
- SB_AddHeader("Confirmed Dead (" .. #PLYS.FOUND .. ")",Color(196, 0, 0))
- // Players
- for k,v in pairs(PLYS.FOUND) do SB_AddPlayer(v) end
- end
- // Spectator List -------------------
- if #PLYS.SPEC > 0 then
- // Spec header
- SB_AddHeader("Spectators (" .. #PLYS.SPEC .. ")",Color(110, 190, 255))
- // Players
- for k,v in pairs(PLYS.SPEC) do SB_AddPlayer(v) end
- end
- // DMers list ---------------
- if #PLYS.DMERS > 0 then
- // Spec header
- SB_AddHeader("Spectate DMers [F1 > Deathmatch] (" .. #PLYS.DMERS .. ")",Color(158,158,158))
- // Players
- for k,v in pairs(PLYS.DMERS) do SB_AddPlayer(v) end
- end
- GenerateScrollbar(B.Players)
- Dev.SB:SetPos(W*.5-(SB_W*.5),math.Clamp(H*.5-((BG_Space+62)*.5),0,H*.15))
- end
- SB_RefreshPList()
- function B.Players:Think()
- for k,v in pairs(player.GetAll()) do
- local SG = v.ScoreGroup
- if !SG or SG != ScoreGroup(v) then
- SB_RefreshPList()
- end
- end
- end
- // END PLAYER LISTS =============================
- // Show mouse, restore last position
- gui.EnableScreenClicker(true)
- return Dev.SB
- end
- function Dev.DeleteSB()
- if Dev.SB and Dev.SB:IsValid() then
- local MX,MY = gui.MousePos()
- Dev.MouseX = math.Clamp(MX,ScrW()*.2,ScrW()*.8)
- Dev.MouseY = math.Clamp(MY,ScrH()*.14,ScrH()*.87)
- Dev.Closed = CurTime()
- Dev.SB:Close()
- gui.EnableScreenClicker(false)
- end
- end
- // No mouse disappearing/teleporting with scoreboard open!
- local oldClick = gui.EnableScreenClicker
- function gui.EnableScreenClicker(val,...)
- if !val and Dev.SB and Dev.SB:IsValid() and (!Dev.Closed or CurTime()-Dev.Closed > .001) then return end
- return oldClick(val,...)
- end
- local oldSetPos = gui.SetMousePos
- function gui.SetMousePos(...)
- if Dev.SB and Dev.SB:IsValid() and (!Dev.Closed or CurTime()-Dev.Closed > .001) then return end
- return oldSetPos(...)
- end
- timer.Simple(1,function()
- local LastTab = CurTime()
- local GM = GM or GAMEMODE
- function GM:ScoreboardShow()
- if LocalPlayer().DeathDM then
- if CurTime()-LastTab > .5 then
- LastTab = CurTime()
- hook.Call("Rust_TabMenuMain",GAMEMODE)
- hook.Call("Rust_TabMenu",GAMEMODE)
- end
- return
- end
- Dev.CreateSB()
- end
- function GM:ScoreboardHide()
- Dev.DeleteSB()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement