IPGetItemHasProperty(object, itemproperty, int, int)
Checks if an item has a matchine itemproperty.
int IPGetItemHasProperty( object oItem, itemproperty ipCompareTo, int nDurationType, int bIgnoreSubType = FALSE );
Parameters
oItem
Item to check for property.
ipCompareTo
ItemProperty to compare to
nDurationType
See description and remarks.
bIgnoreSubType
TRUE to ignore subtype. Otherwise FALSE. (Default: FALSE)
Description
Wrapper for GetItemHasItemProperty that returns true if oItem has an itemproperty that matches ipCompareTo by Type AND DurationType AND SubType
nDurationType = Valid DURATION_TYPE_* or -1 to ignore
bIgnoreSubType - If set to TRUE an item property will be considered identical even if the SubType is different.
Remarks
Only DURATION_TYPE_TEMPORARY, DURATION_TYPE_PERMANENT, and -1 are valid for nDurationType.
This differs from GetItemHasItemProperty in several ways. First of all because it also takes duration type and subtype into accound. And also because it uses an itemproperty value for parameter, instead of the ITEM_PROPERTY_* integer constant.
Returns TRUE if oItem has the same type of itemproperty that ipCompareTo is. If nDurationType is different from -1, it also needs to be that same duration type. If bIgnoreSubType is FALSE, it also needs to be of the same subtype.
Returns FALSE if the above isn't mean. It also prints "Not Found" to the log.
Requirements
#include "x2_inc_itemprop"
Version
1.61
Example
#include "x2_inc_itemprop" //This could be used as part of a blacksmith script. For instance //it could be that the smith will only allow four properties on an item //but he may then also offer to remove doubles. //This example will remove all the itemproperties on the PC speaker's //offhand weapon that are also on the OnHand weapon void main() { object oPC=GetPCSpeaker(); object oOnHand=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC); object oOffHand=GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC); //make sure they're both melee weapons if (!(IPGetIsMeleeWeapon(oOnHand) && IPGetIsMeleeWeapon(oOffHand))) return; //Loop through all itemprops on onhand weapon itemproperty ipLoop=GetFirstItemProperty(oOnHand); while (GetIsItemPropertyValid(ipLoop)) { if (IPGetItemHasProperty(oOffHand, ipLoop, DURATION_TYPE_PERMANENT, FALSE)) RemoveItemProperty(oOffHand, ipLoop); ipLoop=GetNextItemProperty(oOnHand); } }
See Also
functions: | GetItemHasItemProperty |
categories: | Get Data from Object Functions | Item Creation Functions | Item Properties Functions |
constants: | DURATION_TYPE_* Constants |
author: Lilac Soul
Send comments on this topic.