local seemodchatAccess = "seemodchat"
if SERVER then ULib.ucl.registerAccess( seemodchatAccess, ULib.ACCESS_ADMIN, "Ability to see the mod chat", "Other" ) end
function ulx.modchat( calling_ply, message )
local players = ULib.getUsers( "#superadmin, #admin, #moderator ", true )
for i=#players, 1, -1 do
local v = players[ i ]
if ULib.ucl.query( calling_ply, seemodchatAccess ) and v~=calling_ply then
if ULib.ucl.query( calling_ply, seemodchatAccess ) then
if not calling_ply:IsValid() then
ULib.tsayColor( v, 1, "(Mod Chat)", console, "(Console)", mod, ": ", message )
else
ULib.tsayColor( v, 1, "(Mod Chat) ", team.GetColor(calling_ply:Team()), calling_ply:Nick(), mod, ": ", message )
end
end
end
if v == calling_ply then
ULib.tsayColor( v, 1, "(Mod Chat) ", team.GetColor(calling_ply:Team()), calling_ply:Nick(), mod, ": ", message )
end
end
local logFile = ulx.convar( "logFile", "1", "Log to file (Can still echo if off). This is a global setting, nothing will be logged to file with this off.", ULib.ACCESS_SUPERADMIN )
if not calling_ply:IsValid() and logFile:GetBool() then
ulx.logString( "(Mod Chat) " .. "(Console)" .. ": " .. message, true )
elseif logFile:GetBool() then
ulx.logString( "(Mod Chat) " .. calling_ply:Nick() .. ": " .. message, true )
end
end
local modchat = ulx.command( CATEGORY_NAME, "ulx modchat", ulx.modchat, "/m", true, true )
modchat:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
modchat:defaultAccess( ULib.ACCESS_ADMIN )
modchat:help( "Sends a message to all currently connected moderators" )