1. A while ago i wanted to nerf codelocks by making it so, on death, a mod would loop through all the codelocks and tool cupboards on the server and deauth the dead player.

    The idea was that when you respawn you would be a "new you" and would have forgotten the codes.

    So you can't just punch a random number and forget about it, either you would use numbers you can remember, or you write them down somewhere. More codes = more security = more work to keep track of them essentially.

    Has anyone found a way to access the authlist of a codelock and if no, any chance for oxide to work around that in the future?
     
  2. Code:
    FieldInfo codelist = typeof(CodeLock).GetField("whitelistPlayers", (BindingFlags.Instance | BindingFlags.NonPublic));
                                var codeListInst = (List<ulong>)codelist.GetValue(slotlock);
    I'm assuming you already know how to find the code lock on a door, or just loop through all code locks. That's how you access who is on the list. It's a simple list, so just .Add(ulong userid) and .Remove

    EDIT: Also worth noting I think this is essentially the same for regular locks, but not 100% sure
     
  3. Alright, i've never accessed anything this way, i couldn't find how to read it because it's marked as internal. I'll try that as soon as possible.

    what's the slotlock variable that you are referencing?
     
    Last edited by a moderator: May 6, 2016
  4. It's a code lock, hence why codelist is a typeof code lock. Once you get your specified code lock, you use GetValue(CodeLock). If you need help finding a code lock on a door, I can show you code to do that as well.
     
  5. Right!

    I've never used reflection before so i'm not familiar with the syntax.

    to get the codelocks i'm currently using unity's FindObjectsOfType, is there a less "overkill" method to do so?

    I was thinking about only doing so when the server starts and then maintain my own list of locks as they get added/removed.
     
  6. That's probably the best way, though, I don't think finding all code locks is that intensive. -- As compared to finding all building blocks like twigs decay does, so unless you see a hit, you may as well take the easy route first.
     
  7. Yeah it appears to just "work", I'm just referring to the unity recommendation of "Please don't use Find* trivially", but maybe they ment "don't use it every frame"

    I've no clue how many codelocks are used on a busy server, on average.
     
  8. Probably a lot. It's not hard to make a list, automatically add all the current ones to it on OnServerInit, and then OnEntitySpawn and OnEntityDeath do, respectively, what you need to do to the list.
     
  9. yup, altho codelocks are not calling on entitydeath it seems, so i have a removeall() clearing up null entries in the list before flushing player codes.