MobileOdle Posted May 31, 2016 Share Posted May 31, 2016 (edited) Hello! I've done quite a bit of reading and trial and error to try and find answers to a particular problem I'm having with no success, so I'm hoping to turn to the community at large with a bit of a puzzle. A character I'm crearting will come with a weapon of his own that will drop itself if picked up by a different character. Works great for its intended user, but if I test it with another character it doesn't drop the item as intended. It creates two instances of the same weapon; one on the ground and one in the attempted inventory slot. Picking up either one impacts the other, so I'm guessing it isn't emoving the object from my inventory when it drops? The log tells me nothing and I've tried a few different ways of removing the item from the inventory, bar deleting it completely and spawning another, to no success. It doesn't crash, it just...doesn't act as intended, so I've attached more or less everything. Here is the most relevant code I can think of, though, from the weapon's prefab. Inside fn() inst:ListenForEvent("onputininventory", worthy) local function worthy(inst, owner) if not owner:HasTag("worthy") and owner.components.inventory ~= nil then owner.components.inventory:DropItem(inst, nil, true) end end Landon.zip Edited May 31, 2016 by MobileOdle Link to comment https://forums.kleientertainment.com/forums/topic/67785-dropping-creates-phantom-instances-of-item/ Share on other sites More sharing options...
Kunomori Posted May 31, 2016 Share Posted May 31, 2016 (edited) You should take a look on Guts the black swordsman mod. He have the berserker armor that as long as the mod is enabled, even if theres no one using guts, its craftable by anyone, but only him can actually pickup the armor from the ground. Any other character trying to pick it up instantly drops it and say that they cant get this. Edited May 31, 2016 by Kunomori Link to comment https://forums.kleientertainment.com/forums/topic/67785-dropping-creates-phantom-instances-of-item/#findComment-778441 Share on other sites More sharing options...
MobileOdle Posted June 1, 2016 Author Share Posted June 1, 2016 That was a good suggestion, got me where I needed to go! Instead of ListenForEvent, he used this. It called, more or less, the same function except with a DoTaskInTime(0). I'd put the rest of his code here, but I'm not sure if that would be frowned upon. AddPrefabPostInit("grenade", BerserkOnlyPostInit) Link to comment https://forums.kleientertainment.com/forums/topic/67785-dropping-creates-phantom-instances-of-item/#findComment-778693 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now