public void Open(BasePlayer looter) { if (_instance._openBackpacks.ContainsKey(looter)) { return; } _instance._openBackpacks.Add(looter, this); if (!_initialized) { Initialize(); } // The entityOwner may no longer be valid if it was instantiated while the player was offline (due to player death) if (_itemContainer.entityOwner == null) { var ownerPlayer = FindOwnerPlayer()?.Object as BasePlayer; if (ownerPlayer != null) { _itemContainer.entityOwner = ownerPlayer; } } // Container can't be looted for some reason. // We should cancel here and remove the looter from the open backpacks again. if (looter.inventory.loot.IsLooting() || !(_itemContainer.entityOwner?.CanBeLooted(looter) ?? looter.CanBeLooted(looter))) { _instance._openBackpacks.Remove(looter); return; } if (!_instance.VerifyCanOpenBackpack(looter, OwnerId)) { return; } // Only handle overflow when the owner is opening the backpack if (looter.userID == OwnerId) { MaybeAdjustCapacityAndHandleOverflow(looter); } if (!_looters.Contains(looter)) { _looters.Add(looter); } PlayerLootContainer(looter, _itemContainer); Interface.CallHook("OnBackpackOpened", looter, OwnerId, _itemContainer); }
public void Open(BasePlayer looter) { if (_instance._openBackpacks.ContainsKey(looter)) { return; } _instance._openBackpacks.Add(looter, this); if (!_initialized) { Initialize(); } // Container can't be looted for some reason. // We should cancel here and remove the looter from the open backpacks again. if (looter.inventory.loot.IsLooting() || !(_itemContainer.entityOwner?.CanBeLooted(looter) ?? looter.CanBeLooted(looter))) { _instance._openBackpacks.Remove(looter); return; } if (!_looters.Contains(looter)) { _looters.Add(looter); } if (_instance.EventManager?.Call <bool>("isPlaying", looter) ?? false) { _instance.PrintToChat(looter, _instance.lang.GetMessage("May Not Open Backpack In Event", _instance, looter.UserIDString)); return; } var hookResult = Interface.Oxide.CallHook("CanOpenBackpack", looter, OwnerId); if (hookResult != null && hookResult is string) { _instance.PrintToChat(looter, hookResult as string); return; } PlayerLootContainer(looter, _itemContainer); Interface.CallHook("OnBackpackOpened", looter, OwnerId, _itemContainer); }