The CodeLock class contains a method RPC_ChangeCode.
Within this method but before the hook CanChangeCode is called, the lock flag is set to true if there is no code present and the code entered is not the guest code. If the hook CanChangeCode returns a non-null value, the lock is locked without a way for the player to unlock it.
I think moving the hook in front of the mentioned if statement will fix this. If I am wrong, please advise. Thanks!
[BaseEntity.RPC_Server]
[BaseEntity.RPC_Server.MaxDistance(3f)]
private void RPC_ChangeCode(BaseEntity.RPCMessage rpc)
{
if (!rpc.player.CanInteract())
return;
string str = rpc.read.String();
bool flag = rpc.read.Bit();
if (this.IsLocked() || str.Length != 4 || (!str.IsNumeric() || !this.hasCode & flag))
return;
if (!this.hasCode && !flag)
this.SetFlag(BaseEntity.Flags.Locked, true);
if (Interface.CallHook("CanChangeCode", (object) rpc.player, (object) this, (object) str, (object) flag) != null)
return;
if (!flag)
{
this.code = str;
this.hasCode = this.code.Length > 0;
this.whitelistPlayers.Clear();
this.whitelistPlayers.Add(rpc.player.userID);
}
else
{
this.guestCode = str;
this.hasGuestCode = this.guestCode.Length > 0;
this.guestPlayers.Clear();
this.guestPlayers.Add(rpc.player.userID);
}
this.DoEffect(this.effectCodeChanged.resourcePath);
this.SendNetworkUpdate();
}