View Single Post
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-21-2022 , 21:46   Re: how to add item for the category number 8 of the menu
Reply With Quote #11

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.
__________________








CrazY. is offline