1. MonkeY12

    MonkeY12 Scavenger

    Hello,

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

    Regards
     
  2. redBDGR

    redBDGR Airdrop Stalker Plugin Developer

    Perhaps this?

    Code (Text):
    void OnItemDrop(Inventory inventory, int slot)
    {
        Puts("OnItemDrop works!");
    }
     
  3. MonkeY12

    MonkeY12 Scavenger

    This hook only show droped item but i need know who drop the item:(
     
  4. redBDGR

    redBDGR Airdrop Stalker Plugin Developer

    I assume you would be able to get the owner from something within the Inventory object
     
  5. Mughisi

    Mughisi Grenade Master Community Mod Oxide Developer

    This should give you some info
    Code (Text):
            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}");
            }
     
    MonkeY12 likes this.
  6. Wulf

    Wulf Community Admin Community Admin Oxide Developer

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

    MonkeY12 Scavenger


    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: Jun 16, 2017
  8. Mughisi

    Mughisi Grenade Master Community Mod Oxide Developer

    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 (Text):
    inventory.Items[slot].Item.GetNameKey()
     
  9. MonkeY12

    MonkeY12 Scavenger

    Code (Text):
    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. Dawidok915

    Dawidok915 Naked Wanderer

    How to make to remove items after throwing 50,100items ?
    Or kicked player who throws 50,100items