Skip to content

Instantly share code, notes, and snippets.

@PatPeter
Last active May 11, 2019 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatPeter/e773ecc9fb57ef027869a9c41eccc04e to your computer and use it in GitHub Desktop.
Save PatPeter/e773ecc9fb57ef027869a9c41eccc04e to your computer and use it in GitHub Desktop.
Set name and karma colors for TTT scoreboards using TTTScoreboardColorForPlayer and TTTScoreboardColumns
local namecolor = {
dev = Color(100, 240, 105, 255), -- light green
superadmin = Color(220, 180, 0, 255), -- gold
admin = Color(255, 0, 0, 255), -- red
supermod = Color(0, 255, 0, 255), -- green
moderator = Color(0, 0, 255, 255), -- blue
trial = Color(255, 128, 0, 255), -- orange
member = Color(128, 0, 192, 255), -- purple
regular = Color(0, 255, 255 ,255), -- light blue
default = COLOR_WHITE,
};
local karmacolors = {
top = Color(102,255,51,255), -- bright green
max = Color(130,255,130,255), -- light green
high = Color(255,240,135,255), -- light yellow
med = Color(245,220,60,255), -- dark yellow
low = Color(255,180,0,255), -- light orange
min = Color(255,130,0,255), -- dark orange
bottom = Color(204,0,0,255), -- dark red
default = Color(255,255,255,255), -- white
};
hook.Add("TTTScoreboardColorForPlayer", "Unigamia_TTTScoreboardColorForPlayer", function (ply)
if not IsValid(ply) then return namecolor.default end
if ply:SteamID() == "STEAM_0:0:1963640" then
return namecolor.dev
elseif ply:IsSuperAdmin() and GetGlobalBool("ttt_highlight_admins", true) then
return namecolor.superadmin
elseif ply:IsAdmin() and GetGlobalBool("ttt_highlight_admins", true) then
return namecolor.admin
elseif ply:IsUserGroup("supermod") and GetGlobalBool("ttt_highlight_admins", true) then
return namecolor.supermod
elseif ply:IsUserGroup("moderator") and GetGlobalBool("ttt_highlight_admins", true) then
return namecolor.moderator
elseif ply:IsUserGroup("trial") and GetGlobalBool("ttt_highlight_admins", true) then
return namecolor.trial
elseif ply:IsUserGroup("member") then
return namecolor.member
elseif ply:IsUserGroup("regular") then
return namecolor.regular
end
return namecolor.default
end)
hook.Add("TTTScoreboardColumns", "Unigamia_TTTScoreboardColumns", function (panel)
if KARMA.IsEnabled() then
table.remove(panel.cols)
panel:AddColumn( "Karma", function(ply, lbl)
local karma = math.Round(ply:GetBaseKarma())
local color = karmacolors.default;
if karma == 1250 then
color = karmacolors.top
elseif karma > 999 then
color = karmacolors.max
elseif karma > 899 then
color = karmacolors.high
elseif karma > 650 then
color = karmacolors.med
elseif karma > 500 then
color = karmacolors.low
elseif karma > 200 then
color = karmacolors.min
else
color = karmacolors.bottom
end
lbl:SetText(karma)
lbl:SetTextColor(color)
return karma
end, 75)
panel:AddColumn( "Rank", function(ply, lbl)
local name = ""
local color = namecolor.default
if ply:IsSuperAdmin() then
name = "Superadmin"
color = namecolor.superadmin
elseif ply:IsAdmin() then
name = "Admin"
color = namecolor.admin
elseif ply:IsUserGroup("supermod") then
name = "Supermod"
color = namecolor.supermod
elseif ply:IsUserGroup("moderator") then
name = "Moderator"
color = namecolor.moderator
elseif ply:IsUserGroup("trial") then
name = "Trial"
color = namecolor.trial
elseif ply:IsUserGroup("member") then
name = "Member"
color = namecolor.member
elseif ply:IsUserGroup("regular") then
name = "Regular"
color = namecolor.regular
end
lbl:SetText(name)
lbl:SetTextColor(color)
return name
end, 100)
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment