Author Topic: Loading the users.txt without restarting.  (Read 4598 times)

0 Members and 1 Guest are viewing this topic.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Loading the users.txt without restarting.
« on: December 04, 2007, 05:19:12 AM »
The title is a little cloudy.. so here is what I need to know.

If I add someone to my Data/ULib/users.txt file manually by using a template user that I have and filling in name and SID, I would like to be able to refresh the servers understanding of that file without having to restart.

I have carved my server and (using ULX) into a very community based server, and I have registrations and quite a few ranks for the members to achieve. A lot of times someone will E-Mail me if they are to move up in ranks, or will submit my form and they wont be on the server for me to add them/change their rank, so I'll just change it in the users.txt (before you say its not smart to do that, lol, I know what I'm doing ;))
ANyways.. I suggested that there be a command to add a user that isnt on, such as ulx adduserid <name> <ID> <group> [<immune?>] and I really hope you guys pick that up, but until you do, I'll continue to just add them like that.

Now that you know what/why Im doing this, here is what I need to know...

Is there a way.. a lua file I can "lua_openscript" or something that will make it to where if I were to have added someone to the users.txt file and the server had NOT restarted since then, they will join the server with the new rank?

I know im not being clear.. lol.. so here is an example if you need it..
1. Zach is not in any groups.. he is a user.
2. I add Zach to my users.txt file as an admin
3. Zach then joins the server but is still only a user (unless the server was restarted inbetween steps 2 and 3)

*crosses fingers* :D

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Loading the users.txt without restarting.
« Reply #1 on: December 04, 2007, 07:12:24 AM »
There's currently no good method of doing this... though we should probably make one.
Experiencing God's grace one day at a time.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Loading the users.txt without restarting.
« Reply #2 on: December 04, 2007, 07:14:10 AM »
I;m just glad you understood what I was asking.. re-reading it now, I can hardly make sense of it myself..! ??? :-\ :-\

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Loading the users.txt without restarting.
« Reply #3 on: December 04, 2007, 04:41:38 PM »
Gee.. you had me at hello.
Oh. No. Wait.
I understood.

Though the reloading of users.txt in some way is a good idea...I'm not so sure I like the adduserid.
Sure, at first, its great. After/before the fact additions.
Think though... supporting ulx is difficult enough with people trying to use adduser with the people on the server.

I'm not sure I want to experience the nightmare of supporting most people after spending too many times they finally give us a debug output and the users info has
Code: [Select]
"OPERATOR"
{
"deny"
{
}
"type" "steamid"
"groups"
{
"STEAM:BLAH:BLAH012345"
}
"id" "SOME_GUY_THAT_I_TRIED_TO_ADD"
"pass" "IMMUNITY=1"
"allow"
{
}
}

All the input error checking in the world can't account for the poor village missing its mayor. :)
"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: Loading the users.txt without restarting.
« Reply #4 on: December 04, 2007, 04:53:43 PM »
Gee.. you had me at hello.
Oh. No. Wait.
I understood.

Though the reloading of users.txt in some way is a good idea...I'm not so sure I like the adduserid.
Sure, at first, its great. After/before the fact additions.
Think though... supporting ulx is difficult enough with people trying to use adduser with the people on the server.

I'm not sure I want to experience the nightmare of supporting most people after spending too many times they finally give us a debug output and the users info has
Code: [Select]
"OPERATOR"
{
"deny"
{
}
"type" "steamid"
"groups"
{
"STEAM:BLAH:BLAH012345"
}
"id" "SOME_GUY_THAT_I_TRIED_TO_ADD"
"pass" "IMMUNITY=1"
"allow"
{
}
}

All the input error checking in the world can't account for the poor village missing its mayor. :)

Agreed JamminR. Ulx adduserid isn't going to happen, but I think reloading users.txt is a good idea.
Experiencing God's grace one day at a time.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Loading the users.txt without restarting.
« Reply #5 on: December 04, 2007, 07:01:04 PM »
Well, either way, reloading users.txt will get the job done! =)

I'm not great with lua, but would it be possible to look at the adduser command and use the ulib functions to create my own adduserid? Or is this something that ULib wouldnt even support at this time? because if it is just something that could be modularized for ULX, I'll just try to do it myself.

Thanks again guys.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Loading the users.txt without restarting.
« Reply #6 on: December 04, 2007, 07:13:06 PM »
It's most certainly possible. When the users are loaded from users.txt, they're all passed through ULib.addUser(), no need to have the user connected at the time.

If this is your first venture into lua, this should be a decent project because it will only be a few lines off from the standard ulx adduser.
Experiencing God's grace one day at a time.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Loading the users.txt without restarting.
« Reply #7 on: December 04, 2007, 08:28:12 PM »
This is what I got.. but not only does it not work.. it breaks my regular adduser :(:(

Code: [Select]
function ulx.cc_adduserid( ply, command, argv, args )

if #argv < 3 then
ULib.tsay( ply, ulx.LOW_ARGS, true )
return
end

local pname = argv[ 1 ]

local group = argv[ 2 ]

local immunity = util.tobool( argv[ 4 ] )

if ULib.ucl.groups[ group ] == nil or group == "user" then -- "not ULib.ucl.groups[ group ]" isn't working for some reason. Lua language construct error? Strange!
ULib.tsay( ply, "Invalid group!", true )
return
end

local sid = argv[ 3 ]

local groups = { group }
local allows = {}
if immunity then table.insert( allows, ULib.ACCESS_IMMUNITY ) end

ULib.ucl.addUser( pname, "steamid", sid, groups, {allow=allows, deny={}} , _, _, true )


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( "adduserid", ulx.cc_adduserid, "<name> <group> <SteamID> [<immunity>] - Add a user by SteamID to specified group with optional immunity.", ULib.ACCESS_SUPERADMIN, _, _, ulx.ID_PLAYER_HELP )

I put it in its own lua file in my ulx/lua/ulx/modules folder. Any help you guys are willing to lend would be greatly appreciated =)

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Loading the users.txt without restarting.
« Reply #8 on: December 04, 2007, 08:33:01 PM »
Any errors on startup or use?
Experiencing God's grace one day at a time.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Loading the users.txt without restarting.
« Reply #9 on: December 04, 2007, 08:38:23 PM »
"22:25:32 ulx adduserid Zach STEAM_0:1:1234567 admin"

is all I get on use from my DediConsole.. no errors and no confirmation. But funny thing is, it doesnt tell me it isnt a command either...
I'll load it up on a listen server so I get loading errors and will be in game when I test it.

1 second.


Edit.. Okay

Well the main problem I was having was that I forgot to replace the player variable in the Immunity checks with my pname variable I called it. So I fixed that. However I am now getting this
Code: [Select]
log.lua:51: attempt to call method 'IsConnected' (a nil value)I dunno what is causing it, but the user IS getting added to my users.txt file which is ultimately what i was going for! =)
« Last Edit: December 04, 2007, 09:05:06 PM by zakap »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Loading the users.txt without restarting.
« Reply #10 on: December 04, 2007, 09:24:05 PM »
zakap ...

1) the way you entered your user
"22:25:32 ulx adduserid Zach STEAM_0:1:1234567 admin"
is in the wrong order according to the variables according to the way you have in your code.
<name> <group> <steamid> <immunity>

2) The ULib.ucl.AddUser apparently checks to see if they are connected. Look it up in ULIb.
I'm betting one of the final parameters for it tell it to check for connected player.
Code: [Select]
_, _, true )
Meg could confirm, but I'm betting 'true' would be false for non-connected players. Look at the user.txt file parser code and see if it's 'false'. It would have to be since reading the file would usually involve non-connected players.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Loading the users.txt without restarting.
« Reply #11 on: December 04, 2007, 09:37:37 PM »
yeah.. sorry. I got that.

After I fixed the problem with the variable misnamed, it worked fine. Only problem was the ulx.log error still. I'll have to look into it and figure out why it wasnt logging/echoing.
I commented out the section of the code that asked for the log/echo, and for now it works fine. I tested it on myself, I removed all my access, left the server, used the command with my Steam ID and name(which I know is only for cosmetic and easy to use when looking at the file purposes) and when I joined the server I had the access I had granted myself and everything worked.

Thanks a million guys. If someone figures out about the log/echo thing before I do, please do tell, other than that, I got everything working as I need!

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Loading the users.txt without restarting.
« Reply #12 on: December 04, 2007, 09:48:15 PM »
The logging isn't working because the variable 'target' is nil. Change it to something like...

ulx.logServAct( ply, "#A added user <user> to group \"" .. group .. "\"" )
Experiencing God's grace one day at a time.