Skip to content

Need help with item containers inventory

I am using a very old ATS tradeskill build in a module. However I have an issue where sometimes a duplicate token box that stores the information of the player skills appears in the inventory but empty. So the player would have a correct box container with tokens and a second undroppable box that is completely empty. I wish to add to my OnClientEnter script a section that removes all empty boxes upon login. I just don't know how to target only the empty container boxes in a players inventory.

The tag of the item container that need checking and removing is "ATS_SKILLBOX_NOD"

Any help would be greatly appreciated :)

Comments

  • NeverwinterWightsNeverwinterWights Member Posts: 339
    edited September 2019
    Something like this should work for ya. Tested it a bit. Recommend doing your own test as well. I don't want to delete all your players stuff. :D
    void main()
    {
        object oPC = GetEnteringObject();
        object oItem = GetFirstItemInInventory(oPC);
        while(GetIsObjectValid(oItem))
        {
            if (GetTag(oItem) == "ATS_SKILLBOX_NOD")
            {
                object oCheck = GetFirstItemInInventory(oItem);
                if (!GetIsObjectValid(oCheck))
                {
                    DestroyObject(oItem);
                    return;
                }
            }
            oItem = GetNextItemInInventory(oPC);
        }
    }
    

    One caveat. This will run every time a player enters unless you add a "do once" variable. Whether that be in a database or item is up to you. Just let me know if you need further help with that.
  • Lu7zLu7z Member Posts: 2
    edited September 2019
    Thanks so much! After fiddling around with delaying when the script runs it seems to be working as I had hoped. Again thank you.

    I am also happy it runs every relog. For some reason, buried somewhere in the ATS scripts its pushing two boxes into the players inventory every time a player relogs instead of only the one.

    Also this script is super helpful because now I know how to target an empty item container in a player inventory! :)
Sign In or Register to comment.