Version 2.7.0

Implemented a modular admin addon dependency. Removed lots of Ifs and moved the code to each admin addon folder. This way is more elegant, and should be easier to port this addon to other admin addons.
This commit is contained in:
Júlio C. Oliveira 2024-05-20 12:57:19 -03:00
parent 22fd9e7467
commit 7082dfea59
19 changed files with 251 additions and 136 deletions

View File

@ -1,8 +1,8 @@
"AddonInfo"
{
"name" "SUI Scoreboard"
"version" "2.6.9"
"up_date" "2024-05-19"
"version" "2.7.0"
"up_date" "2024-05-20"
"author_name" "Dathus [BR]"
"author_url" "http://www.juliocesar.me"
"info" "This is a Scoreboard based on SUI Scoreboard v2 developed by suicidal.banana, was modified, fixed, improved and ported to Garry's Mod 13, to work with ULX v3, Exsto, Maestro and Mercury."

View File

@ -12,14 +12,14 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2024-05-19 10:24 PM (UTC -03:00)
Version 2.7 - 2024-05-20 12:17 PM (UTC -03:00)
]]--
-- Setup Class
Scoreboard = {}
-- Scoreboard version
Scoreboard.version = "2.6.9"
Scoreboard.version = "2.7.0"
--Setup Loading Log Formatation
function loadingLog (text)
@ -41,7 +41,7 @@ Msg( "\n/====================================\\\n")
Msg( "|| SUI Scoreboard ||\n" )
Msg( "||----------------------------------||\n" )
loadingLog("Version " .. Scoreboard.version)
loadingLog("Updated on 2024-05-19 10:24 PM")
loadingLog("Updated on 2024-05-20 12:17 PM")
Msg( "\\====================================/\n\n" )
if SERVER then

View File

@ -12,14 +12,14 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2023-06-05 8:00 PM(UTC -03:00)
Version 2.7 - 2023-06-05 8:00 PM(UTC -03:00)
]]--
local PLUGIN = {}
PLUGIN.Title = "SUI Scoreboard v2.6 for Evolve"
PLUGIN.Description = "SUI Scoreboard v2.6 ported for Evolve!"
PLUGIN.Author = ".Z. Nexus"
PLUGIN.Author = "Dathus [BR]"
function PLUGIN:ScoreboardShow()
return Scoreboard.Show()
@ -34,4 +34,46 @@ function PLUGIN:PlayerInitialSpawn( ply )
Scoreboard.PlayerSpawn( ply )
end
if CLIENT then
-- Kick player
Scoreboard.kick = function (ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "ev kick \"".. ply:Nick().. "\" \"Kicked By Administrator\"" )
end
end
-- Permanent ban player
Scoreboard.pBan = function(ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "ev ban \"".. ply:Nick().. "\" 0 \"Kicked By Administrator\"" )
end
end
-- Ban player
Scoreboard.ban = function(ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "ev ban \"".. ply:Nick().. "\" 60 \"Kicked By Administrator\"" )
end
end
-- Get player's Team Name
Scoreboard.getGroup = function (ply)
return evolve.ranks[ ply:EV_GetRank() ].Title
end
-- Get player's Played time
Scoreboard.getPlayerTime = function (ply)
return evolve:Time() - ply:GetNWInt( "EV_JoinTime" ) + ply:GetNWInt( "EV_PlayTime" )
end
elseif SERVER then
Scoreboard.SendColor = function (ply)
tColor = evolve.ranks[ ply:EV_GetRank() ].Color
net.Start("SUIScoreboardPlayerColor")
net.WriteTable(tColor)
net.Send(ply)
end
end
evolve:RegisterPlugin( PLUGIN )

View File

@ -12,7 +12,7 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2023-06-05 8:00 PM(UTC -03:00)
Version 2.7 - 2023-06-05 8:00 PM(UTC -03:00)
]]--
@ -22,7 +22,7 @@ PLUGIN:SetInfo({
Name = "SUI Scoreboard v2.6 for Exsto",
ID = "sui-scoreboard-v2-6",
Desc = "SUI Scoreboard v2.6 ported for Exsto!",
Owner = ".Z. Nexus"
Owner = "Dathus [BR]"
})
function PLUGIN:Init()
@ -40,4 +40,46 @@ function PLUGIN:PlayerInitialSpawn( ply )
Scoreboard.PlayerSpawn( ply )
end
if CLIENT then
-- Kick player
Scoreboard.kick = function (ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "exsto kick \"".. ply:Nick().. "\" \"Kicked By Administrator\"" )
end
end
-- Permanent ban player
Scoreboard.pBan = function(ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "exsto ban \"".. ply:Nick().. "\" 0 \" Banned permanently by Administrator\"" )
end
end
-- Ban player
Scoreboard.ban = function(ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "exsto ban \"".. ply:Nick().. "\" 60 \" Banned for 1 hour by Administrator\"" )
end
end
-- Get player's Team Name
Scoreboard.getGroup = function (ply)
return exsto.Ranks[ply:GetRank()].Name
end
-- Get player's Played time
Scoreboard.getPlayerTime = function (ply)
-- Get Time
return ply:GetNWInt( "Time_Fixed" ) + (CurTime() - ply:GetNWInt( "Time_Join" ))
end
elseif SERVER then
Scoreboard.SendColor = function (ply)
tColor = team.GetColor( ply:Team())
net.Start("SUIScoreboardPlayerColor")
net.WriteTable(tColor)
net.Send(ply)
end
end
PLUGIN:Register()

View File

@ -12,14 +12,57 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2023-06-05 8:00 PM(UTC -03:00)
Version 2.7 - 2023-06-05 8:00 PM(UTC -03:00)
]]--
if SERVER then
AddCSLuaFile()
hook.Add("PlayerInitialSpawn", "SUISCOREBOARD-Spawn", Scoreboard.PlayerSpawn)
Scoreboard.SendColor = function (ply)
tColor = maestro.rankcolor(maestro.userrank(ply)) or team.GetColor(ply:Team())
net.Start("SUIScoreboardPlayerColor")
net.WriteTable(tColor)
net.Send(ply)
end
elseif CLIENT then
hook.Add("ScoreboardShow","SUISCOREBOARD-Show", Scoreboard.Show)
hook.Add("ScoreboardHide", "SUISCOREBOARD-Hide", Scoreboard.Hide)
-- Kick player
Scoreboard.kick = function (ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "ms kick \"$" .. ply:SteamID() .. "\" \"Kicked By Administrator\"" )
end
end
-- Permanent ban player
Scoreboard.pBan = function(ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "ms ban \"$" .. ply:SteamID() .. "\" 0 \"Banned permanently by Administrator\"" )
end
end
-- Ban player
Scoreboard.ban = function(ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "ms ban \"$" .. ply:SteamID() .. "\" 1h \"Banned permanently by Administrator\"" )
end
end
-- Get player's Team Name
Scoreboard.getGroup = function (ply)
return maestro.userrank(ply)
end
-- Get player's Played time
Scoreboard.getPlayerTime = function (ply)
if maestro_promote then
return CurTime() - ply:GetNWInt("maestro-promote", CurTime())
else
-- Get Time
return ply:GetNWInt( "Time_Fixed" ) + (CurTime() - ply:GetNWInt( "Time_Join" ))
end
end
end

View File

@ -12,9 +12,41 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2024-05-19 10:47 AM(UTC -03:00)
Version 2.7 - 2024-05-19 10:47 AM(UTC -03:00)
]]--
hook.Add("ScoreboardShow","SUISCOREBOARD-Show", Scoreboard.Show)
hook.Add("ScoreboardHide", "SUISCOREBOARD-Hide", Scoreboard.Hide)
hook.Add("ScoreboardHide", "SUISCOREBOARD-Hide", Scoreboard.Hide)
-- Kick player
Scoreboard.kick = function (ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "hg kick \"" .. ply:SteamID() .. "\" \"Kicked By Administrator\"" )
end
end
-- Permanent ban player
Scoreboard.pBan = function(ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "hg ban \"" .. ply:SteamID() .. "\" 0 \"Quick ban via scoreboard\"" )
end
end
-- Ban player
Scoreboard.ban = function(ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "hg ban \"" .. ply:SteamID() .. "\" 60 \"Quick ban via scoreboard\"" )
end
end
-- Get player's Team Name
Scoreboard.getGroup = function (ply)
return team.GetName(ply:Team())
end
-- Get player's Played time
Scoreboard.getPlayerTime = function (ply)
return ply:GetNWInt("ranktime", 0)
end

View File

@ -12,8 +12,17 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2024-05-19 10:47 AM(UTC -03:00)
Version 2.7 - 2024-05-19 10:47 AM(UTC -03:00)
]]--
hook.Add("PlayerInitialSpawn", "SUISCOREBOARD-Spawn", Scoreboard.PlayerSpawn)
hook.Add("PlayerInitialSpawn", "SUISCOREBOARD-Spawn", Scoreboard.PlayerSpawn)
Scoreboard.SendColor = function (ply)
tColor = Mercury.Ranks.RankTable[ply:GetNWString("UserRank")].color
net.Start("SUIScoreboardPlayerColor")
net.WriteTable(tColor)
net.Send(ply)
end

View File

@ -12,7 +12,7 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2023-06-05 8:00 PM(UTC -03:00)
Version 2.7 - 2023-06-05 8:00 PM(UTC -03:00)
]]--

View File

@ -12,86 +12,10 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2023-06-06 8:00 PM(UTC -03:00)
Version 2.7 - 2023-06-06 8:00 PM(UTC -03:00)
]]--
-- Kick player
Scoreboard.kick = function (ply)
if ply:IsValid() then
if exsto ~= nil then
LocalPlayer():ConCommand( "exsto kick \"".. ply:Nick().. "\" \"Kicked By Administrator\"" )
elseif ulx ~= nil then
LocalPlayer():ConCommand( "ulx kick \"".. ply:Nick().. "\" \"Kicked By Administrator\"" )
elseif evolve ~= nil then
LocalPlayer():ConCommand( "ev kick \"".. ply:Nick().. "\" \"Kicked By Administrator\"" )
elseif maestro ~= nil then
LocalPlayer():ConCommand( "ms kick \"$" .. ply:SteamID() .. "\" \"Kicked By Administrator\"" )
elseif Mercury~=nil then
LocalPlayer():ConCommand( "hg kick \"" .. ply:SteamID() .. "\" \"Kicked By Administrator\"" )
end
end
end
-- Permanent ban player
Scoreboard.pBan = function(ply)
if ply:IsValid() then
if exsto ~= nil then
LocalPlayer():ConCommand( "exsto ban \"".. ply:Nick().. "\" 0 \" Banned permanently by Administrator\"" )
elseif ulx ~= nil then
LocalPlayer():ConCommand( "ulx ban \"".. ply:Nick().. "\" 0 \" Banned permanently by Administrator\"" )
elseif evolve ~= nil then
LocalPlayer():ConCommand( "ev ban \"".. ply:Nick().. "\" 0 \"Kicked By Administrator\"" )
elseif maestro ~= nil then
LocalPlayer():ConCommand( "ms ban \"$" .. ply:SteamID() .. "\" 0 \"Banned permanently by Administrator\"" )
elseif Mercury ~=nil then
LocalPlayer():ConCommand( "hg ban \"" .. ply:SteamID() .. "\" 0 \"Quick ban via scoreboard\"" )
end
end
end
-- Ban player
Scoreboard.ban = function(ply)
if ply:IsValid() then
if exsto ~= nil then
LocalPlayer():ConCommand( "exsto ban \"".. ply:Nick().. "\" 60 \" Banned for 1 hour by Administrator\"" )
elseif ulx ~= nil then
LocalPlayer():ConCommand( "ulx ban \"".. ply:Nick().. "\" 60 \" Banned for 1 hour by Administrator\"" )
elseif evolve ~= nil then
LocalPlayer():ConCommand( "ev ban \"".. ply:Nick().. "\" 60 \"Kicked By Administrator\"" )
elseif maestro ~= nil then
LocalPlayer():ConCommand( "ms ban \"$" .. ply:SteamID() .. "\" 1h \"Banned permanently by Administrator\"" )
end
end
end
-- Get XGUI Team Name by group
Scoreboard.getXGUITeamName = function (check_group)
for _, team in ipairs( ulx.teams ) do
for _, group in ipairs( team.groups ) do
if group == check_group then
return team.name
end
end
end
return check_group
end
-- Get player's Team Name
Scoreboard.getGroup = function (ply)
if exsto ~= nil then
return exsto.Ranks[ply:GetRank()].Name
elseif ulx ~= nil then
return Scoreboard.getXGUITeamName(ply:GetUserGroup())
elseif evolve ~= nil then
return evolve.ranks[ ply:EV_GetRank() ].Title
elseif maestro ~= nil then
return maestro.userrank(ply)
elseif Mercury ~= nil then
return team.GetName(ply:Team())
end
end
-- Create Scoreboard VGUI
Scoreboard.CreateVGUI = function()
if Scoreboard.vgui then
@ -147,24 +71,6 @@ Scoreboard.formatTime = function (time)
return string.format( str.."%02ih %02im %02is", h, m, s )
end
-- Get player's Played time
Scoreboard.getPlayerTime = function (ply)
-- Check if ULX and uTime is Installed
if ulx ~= nil and ply:GetNWInt( "TotalUTime", -1 ) ~= -1 then
-- Get player's played time
return math.floor((ply:GetUTime() + CurTime() - ply:GetUTimeStart()))
elseif evolve ~= nil then
return evolve:Time() - ply:GetNWInt( "EV_JoinTime" ) + ply:GetNWInt( "EV_PlayTime" )
elseif maestro_promote then
return CurTime() - ply:GetNWInt("maestro-promote", CurTime())
elseif Mercury~=nil then
return ply:GetNWInt("ranktime", 0)
else
-- Get Time
return ply:GetNWInt( "Time_Fixed" ) + (CurTime() - ply:GetNWInt( "Time_Join" ))
end
end
-- Get Local Player Color
Scoreboard.netGetPlayerColor = function(ply)
Scoreboard.playerColor = net.ReadTable()

View File

@ -12,7 +12,7 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2023-06-06 8:00 PM(UTC -03:00)
Version 2.7 - 2023-06-06 8:00 PM(UTC -03:00)
]]--

View File

@ -12,7 +12,7 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2023-06-06 8:00 PM(UTC -03:00)
Version 2.7 - 2023-06-06 8:00 PM(UTC -03:00)
]]--

View File

@ -12,7 +12,7 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2023-06-06 8:00 PM(UTC -03:00)
Version 2.7 - 2023-06-06 8:00 PM(UTC -03:00)
]]--

View File

@ -12,7 +12,7 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2024-05-19 11:25 AM (UTC -03:00)
Version 2.7 - 2024-05-19 11:25 AM (UTC -03:00)
]]--

View File

@ -12,7 +12,7 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2024-05-19 11:25 AM(UTC -03:00)
Version 2.7 - 2024-05-19 11:25 AM(UTC -03:00)
]]--

View File

@ -12,7 +12,7 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2023-06-06 8:00 PM(UTC -03:00)
Version 2.7 - 2023-06-06 8:00 PM(UTC -03:00)
]]--

View File

@ -12,7 +12,7 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2023-06-06 8:00 PM(UTC -03:00)
Version 2.7 - 2023-06-06 8:00 PM(UTC -03:00)
]]--

View File

@ -12,28 +12,12 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2024-05-19 10:24 PM (UTC -03:00)
Version 2.7 - 2024-05-19 10:24 PM (UTC -03:00)
]]--
util.AddNetworkString( "SUIScoreboardPlayerConnecting" )
Scoreboard.SendColor = function (ply)
if evolve then
tColor = evolve.ranks[ ply:EV_GetRank() ].Color
elseif maestro then
tColor = maestro.rankcolor(maestro.userrank(ply)) or team.GetColor(ply:Team())
elseif Mercury then
tColor = Mercury.Ranks.RankTable[ply:GetNWString("UserRank")].color
else
tColor = team.GetColor( ply:Team())
end
net.Start("SUIScoreboardPlayerColor")
net.WriteTable(tColor)
net.Send(ply)
end
--- When the player joins the server we need to restore the NetworkedInt's
Scoreboard.PlayerSpawn = function ( ply )
timer.Simple( 5, function() Scoreboard.UpdatePlayerRatings( ply ) end) -- Wait a few seconds so we avoid timeouts.

View File

@ -12,7 +12,7 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2023-06-06 8:00 PM(UTC -03:00)
Version 2.7 - 2023-06-06 8:00 PM(UTC -03:00)
]]--

View File

@ -12,14 +12,71 @@ Copyright only on the code that I wrote, my implementation and fixes and etc, Th
----------------------------------------------------------------------------------------------------------------------------
$Id$
Version 2.6 - 2023-06-06 8:00 PM(UTC -03:00)
Version 2.7 - 2023-06-06 8:00 PM(UTC -03:00)
]]--
if SERVER then
AddCSLuaFile()
hook.Add("PlayerInitialSpawn", "SUISCOREBOARD-Spawn", Scoreboard.PlayerSpawn)
Scoreboard.SendColor = function (ply)
tColor = team.GetColor( ply:Team())
net.Start("SUIScoreboardPlayerColor")
net.WriteTable(tColor)
net.Send(ply)
end
elseif CLIENT then
hook.Add("ScoreboardShow","SUISCOREBOARD-Show", Scoreboard.Show)
hook.Add("ScoreboardHide", "SUISCOREBOARD-Hide", Scoreboard.Hide)
-- Kick player
Scoreboard.kick = function (ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "ulx kick \"".. ply:Nick().. "\" \"Kicked By Administrator\"" )
end
end
-- Permanent ban player
Scoreboard.pBan = function(ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "ulx ban \"".. ply:Nick().. "\" 0 \" Banned permanently by Administrator\"" )
end
end
-- Ban player
Scoreboard.ban = function(ply)
if ply:IsValid() then
LocalPlayer():ConCommand( "ulx ban \"".. ply:Nick().. "\" 60 \" Banned for 1 hour by Administrator\"" )
end
end
-- Get XGUI Team Name by group
Scoreboard.getXGUITeamName = function (check_group)
for _, team in ipairs( ulx.teams ) do
for _, group in ipairs( team.groups ) do
if group == check_group then
return team.name
end
end
end
return check_group
end
-- Get player's Team Name
Scoreboard.getGroup = function (ply)
return Scoreboard.getXGUITeamName(ply:GetUserGroup())
end
-- Get player's Played time
Scoreboard.getPlayerTime = function (ply)
-- Check if ULX and uTime is Installed
if ply:GetNWInt( "TotalUTime", -1 ) ~= -1 then
-- Get player's played time
return math.floor((ply:GetUTime() + CurTime() - ply:GetUTimeStart()))
else
-- Get Time
return ply:GetNWInt( "Time_Fixed" ) + (CurTime() - ply:GetNWInt( "Time_Join" ))
end
end
end