One hint to your code Masteroshi:
Could work but is a manual concatenation which should not be used if there are better ways provided by ZOs:
local tag = "group"..tostring(i)
You also would not (or at least should not) always just use 1, instead of the correct constant BAG_BAGPACK for the inventory's bagId.
-> The constants and API functions exist to make it compatible, also for future use cases. So better make use of them instead of re-inventing your own code that maybe works today, but breaks tomorrow.
Definately works (and is API and should be used here):
Code:
local unitTag = GetGroupUnitTagByIndex(i)
Attention:
A unitTag may be nil if there are gaps in the group indices! So GetGroupUnitTagByIndex(index) might return nil, add a nil check afterwards!
Code:
local unitTag = GetGroupUnitTagByIndex(i)
if unitTag ~= nil and DoesUnitExist(unitTag) then
--Only here we know the unit at index i exists!
end