1. 1. Is there any hook, event or code, for knowing when an item despawns (dropped on ground and removed/cleaned up by game)?
    1.a. Or know when an item is crushed?

    2. Do Items have unique ids?

    3. Is is possible to check if a specific item in the game still exists?
    [DOUBLEPOST=1479244322][/DOUBLEPOST]4. If Items do not have unique IDs, is it possible to tie/link an item to a specific player?
    4.a. How does item ownership work? Person who crafts an item and person who owned the resources used to create an item, both have partial ownership?
     
  2. For number 1 server has a command

    server.itemdespawn

    its the seconds that items on ground will despawn.
     
  3. @Colon Blow
    For example, lets say I want a plugin where I can kill a player, and harvest their skull,
    and bring their skull back to my base, put it in a box, and put other resources around it,
    which are then consumed and it initiates a Voodoo spell that causes the player to be cursed (and slowly take damage, or something else, etc etc)

    And lets say as long as I have their skull, the curse keeps going,
    but once the Skull is crushed, or destroyed (despawned), the curse ends
     
  4. Well, did some quick testing on human skulls. Since I'm from Louisiana and like Voodoo :)

    Skulls do indeed take on item ownership.
    Skulls that are harvested from dead players take on the dead players name on skull and has dead players owner.userid as part of item.owners.
    Different than spawned in skulls, ownership is given to the one who spawns it in.

    And with owner.userid you can get player name of who's corpse skull it was..or who spawned it in.

    So it should be very possible to do what you say.

    example code: (would check if skull gets added to players inventory. and reply to player the userid in chat)

    Code:
            void OnItemAddedToContainer(ItemContainer container, Item item)
            {
                   var player = container.playerOwner;
                   if (!container.playerOwner) return;               if (item.info.shortname == "skull.human")
                   {
                             foreach (var owner in item.owners)
                            {
                                 SendReply(player, "You have the skull of "+owner.userid);
                            }
                   }
            }
     
    Last edited by a moderator: Nov 16, 2016
  5. @Colon Blow you're awesome! This solves question #4

    Remaining questions Im still curious about (should I make a new thread?):
    1. Is there any hook, event or code, for knowing when an item despawns (dropped on ground and removed/cleaned up by game)?
    1.a. Or know when an item is crushed?
    3. Is is possible to check if a specific item in the game still exists?
    2. Do Items have unique ids?
     
  6. OnEntitySpawned(BaseNetworkable net) should allow you to track the item being dropped and spawned as world entity for other users to be picked up, and assuming that the clean up utilizes Kill on the object it should be possible to track it being destroyed with OnEntityKill(BaseNetworkable net)
    Not sure if there is a hook present that triggers on a skull being crushed, this might be included in the OnConsumbleUse(Item item, int amount) so this would require some testing.
    Yes, but this would involve looping through all players and all containers which would have quite an impact on server performance, so it might be easier to track other events like the item being picked up, dropped, stored in a container,.....
    Yes, the field uint uid provides this (yourItem.uid)
     
  7. Ill be writing my first plugin soon, I will definitley report back how everything goes!, Thank you so much @Colon Blow and @Mughisi
     
  8. You could add the skulls owner to a dictionary when the "voodoo" ritual adds them to the list to be cursed.
    That way you can just check the list periodically and hurt any player in it. And remove the player after time or with some other trigger (owners skull is crushed, dropped or not in original players inventory)