The problem is that ArraySize is returning the number of items of both "Locations", 1 and 2, altogether.
To fix that, either create one array for each "Location" or implement your own ArraySize ignoring all "Locations" but the specified.
Code:
LocationItemCount(location)
{
new total
for (new i, count = ArraySize(g_menuItems), data[ArrayTest]; i < count; i++)
{
ArrayGetArray(g_menuItems, i, data)
if (location == data[Location])
{
total++
}
}
return total
}
Personally, I would create one array for each menu, it's simpler and easier to maintain, the way you are doing it now is overcomplicated and won't get any real benefit compared to multiple arrays, but that's just my opinion, you're free to use whatever method you want.
__________________