CanPickupFromRack
CarbonGlobalCalled to check whether the player can take a specific weapon from a weapon rack.
Return true to allow the action and false to block it.
void CanPickupFromRack(WeaponRack rack, BasePlayer player, Item item, int mountSlotIndex, int playerBeltIndex, bool tryHold)Works — the game method in this build is the one the hook was written for.
Parameters
- rack
- WeaponRack
- player
- BasePlayer
- item
- Item
- mountSlotIndex
- int
- playerBeltIndex
- int
- tryHold
- bool
Return value
voidBehaviour is not described.
Example
private void CanPickupFromRack(WeaponRack rack, BasePlayer player, Item item, int mountSlotIndex, int playerBeltIndex, bool tryHold)
{
Puts("CanPickupFromRack");
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Carbon
void WeaponRack.GivePlayerWeapon(BasePlayer player, int mountSlotIndex, int playerBeltIndex, bool tryHold, bool sendUpdate)
WorksAssembly-CSharp
Where it is called (this branch's game code)
private void GivePlayerWeapon(BasePlayer player, int mountSlotIndex, int playerBeltIndex = -1, bool tryHold = true, bool sendUpdate = true)
{
Interface.CallHook("CanPickupFromRack", this, player, item, mountSlotIndex, playerBeltIndex, tryHold);
if (player == null)
{
return;
}
WeaponRackSlot weaponAtIndex = GetWeaponAtIndex(mountSlotIndex);
if (weaponAtIndex == null)
{
return;
// …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.