1. Hello. I need to check, is player auth in codelock, that is on large box.
    So, i have:
    BasePlayer player - player that i want to check;
    BaseEntity box - large box that code i want to check;

    How i can check it?
    [DOUBLEPOST=1497641604][/DOUBLEPOST]Have an update, wrote something like:
    Code:
    var hit = hitinfo.collider.gameObject.ToBaseEntity();
                    if (hit.name == "assets/prefabs/deployable/large wood storage/box.wooden.large.prefab")
                    {
                        StorageContainer container = hit.GetComponent<StorageContainer>();
                        Dictionary<int, int> current = new Dictionary<int, int>();
                        ForRemove.Add(player.userID, new List<int> { });
                        CodeLock code = hit.GetComponent<CodeLock>();
                        List<ulong> auth = code.whitelistPlayers;
                        foreach (var checkter in auth)
                        {
                            SendReply(player, checkter.ToString());
                        }
    It is part of my code, but when i try to call this function - i see Object reference not set to an instance of an object in console
     
  2. UP, made it myself:
    I know, i am noob, but i will try to help other noobs
    1. Take ur entity, code from what u want to check and find his children.
    var code = entity.Children[0]; - (In case, that entity is box - Children[0] - codelock).
    2. Next get component of this lock.
    CodeLock locker = code.GetComponent<CodeLock>();
    3. Get list of players:
    List<ulong> players = locker.whitelistPlayers;

    Now, u can, for example, send all auth players in consol:
    foreach(var check in players) {
    Puts(check);
    }

    If somebody know how to make this easily - write here, pls ;3
     
  3. I made this if at all helpful.
    Code:
            [ChatCommand("check")]
            private void CheckCommand(BasePlayer player, string command, string[] args)
            {
                if (!player.IsAdmin)
                {
                    PrintToChat(player, "Error, you're not an admin.");
                    return;
                }            if (args.Length == 0)
                {
                    PrintToChat(player, "Error, no argument specified");
                    return;
                }            var targetEntity = GetViewEntity(player)?.GetSlot(BaseEntity.Slot.Lock);
                var codeLock = targetEntity?.GetComponent<CodeLock>();            if (codeLock == null)
                {
                    PrintToChat(player, "Error, that's not a lock.");
                    return;
                }            var target = BasePlayer.Find(args[0]);            if (target == null)
                {
                    PrintToChat(player, "Error, target not found.");
                    return;
                }            PrintToChat(player, $"{target.displayName} {(codeLock.whitelistPlayers.Contains(target.userID) || codeLock.guestPlayers.Contains(target.userID) ? "is" : "isn't")} authorized.");
            }        private bool IsLocksEntity(BaseEntity entity) => entity != null && entity.ShortPrefabName == "lock.code";        private BaseEntity GetViewEntity(BasePlayer player)
            {
                RaycastHit hit;
                var didHit = Physics.Raycast(player.eyes.HeadRay(), out hit, 5);            return didHit ? hit.GetEntity() : null;
            }
     
    Last edited by a moderator: Jun 16, 2017
  4. Ty. It is working good 2, but can u help me one more time?
    Can i destroy item in player inventory, if i know his UID?
    (Because i don't need to destroy ALL items with one itemid, i need destroy one, that i know?)
     
  5. Well, you should be able to do a foreach statement in player.inventory.AllItems(), and then remove it from the container. There's also FindItem(args) which may be worth looking at too though.