Prevent player from dropping item
xypher
Member Posts: 10
Hello,
I am trying to keep a player from being able to drop an item once they acquire it into their inventory. The item isn't set as undroppable in the toolset options as they retrieve it from a container. I saw a similar post to this and I thought I did it correctly, but even after taking the item I can still right click and drop it from my inv. or drag and drop it out into the game world. I attempted via this method in my OnAcquire module script:
SetDroppableFlag(oItem, FALSE);
I also tried with the SetCursedItemFlag since its description sounded like it did the same thing? Neither work when I set it to false. My logic was, when the item is acquired set that item to be undroppable.
I am trying to keep a player from being able to drop an item once they acquire it into their inventory. The item isn't set as undroppable in the toolset options as they retrieve it from a container. I saw a similar post to this and I thought I did it correctly, but even after taking the item I can still right click and drop it from my inv. or drag and drop it out into the game world. I attempted via this method in my OnAcquire module script:
SetDroppableFlag(oItem, FALSE);
I also tried with the SetCursedItemFlag since its description sounded like it did the same thing? Neither work when I set it to false. My logic was, when the item is acquired set that item to be undroppable.
0
Comments
SetDroppableFlag is to indicate if an item can drop as loot or not for NPCs.
In case this helps, the item is being created dynamically in script of OnOpen whenever the inventory of this object is opened.
(I'm just not 100% on what that means or how it works at the moment since I'm still learning)
EDIT: Also, thanks for the tip Ancarion. For my module I actually do expect there to be multiple existing at the same time in some instances.
Some of the default AI is really easy to break.
In this particular case, I have the default code before the custom code, with no problems.
What the default code says is "return if X2_EXECUTE_SCRIPT_END is returned by a script with the same name as the tag". That suggests that you actually have a tag-based script which is executing in addition to your custom logic, when the default code is placed last.
EDIT: Sure enough, I had a tag-based script for that item and I completely forgot about that. That was messing with all sorts of stuff when I was originally setting up this whole gameplay mechanic. Now that I understand better how this is working I actually moved all that code into the tag-based script and have it working that way. Thank you.