| 02-28-2010, 04:28 PM | #1 |
What are the correct parameters to pass into this function for item? JASS:native UnitHasItem takes unit whichUnit, item whichItem returns boolean Cannot just pass name(string), or item id(integer) or is there a way to convert them to an item? |
| 02-28-2010, 04:37 PM | #2 |
The item argument for the UnitHasItem function refers to an item object not an ID. If I remember correctly, you need to perform a comparison of the itemTypeID for each of the items carried by the unit. Try using: JASS:native GetItemTypeId takes item i returns integer |
| 03-01-2010, 01:41 PM | #3 |
You are probably looking for UnitHasItemOfTypeBJ. |
| 03-01-2010, 05:56 PM | #4 |
JASS:function UnitHasItemType takes unit u, integer id returns integer local integer i=0 local integer m=UnitInventorySize(u) loop exitwhen(i==m) if (GetItemTypeId(UnitItemInSlot(u, i))==id) then return i endif set i=i+1 endloop return -1 endfunction Here, rather than using a function that calls another function, just use this function. It returns -1 if the unit does not have the item, and if the unit does have the item then it will return the slot index of the first "appearance" of the item-type in a unit's inventory. |
| 03-03-2010, 10:06 AM | #5 |
thx guys for helping. the way i use is similar with "TheKid" shows me but not in a function calling way. |
