So I had a player notify me this morning that with the Auto Locks plugin, they were unable to change the randomly assigned code that they were assigned the first time they used the plugin. I initially thought there was an error with the plugin, but in looking at the code, I noticed it relied on the OnCodeEntered hook for when the user changed their code via the keypad mechanism. I saw that the hook signature didn't quite match the one in the API documentation, so I edited it to make it match, but it still wouldn't work. I ended up making a simple test plugin and copy/pasted the hook example code in there and uploaded to my server. When I change any codelocks at all, not just using the AutoLock internal command, that hook is not being called. I'm not sure when this started as to my knowledge, it was working at the beginning of the month after the January 6th update, so maybe one of the more recent protocol updates? I wasn't sure the best location to report this, so I posted here and on the Auto Lock plugin support as well.
Thanks!
OnCodeEntered hook not working
Hooks are called when game code is triggered. Unless Rust did away with code locks entirely (they didn't), the hook would still be called.
The game code:
private void UnlockWithCode(RPCMessage rpc)
{
if (!rpc.player.CanInteract() || !IsLocked() || IsCodeEntryBlocked())
{
return;
}
string text = rpc.read.String();
if (Interface.CallHook("OnCodeEntered", this, rpc.player, text) != null)
{
return;
} Hey Wulf,
So over an hour of messing around with the Auto Lock plugin and the quick test plugin I made, that OnCodeEntered hook never fired in either one. I finally stopped working with it and went back to work. The player just PMed me thanking me for fixing it. So I don't know what happended. It's the same version of the plugin as before and it had been reloaded numerous times while troubleshooting. So it's working again but I'm not sure how unless it was that slight change in the hook signature, but even then, I had reloaded it a few times after making that change.