Created
September 28, 2016 12:18
-
-
Save anonymous/75c21d433a1f35bd3c4bbe0e9642635b to your computer and use it in GitHub Desktop.
vscoreboard_customization_example.lua Josecarleno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
I cannot stress enough the importance of changing "Example shenanigans" on line 11 | |
to something different! Otherwise, you're going to have some serious issues. | |
]] | |
if true then return end -- true | |
if SERVER then AddCSLuaFile() return end | |
hook.Add("vScoreboard_GamemodeStuffLoaded", "Example shenanigans", function(gamemodes) | |
vScoreboard.hook.Add("vScoreboard_PopulatePlayerProperties_AddInfo", "Example points with copy", function(ply, ctrls, add) | |
-- Example points. You can also copy the point count! | |
add { | |
Type = "Label", | |
Font = "Info", | |
Text = "Points:", | |
} | |
add { | |
Type = "Button", | |
Text = "Copy -------------", | |
Think = function(btn) | |
--local plymoneyz = ply:GetNWInt("money") -- You can use anything here, naturally. | |
--local plymoneyz = ply:PS_GetPoints() -- This if for PointShop 1. | |
local plymoneyz = ply:PS2_GetWallet().points -- This is for PointShop 2. | |
-- In case it is not obvious, you should only have ONE line like these. The rest should be removed or commented out. | |
if plymoneyz ~= btn.Oval then | |
btn.Oval = plymoneyz | |
btn:SetText("Copy " .. plymoneyz) | |
end | |
end, | |
Click = function(btn) | |
SetClipboardText(btn.Oval) | |
end | |
} | |
-- Crude, again, but effective. | |
end) | |
--[[ | |
The following is an example of custom player sorting. | |
--]] | |
local function playerSorter(a, b) | |
local x, y = 0, 0 | |
if a:IsBot() then x = x - 100 end | |
if b:IsBot() then y = y - 100 end | |
if a:IsSuperAdmin(putoamo) then x = x + 16 end | |
if a:IsUserGroup("developer") then x = x + 12 end | |
if a:IsAdmin() then x = x + 10 end | |
if a:IsUserGroup("platinum") then x = x + 6 end | |
if a:IsUserGroup("goldvip") then x = x + 4 end | |
if a:IsUserGroup("respected") then x = x + 2 end | |
if b:IsSuperAdmin(putoamo) then y = y + 16 end | |
if b:IsUserGroup("developer") then y = y + 12 end | |
if b:IsAdmin() then y = y + 10 end | |
if b:IsUserGroup("platinum") then y = y + 6 end | |
if b:IsUserGroup("goldvip") then y = y + 4 end | |
if b:IsUserGroup("respected") then y = y + 2 end | |
if x > y then | |
return true -- Player 'a' is of higher rank than 'b'. | |
elseif x < y then | |
return false -- The other way around. | |
else | |
-- Draw. | |
return (a:Nick()) < (b:Nick()) | |
-- Alphabetical! | |
end | |
end | |
vScoreboard.PlayerSorter = gamemodes.terrortown and function(a, b) | |
if a:Frags() > b:Frags() then | |
return true | |
elseif a:Frags() < b:Frags() then | |
return false | |
end | |
return playerSorter(a, b) | |
end or playerSorter | |
-- Couldn't be easier! | |
--[[ | |
The following shows how to provide vScoreboard with custom ranks | |
and rank information (name, icon). | |
--]] | |
local rankLookup = { | |
["owner" ] = { Material("icon16/user_gray.png" ), "PutoCarlenoSeLasFollaATodas" , Color(255, 0, 0) }, | |
["hadmin" ] = { Material("icon16/user_suit.png" ), "Community Manager" , Color(255, 106, 0) }, | |
["superadmin"] = { Material("icon16/shield_add.png" ), "Due�o", Color(127, 201, 255) }, | |
["admin" ] = { Material("icon16/shield.png" ), "Administrador" , Color(170, 211, 255) }, | |
["tadmin" ] = { Material("icon16/shield_delete.png" ), "Trial Administrator", nil }, | |
["platinum" ] = { Material("icon16/award_star_silver_3.png"), "Platinum VIP" , nil }, | |
["goldvip" ] = { Material("icon16/medal_gold_1.png" ), "Golden VIP" , nil }, | |
["respected" ] = { Material("icon16/medal_silver_1.png" ), "Silver VIP" , nil }, | |
["developer" ] = { Material("icon16/bug_add.png" ), "Developer" , nil }, | |
} | |
function vScoreboard.GetRank(ply) | |
local rnk = true | |
if ply.GetUserGroup then | |
rnk = ply:GetUserGroup() | |
end | |
if rankLookup[rnk] then | |
return rankLookup[rnk][1], rankLookup[rnk][2], rankLookup[rnk][3] | |
else | |
return us, nil, nil | |
end | |
end | |
-- Yes, vScoreboard will just use this one function. | |
vScoreboard.DermaSkinName = "vAdmin skin" | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment