CanPickupLock
OxideCarbonPlayerCalled to determine whether to pickup lock.
Return true to allow the action and false to block it.
object CanPickupLock(BasePlayer player, BaseLock baseLock)Works — the game method in this build is the one the hook was written for.
Parameters
- player
- BasePlayer
- baseLock
- BaseLock
Return value
objectReturn non-null to cancel the game action.
Example
object — you can affect the game: return a value to change or cancel the action.
private object CanPickupLock(BasePlayer player, BaseLock baseLock)
{
Puts("CanPickupLock");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return false; // non-null cancels the game action
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
void BaseLock.RPC_TakeLock(BaseEntity.RPCMessage)
Passes: BasePlayer player, BaseLock baseLock
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)]
public void RPC_TakeLock(RPCMessage rpc)
{
if (rpc.player.CanInteract() && CanRemove && !IsLocked())
{
if (Interface.CallHook("CanPickupLock", rpc.player, this) != null)
{
return;
}
Item item = ItemManager.Create(itemType, 1, skinID, isServerSide: true, 0uL);
if (item != null)
{
rpc.player.GiveItem(item);
}
// …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.