If not:
You should make an arrayed Unit variable 'GotYourItem'. If the unit gets the item, place him in the variable. To check which array is still unused, you need an 'exitwhen' JASS line. I'm not using JASS, but I know that line exists. You should ask someone who's familiar with JASS to tell you the exact script line to place. It should exit when the array is not used or the unit in it has been detroyed (leakless). If that's not possible, just set the unit to a dummy unit and exit when the unit of that array is the dummy unit. For an example of what I mean, check
this thread.