[Feature] Consider saving rank state to dB when new rank is applied
Bryantdl7 opened this issue · 12 comments
Saving the users rank would be helpful in a situation where a user is promoted to a rank, such as admin, and the server crashes before they disconnect.
In its current state, when a user is given a rank it does not apply until they disconnect from the server.
I found out that ULX supplies a hook for changing of user groups, I will implement that feature into MRSync
Great, let me know if you need me to test it.
it would be nice if you could test the bugfix branch so I can merge it to development and then start to work on this feature
Feature implemented in MRSync version 2.1.2+
I tested the code present in 06a4546
and my rank did not update in the database.
No output in RCON stating a rank change occured either.
L 05/13/2020 - 17:26:21: [ULX] [DSTM] Bryant added Themself to group manager Compressing fragments (38386 -> 14361 bytes)
This branch did however update my database when I disconnected
MRSync should listen for a hook provided by ULX itself, can you execute this command please and then try again to change someones rank?
lua_run hook.Add("ULibUserGroupChange", "mrsync.H.saveRankOnUpdate", function(sid, _, _, new_group, _) print(sid, new_group) end)
The provided code did not work. Here is the output I received:
Kindly note I ran the status command manually, to ensure the command did go through.
lua_run hook.Add("ULibUserGroupChange", "mrsync.H.saveRankOnUpdate", function(sid, _, _, new_group, _) print(sid, new_group) end)
> hook.Add("ULibUserGroupChange", "mrsync.H.saveRankOnUpdate", function(sid, _, _, new_group, _) print(sid, new_group) end)...
status
status
hostname: DarkstormDev
version : 2020.03.17/24 7836 secure
udp/ip : 192.223.26.64:1574 (public ip: 192.223.26.64)
map : gm_construct at: 0 x, 0 y, 0 z
players : 1 (40 max)
# userid name uniqueid connected ping loss state adr
# 3 "[DSTM] Bryant" STEAM_0:0:26745653 06:01 188 0 active 24.194.254.170:27005
[DSTM] Bryant added Themself to group owner
ServerLog: [ULX] [DSTM] Bryant added Themself to group owner
L 05/13/2020 - 17:34:16: [ULX] [DSTM] Bryant added Themself to group owner
A second time for the sake of consistency:
lua_run hook.Add("ULibUserGroupChange", "mrsync.H.saveRankOnUpdate", function(sid, _, _, new_group, _) print(sid, new_group) end)
> hook.Add("ULibUserGroupChange", "mrsync.H.saveRankOnUpdate", function(sid, _, _, new_group, _) print(sid, new_group) end)...
[DSTM] Bryant added Themself to group superadmin
ServerLog: [ULX] [DSTM] Bryant added Themself to group superadmin
L 05/13/2020 - 17:36:29: [ULX] [DSTM] Bryant added Themself to group superadmin
Okay, it looks like the ULib hook is either not avaiable at your server or that it doesnt get called by ULX on a group change. Do you use the GitHub ULX or the provided downloads from their website?
you can also try this:
lua_run hook.Call("ULibUserGroupChange", nil, "Hello", "Hey")
Good catch! Somehow people on my team only thought that ULX needed updating. not ULib.
I was running 2.61d (2016!), apparently this feature was added in at some point between then and 2.63d from 2018
The initial code from your repo works. The error was me.
Alrighty, I was already worried for a second. But you should not clone their repository directly, they tried to implement a new way of saving data, but it doesnt work ( never got finished ). So I suggest to use release versions on their GitHub or website ( Just in case you didn't know )
I was on a release version, just one from two years prior to their latest stable release, that was my issue. Trust me, I have learned the hard way on just grabbing the first ULIB files I see lol
Great, so if there are no more issues I am going to merge the changes to the development branch