04.04.2016, 23:01
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:
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.
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(playerid, params[]) {
if(isnull(params)) {
return SendClientMessage(playerid, -1, "You have to enter something!");
}
new
emptyIndex = 0;
for(new i = 0; i < MAX_INDEXES; i ++) {
if(!isnull(TheArray[playerid][i])) {
emptyIndex ++;
continue;
}
else {
printf("TheArray[playerid][%d] (before strmid): %s", i, TheArray[playerid][i]);
strmid(TheArray[playerid][i], params, 0, strlen(params));
printf("TheArray[playerid][%d]: %s", i, TheArray[playerid][i]);
emptyIndex = 0;
break;
}
}
if(emptyIndex != 0) {
print("All indexes are occupied.");
}
return true;
}
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.