Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new logging type: "Admin only" #165

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lua/ulx/log.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local logEcho = ulx.convar( "logEcho", "2", "Echo mode 0-Off 1-Anonymous 2-Full", ULib.ACCESS_SUPERADMIN )
local logEcho = ulx.convar( "logEcho", "3", "Echo mode 0-Off 1-Anonymous 2-Full 3-Admin Only", ULib.ACCESS_SUPERADMIN )
local logEchoColors = ulx.convar( "logEchoColors", "1", "Whether or not echoed commands in chat are colored", ULib.ACCESS_SUPERADMIN )
local logEchoColorDefault = ulx.convar( "logEchoColorDefault", "151 211 255", "The default text color (RGB)", ULib.ACCESS_SUPERADMIN )
local logEchoColorConsole = ulx.convar( "logEchoColorConsole", "0 0 0", "The color that Console gets when using actions", ULib.ACCESS_SUPERADMIN )
Expand All @@ -24,6 +24,9 @@ ULib.ucl.registerAccess( seeanonymousechoAccess, ULib.ACCESS_ADMIN, "Ability to
local spawnechoAccess = "ulx spawnecho"
ULib.ucl.registerAccess( spawnechoAccess, ULib.ACCESS_ADMIN, "Ability to see spawn echoes and steamids from joined players in console", "Other" ) -- Give admins access to see spawn echoes by default

local seeadminonlyechoAccess = "ulx seeadminonlyechoes"
ULib.ucl.registerAccess(seeadminonlyechoAccess, ULib.ACCESS_ADMIN, "Ability to see who uses a command even with ulx logEcho set to 3", "Other") -- Allows only admins to see command echoes, no one else

local curDateStr = os.date( "%Y-%m-%d" ) -- This will hold the date string (YYYY-mm-dd) we think it is right now.

-- Utility stuff for our logs...
Expand Down Expand Up @@ -350,6 +353,7 @@ end

local function makePlayerList( calling_ply, target_list, showing_ply, use_self_suffix, is_admin_part )
local players = player.GetAll()

-- Is the calling player acting anonymously in the eyes of the player this is being showed to?
local anonymous = showing_ply ~= "CONSOLE" and not ULib.ucl.query( showing_ply, seeanonymousechoAccess ) and logEcho:GetInt() == 1

Expand Down Expand Up @@ -434,6 +438,15 @@ function ulx.fancyLogAdmin( calling_ply, format, ... )
end
end
end

local adminOnly = logEcho:GetInt() == 3
if adminOnly then
for i=#players, 1, -1 do
if not ULib.ucl.query( players[ i ], seeadminonlyechoAccess ) and players[ i ] ~= calling_ply then
table.remove( players, i )
end
end
end
table.insert( players, "CONSOLE" ) -- Dummy player used for logging and printing to dedicated console window

local playerStrs = {}
Expand Down
2 changes: 1 addition & 1 deletion lua/ulx/xgui/settings/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ xgui.addSubModule( "ULX Ban Message", plist, nil, "server" )
local plist = xlib.makelistlayout{ w=275, h=322, parent=xgui.null }
plist:Add( xlib.makelabel{ label="Command/Event echo settings" } )
plist:Add( xlib.makecheckbox{ label="Echo players vote choices", repconvar="ulx_voteEcho" } )
plist:Add( xlib.makecombobox{ repconvar="ulx_logEcho", isNumberConvar=true, choices={ "Do not echo admin commands", "Echo admin commands anonymously", "Echo commands and identify admin" } } )
plist:Add( xlib.makecombobox{ repconvar="ulx_logEcho", isNumberConvar=true, choices={ "Do not echo admin commands", "Echo admin commands anonymously", "Echo commands and identify admin", "Echo admin commands to admins only" } } )
plist:Add( xlib.makecombobox{ repconvar="ulx_logSpawnsEcho", isNumberConvar=true, choices={ "Do not echo spawns", "Echo spawns to admins only", "Echo spawns to everyone" } } )
plist:Add( xlib.makecheckbox{ label="Enable colored event echoes", repconvar="ulx_logEchoColors" } )

Expand Down