{0, 380, "asdfafa", "Other"},
{0, 578, "asdfafafdsafa", "Other"}
{0, 578, "asdfafafdxsafasfa", "Another"}
for (new x = 0; x < sizeof(datatesting); x++)
{
format(string, sizeof(string), "%s\t%d\n",datatesting[x][dmCategory],x);
strcat(fullstr, string);
}
new bool:continueLoop = true;
for (new x = 0; x < sizeof(datatesting); x++)
{
for (new xx = 0; xx < x; xx++)
{
if (strfind(datatesting[xx][dmCategory], datatesting[xx][dmCategory]) == 0) // strfind is faster than strcmp
{
continueLoop = false; // we can't break here the main loop, so we set our variable as false
break; // already found a duplicate, stop this duplicate-detector loop !
}
}
if (continueLoop == false) // if a duplicate one was detected, continue our loop
{
continueLoop = true;
continue;
}
format(string, sizeof(string), "%s\t%d\n",datatesting[x][dmCategory],x);
strcat(fullstr, string);
}
This is the best method I could think of:
pawn Код:
|
for (new x = 0; x < sizeof(datatesting)-1; x++) { if(strlen(datatesting[x][dmCategory]) < 1) continue; for (new xx = x+1; xx < x; xx++) { if(strlen(datatesting[xx][dmCategory]) < 1) continue; if (strfind(datatesting[x][dmCategory], datatesting[xx][dmCategory]) == 0) // strfind is faster than strcmp { continueLoop = false; // we can't break here the main loop, so we set our variable as false break; // already found a duplicate, stop this duplicate-detector loop ! } } if (continueLoop == false) // if a duplicate one was detected, continue our loop { continueLoop = true; continue; } format(string, sizeof(string), "%s\t%d\n",datatesting[x][dmCategory],x); strcat(fullstr, string); }
if (strfind(datatesting[xx][dmCategory], datatesting[xx][dmCategory]) == 0)
This is the best method I could think of:
pawn Код:
|
How about...
Код:
for (new x = 0; x < sizeof(datatesting)-1; x++) { if(strlen(datatesting[x][dmCategory]) < 1) continue; for (new xx = x+1; xx < x; xx++) { if(strlen(datatesting[xx][dmCategory]) < 1) continue; if (strfind(datatesting[x][dmCategory], datatesting[xx][dmCategory]) == 0) // strfind is faster than strcmp { continueLoop = false; // we can't break here the main loop, so we set our variable as false break; // already found a duplicate, stop this duplicate-detector loop ! } } if (continueLoop == false) // if a duplicate one was detected, continue our loop { continueLoop = true; continue; } format(string, sizeof(string), "%s\t%d\n",datatesting[x][dmCategory],x); strcat(fullstr, string); } |
Hello, the one provided by IstuntmanI works by changing
pawn Код:
if (strfind(datatesting[x][dmCategory], datatesting[xx][dmCategory]) == 0) |
"Help me man " and "Help me"
Hello, the one provided by IstuntmanI works by changing
pawn Код:
if (strfind(datatesting[x][dmCategory], datatesting[xx][dmCategory]) == 0) |
enum e_array
{
something_1,
something_2,
something_3[40],
category[20]
};
new array[][e_array] =
{
{0, 380, "asdfafa", "Other"},
{0, 578, "asdfafafdsafa", "Other"},
{0, 578, "asdfafafdxsafasfadwada", "Another"},
{0, 578, "asdfafafdxsafasfawadaaasd", "Another"},
{0, 578, "asdfafafdxsafasfawadaaasdfff", "Test Something"},
{0, 578, "asdfafafdxsafasfawadaaasdffffawfwa", "Another Test"},
{0, 578, "asdfafafdxsafasfawadaaasd", "Test"},
{0, 578, "asdfafafdxsafasfawadaaasd", "Another"},
{0, 380, "asdfafa", "Test"}
};
main()
{
new categories[10][20];
for(new i = 0, j = sizeof(array), count, bool:duplicate; i < j; i ++, duplicate = false)
{
for(new k = 0; categories[k][0] != EOS; k ++)
{
if(!strcmp(array[i][category], categories[k], false))
{
duplicate = true;
break;
}
}
if(!duplicate)
{
strcat(categories[count ++], array[i][category], 20);
printf("%d %s", i, array[i][category]);
}
}
}