if CLIENT then return end
hook.Add( "Initialize", "UPAULXInit", function()
function ulx.cc_addpassuser( ply, command, argv, args )
if !(#argv >= 4) then
ULib.console( ply, "ulx adduser <user> <group> <type> <pass> <pass_req> <immunity>" )
ULib.console( ply, "user - The user to add [name]" )
ULib.console( ply, "group - Choose \"operator\", \"admin\", or \"superadmin\"" )
ULib.console( ply, "type - Whether to use IP, Name, or steamid to auth [ip/name/steamid]" )
ULib.console( ply, "pass - The user's desired password. Needs 5-20 chars. [password]" )
ULib.console( ply, "pass_req - whether they need a password to stay in the server, or be kicked. (Optional) [0/1]" )
ULib.console( ply, "immunity - Should this player have immunity? Note that superadmins override other players' immunity. (Optional) [0/1]" )
ULib.console( ply, "This user WILL be added to the permanent users list!" )
ULib.console( ply, "If the players's already added, it will clear their allow/deny list." )
ULib.console( ply, "Operators have no default access. This makes them great for \"ulx userallow\"." )
return
end
local target, err = ULib.getUser( argv[ 1 ], _, ply )
if not target then
ULib.tsay( ply, err )
return
end
if target:IsUserGroup( ULib.ACCESS_SUPERADMIN ) and ply:IsValid() and not ply:IsListenServerHost() then
ULib.tsay( ply, "Sorry, for security reasons, you can't change the access of a superadmin!" )
return
end
local group = argv[ 2 ]
local typ = string.lower( argv[3] )
if !((typ == "name") or (typ == "ip") or (typ == "steamid") )then
ULib.tsay( ply, "Invalid type!" )
return
end
local pass = argv[4]
if !(string.len( pass ) >= 5 && string.len( pass ) <= 20) then
ULib.tsay( ply, "Invalid number of password chars!" )
return
end
local pass_req = util.tobool( argv[5] )
local immunity = util.tobool( argv[ 6 ] )
if (not ULib.ucl.groups[ group ] and not group == ULib.ACCESS_OPERATOR and not group == ULib.ACCESS_ADMIN and not group == ULib.ACCESS_SUPERADMIN) or group == "user" then
ULib.tsay( ply, "Invalid group!" )
return
end
local groups = { group }
if immunity then table.insert( groups, ULib.ACCESS_IMMUNITY ) end
local id;
if (typ == "name") then
id = target:GetName()
elseif (typ == "ip") then
id = target:IPAddress()
elseif (typ == "steamid") then
id = target:SteamID()
end
local info = ULib.ucl.authed[ target ]
if not info or info.type == "guest" then -- If they don't have an account, make a new one. You can't recycle because this add's ALL info.
ULib.ucl.addUser( target:Nick():lower(), typ, id, groups, {allow={}, deny={}} , pass, pass_req, true )
end
if immunity then
ulx.logUserAct( ply, target, "#A added user #T to group \"" .. group .. "\" with immunity" )
else
ulx.logUserAct( ply, target, "#A added user #T to group \"" .. group .. "\"" )
end
end
ulx.concommand( "addpassuser", ulx.cc_addpassuser, "<user> <group> <type> <pass> <pass_req> <immunity> - Use with no args for more help.", ULib.ACCESS_SUPERADMIN, _, _, ulx.ID_PLAYER_HELP )
end )