• Print

Author Topic: Neato  (Read 15 times)

0 Members and 1 Guest are viewing this topic.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Neato
« on: November 27, 2007, 07:31:53 pm »
Thank you google, for finding this for me. :)

Code: Lua
  1. if CLIENT then return end
  2.  
  3. hook.Add( "Initialize", "UPAULXInit", function()
  4.  
  5. function ulx.cc_addpassuser( ply, command, argv, args )
  6.         if !(#argv >= 4)  then
  7.                 ULib.console( ply, "ulx adduser <user> <group> <type> <pass> <pass_req> <immunity>" )
  8.                 ULib.console( ply, "user - The user to add [name]" )
  9.                 ULib.console( ply, "group - Choose \"operator\", \"admin\", or \"superadmin\"" )
  10.                 ULib.console( ply, "type - Whether to use IP, Name, or steamid to auth [ip/name/steamid]" )
  11.                 ULib.console( ply, "pass - The user's desired password. Needs 5-20 chars. [password]" )
  12.                 ULib.console( ply, "pass_req - whether they need a password to stay in the server, or be kicked. (Optional) [0/1]" )
  13.                 ULib.console( ply, "immunity - Should this player have immunity? Note that superadmins override other players' immunity. (Optional) [0/1]" )
  14.                 ULib.console( ply, "This user WILL be added to the permanent users list!" )
  15.                 ULib.console( ply, "If the players's already added, it will clear their allow/deny list." )
  16.                 ULib.console( ply, "Operators have no default access. This makes them great for \"ulx userallow\"." )
  17.                 return
  18.         end
  19.  
  20.         local target, err = ULib.getUser( argv[ 1 ], _, ply )
  21.         if not target then
  22.                 ULib.tsay( ply, err )
  23.                 return
  24.         end
  25.  
  26.         if target:IsUserGroup( ULib.ACCESS_SUPERADMIN ) and ply:IsValid() and not ply:IsListenServerHost() then
  27.                 ULib.tsay( ply, "Sorry, for security reasons, you can't change the access of a superadmin!" )
  28.                 return
  29.         end
  30.  
  31.         local group = argv[ 2 ]
  32.         local typ = string.lower( argv[3] )
  33.         if !((typ == "name") or (typ == "ip") or (typ == "steamid") )then
  34.                 ULib.tsay( ply, "Invalid type!" )
  35.                 return
  36.         end
  37.        
  38.         local pass = argv[4]
  39.         if !(string.len( pass ) >= 5 && string.len( pass ) <= 20) then
  40.                 ULib.tsay( ply, "Invalid number of password chars!" )
  41.                 return
  42.         end
  43.         local pass_req = util.tobool( argv[5] )
  44.         local immunity = util.tobool( argv[ 6 ] )
  45.        
  46.         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
  47.                 ULib.tsay( ply, "Invalid group!" )
  48.                 return
  49.         end
  50.        
  51.         local groups = { group }
  52.         if immunity then table.insert( groups, ULib.ACCESS_IMMUNITY ) end
  53.         local id;
  54.         if (typ == "name") then
  55.                 id = target:GetName()
  56.         elseif (typ == "ip") then
  57.                 id = target:IPAddress()
  58.         elseif (typ == "steamid") then
  59.                 id = target:SteamID()
  60.         end
  61.        
  62.        
  63.         local info = ULib.ucl.authed[ target ]
  64.         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.
  65.                 ULib.ucl.addUser( target:Nick():lower(), typ, id, groups, {allow={}, deny={}} , pass, pass_req, true )
  66.         end
  67.  
  68.         if immunity then
  69.                 ulx.logUserAct( ply, target, "#A added user #T to group \"" .. group .. "\" with immunity" )
  70.         else
  71.                 ulx.logUserAct( ply, target, "#A added user #T to group \"" .. group .. "\"" )
  72.         end
  73. end
  74.  
  75. 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 )
  76.  
  77. end )
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Neato
« Reply #1 on: November 28, 2007, 04:54:30 am »
What? Someone else wrote a command for ULX?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Neato
« Reply #2 on: November 28, 2007, 08:34:41 am »
Yep.
Experiencing God's grace one day at a time.

  • Print