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?
Solved Items - Despawn Event?, Unique IDs?, Ownership?
Discussion in 'Rust Development' started by Togoshige, Nov 15, 2016.
-
For number 1 server has a command
server.itemdespawn
its the seconds that items on ground will despawn. -
@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 -
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 -
@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? -
-
Ill be writing my first plugin soon, I will definitley report back how everything goes!, Thank you so much @Colon Blow and @Mughisi
-
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)