CanUnlock
OxidePlayerobject CanUnlock(BasePlayer player, CodeLock codeLock)
object CanUnlock(BasePlayer player, KeyLock keyLock)
object CanUnlock(BasePlayer player, ModularCarCodeLock modularCarCodeLock, string codeEntered)Works — the game method in this build is the one the hook was written for.
Parameters
- player
- BasePlayer
- codeLock
- CodeLock
Return value
objectReturn a value of the method's result type and the game returns it immediately; null continues as usual.
Example
object — you can affect the game: return a value to change or cancel the action.
private object CanUnlock(BasePlayer player, CodeLock codeLock)
{
Puts("CanUnlock");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return null; // null — the game continues as usual
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point 1
Rust.opj (Oxide)
void CodeLock.TryUnlock(BaseEntity.RPCMessage)
Passes: BasePlayer player, CodeLock codeLock
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (a0.player, this)Assembly-CSharp.dll
Where it is called (this branch's game code)
[RPC_Server]
[RPC_Server.MaxDistance(3f, CheckParent = true)]
private void TryUnlock(RPCMessage rpc)
{
if (rpc.player.CanInteract() && IsLocked() && !IsCodeEntryBlocked() && whitelistPlayers.Contains(rpc.player.userID))
{
if (Interface.CallHook("CanUnlock", rpc.player, this) != null)
{
return;
}
DoEffect(effectUnlocked.resourcePath);
SetFlagLocal(Flags.Locked, b: false);
SendNetworkUpdate();
}
}Injection point 2
Rust.opj (Oxide)
void KeyLock.RPC_Unlock(BaseEntity.RPCMessage)
Passes: BasePlayer player, KeyLock keyLock
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (a0.player, this)Assembly-CSharp.dll
Where it is called (this branch's game code)
[RPC_Server]
[RPC_Server.MaxDistance(3f, CheckParent = true)]
private void RPC_Unlock(RPCMessage rpc)
{
if (rpc.player.CanInteract() && IsLocked() && HasLockPermission(rpc.player))
{
if (Interface.CallHook("CanUnlock", rpc.player, this) != null)
{
return;
}
SetFlagLocal(Flags.Locked, b: false);
SendNetworkUpdate();
}
}Injection point 3
Rust.opj (Oxide)
bool ModularCarCodeLock.TryOpenWithCode(BasePlayer, string)
Passes: BasePlayer player, ModularCarCodeLock modularCarCodeLock, string codeEntered
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (a0, this, a1)Assembly-CSharp.dll
Where it is called (this branch's game code)
public bool TryOpenWithCode(BasePlayer player, string codeEntered)
{
object returnvar = Interface.CallHook("CanUnlock", player, this, codeEntered);
if (returnvar is bool)
{
return (bool)returnvar;
}
if (CodeEntryBlocked(player))
{
return false;
}
// …Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.