Help with lock picking plugin
I'm working on a plugin that will allow players to bypass locks of other players if they successfully complete a text-based mini game, all the while taking damage based on how well they are or are not doing with the mini game. All this is working great. I can get into locks I don't own when I complete the game successfully, and locks I do own work as normal.

I'm still testing all the various scenarios I can think of before I release the first version. One of the problems I'm having is with TCs. I want to have players be able to loot a TC if they bypass the lock, but not be able to authorize on TC. Does anyone even know whether or not that's even possible? Under normal circumstances, you can't loot a TC until you auth on it.
private void OpenContainer(BasePlayer player, StorageContainer container, string panelName = null)
        {
            timer.Once(0.2f, () =>
            {
                player.EndLooting();
                if (!player.inventory.loot.StartLootingEntity(container, false)) {return;}
                player.inventory.loot.AddContainer(container.inventory);
                player.inventory.loot.SendImmediate();
                player.ClientRPCPlayer(null, player, "RPC_OpenLootPanel", panelName ?? container.panelName);
                player.SendNetworkUpdate();
            });
        }
Orange, thanks for the quick reply. I tried your code, adding another status for a completed lock that is on a tool cupboard. If it is a cupboard, rather than returning true for the CanUseLockedEntity, I'm calling your function like this:

if (pl.status == "Cupboard")
{
    var lockedTC = baseLock.GetParentEntity() as StorageContainer;
    OpenContainer(player, lockedTC, "");
}

The rest of CULE will fall through to false for the hacked cupboard lock. The problem I'm encountering is that it is opening the player's inventory without opening the TC's inventory. I'm also seeing an error message on the screen itself.
Couldn't find prefab "assets/bundled/prefabs/ui/lootpanels/lootpanel..prefab"

Missing Loot Panel assets/bundled/prefabs/ui/lootpanels/lootpanel..prefab

My thought is that it is failing the Hook CanLootEntity because it is locked and CULE is returning false, so that's where I'm going to focus for now. But I wanted to throw it up here in case you or someone had an idea of a different place to look.

Merged post

Update-------------------------------------------------------------------
Ok, I got this working. It had nothing to do with CanLootEntity. I was calling Orange's function wrong. I changed the function call to 

OpenContainer(player, lockedTC, "toolcupboard");​

and that worked just fine. I thought that setting the string to null in the function parameters list would override anything that was sent, but it doesn't. Looks like it only sets it to null if you don't pass anything.

Thanks Orange for the code snippet. It works like a champ.