GetInventoryIndexOfItemTypeBJ

Parameters
whichUnit unit
itemId integer
bug

Leaks handle indexItem: In Jass you must set local variables that hold agents (or any child type) to null at the end of functions to avoid reference counter leaks.

comment
return type
integer
Source code
function GetInventoryIndexOfItemTypeBJ takes unit whichUnit, integer itemId returns integer
    local integer index
    local item    indexItem

    set index = 0
    loop
        set indexItem = UnitItemInSlot(whichUnit, index)
        if (indexItem != null) and (GetItemTypeId(indexItem) == itemId) then
            return index + 1
        endif

        set index = index + 1
        exitwhen index >= bj_MAX_INVENTORY
    endloop
    return 0
endfunction
Source
Blizzard.j
wc3modding.com
GetInventoryIndexOfItemTypeBJ