Skip to content

GetItemPropertyByTag(object oItem, string sTag);

NeverwinterWightsNeverwinterWights Member Posts: 339
edited April 2020 in Builders - Scripting
Just a little something many of you probably already discovered but figured I'd share because I always wanted an easy way to remove item properties or effects. Now with being able to give tags to item properties and effects you can use the new TagItemProperty(); or TagEffect(); function in conjunction with a "home brew" function to easily remove item properties or effects and not have to add cycles/loops so much or worry about duplicate types or creators. The function I came up with for item properties:
itemproperty GetItemPropertyByTag(object oItem, string sTag, int nNth = 1)
{
    itemproperty ipNull;
    int nNthCheck;
    itemproperty ipProperty = GetFirstItemProperty(oItem);
    while (GetIsItemPropertyValid(ipProperty))
    {
        if (GetItemPropertyTag(ipProperty) == sTag)
        {
            nNthCheck++;
            if (nNth == nNthCheck) return ipProperty;
        }
        ipProperty = GetNextItemProperty(oItem);
    }
    return ipNull;
}

And then in your main you can just do something like:
itemproperty ipRemove = GetItemPropertyByTag(oSkin, "PC_ZOMBIE_WALK");
RemoveItemProperty(oSkin, ipRemove);

Can also do the same thing with tagging effects. Anyway hope it helps someone.
Post edited by NeverwinterWights on
Sign In or Register to comment.