1. Hello,

    Is there a hook that detects whether a person drop an item.
    People crash my server by droping items.

    Regards
     
  2. Perhaps this?

    Code:
    void OnItemDrop(Inventory inventory, int slot)
    {
        Puts("OnItemDrop works!");
    }
     
  3. This hook only show droped item but i need know who drop the item:(
     
  4. I assume you would be able to get the owner from something within the Inventory object
     
  5. This should give you some info
    Code:
            private void OnItemDrop(Inventory inventory, int slot)
            {
                PrintWarning($"Calling OnItemDrop({inventory}, {slot})");
                var networkview = inventory.GetComponent<uLinkNetworkView>().owner;
                var playerSession = GameManager.Instance.GetSession(networkview);
                if (playerSession != null)
                    Puts($"  Player: {playerSession.Identity.Name}");
                else
                    Puts($"  Inventory: {inventory}");
            }
     
  6. Wulf

    Wulf Community Admin

    That will be renamed to OnItemDropped when we push for itemv2 by the way. :p
     

  7. I love you <3

    Thank u ! :)


    EDIT: Its possible to check droped item ?
    19:01 [Warning] [Check] Calling OnItemDrop(PlayerServer(Clone) (PlayerInventory), 19)
    19:01 [Info] [Check] Player: LeedeK
     
    Last edited by a moderator: Jun 16, 2017
  8. At the time I added the hook you could get the item with the following code, it might be a bit outdated now though but should give you some info on how to proceed if it wouldn't work.
    Code:
    inventory.Items[slot].Item.GetNameKey()
     
  9. Code:
    19:22 [Warning] Calling 'OnItemDrop' on 'Check v1.0.0' took 793ms [GARBAGE COLLECT]
    19:22 [Warning] [Check] Calling OnItemDrop(GroundDrillDynamicConstructed(Clone) (FuelSlotInventory), 1)
    19:22 [Info] [Check]   Inventory: GroundDrillDynamicConstructed(Clone) (FuelSlotInventory)
    19:22 [Error] Failed to call hook 'OnItemDrop' on plugin 'Check v1.0.0' (NullReferenceException: Object reference not set to an instance of an object)
    19:22 [Stacktrace]   at Oxide.Plugins.Check.OnItemDrop (.Inventory inventory, Int32 slot) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.Check.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00000] in <filename unknown>:0 
    Last question. Can i detect who does it?
     
  10. How to make to remove items after throwing 50,100items ?
    Or kicked player who throws 50,100items