new TheArray[MAX_PLAYERS][50][128];
for(new i = 0; i < 50; i++)
{
if(strlen(TheArray[giveplayerid][i]) < 1)
{
strmid(TheArray[giveplayerid][i], inputtext, 0, 128);
return 1;
}
else
{
SCM(playerid, COLOR_GREY, "ERROR: ERROR MESSAGE");
return 1;
}
}
return 1;
#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;
}
|
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 код:
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. |
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;
}