Problem with 3D Dimensional array.
#2

Of course it will not work. It is always going to check the first index and if the first index is occupied, it will display the error. Hence why it only works once.

You'll have to reconfigure it to fit in your dialog as I've used it in a command:
PHP код:
#undef MAX_PLAYERS
#define MAX_PLAYERS    30
#define MAX_INDEXES    50
new
    
TheArray[MAX_PLAYERS][MAX_INDEXES][128];
CMD:functest(playeridparams[]) {
    if(
isnull(params)) {
        return 
SendClientMessage(playerid, -1"You have to enter something!");
    }
    new
        
emptyIndex 0;
    for(new 
0MAX_INDEXES++) {
        if(!
isnull(TheArray[playerid][i])) {
            
emptyIndex ++;
            continue;
        }
        else {
            
printf("TheArray[playerid][%d] (before strmid): %s"iTheArray[playerid][i]);
            
strmid(TheArray[playerid][i], params0strlen(params));
            
printf("TheArray[playerid][%d]: %s"iTheArray[playerid][i]);
            
emptyIndex 0;
            break;
        }
    }
    if(
emptyIndex != 0) {
        print(
"All indexes are occupied.");
    }
    return 
true;

Also not redefining MAX_PLAYERS extended the compilation time by 6 seconds (from 0.3 seconds in a blank template)! Because: An array of 500 indexes with another 50 cells each and then another 128 cells each. That's 12,800,000 bytes or 12.8 MB.

EDIT: I forgot about the recent increase of MAX_PLAYERS from 500 to 1000, so instead of 12.8MB it's 25MB!
EDIT2: I defined a constant for the maximum cells to make it easier to modify if needed later on.
Reply


Messages In This Thread
Problem with 3D Dimensional array. - by Black Axe - 04.04.2016, 22:19
Re: Problem with 3D Dimensional array. - by AndySedeyn - 04.04.2016, 23:01
Re: Problem with 3D Dimensional array. - by Black Axe - 04.04.2016, 23:16
Re: Problem with 3D Dimensional array. - by AndySedeyn - 04.04.2016, 23:24

Forum Jump:


Users browsing this thread: 2 Guest(s)