09.03.2013, 19:40
pawn Код:
stock GetRandomRows(values[], amount, max_values = sizeof(values))
{
if(max_values <= amount && values[0] == -1)
{
new i, i2, rand;
while(i < max_values)
{
rand = random(amount);
i2 = 0;
while(i2 < max_values)
{
if(values[i2] == rand)
{
rand = random(amount);
i2 = 0;
continue;
}
i2++;
}
values[i] = rand;
i++;
}
return 1;
}
return 0;
}
pawn Код:
new values[10] = { -1, ... };
GetRandomRows(values, sizeof(strings_array));