Array - how can I skip a repeated value in an array?
#3

Quote:
Originally Posted by IstuntmanI
Посмотреть сообщение
This is the best method I could think of:
pawn Код:
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);
}
Thanks for replying! I just figured a way to do it, too. And that's kinda what I did, thanks a lot
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)