С тебя печенье.
PHP Code:
#include <a_samp>
#define InitRandomNumberArr(%0,%1) new %1[%0+1]; ReInitRandomNumberArr(%1, %0+1)
stock ReInitRandomNumberArr(rand_arr[], size = sizeof(rand_arr))
{
for(new i = size; i--;)
{
rand_arr[i] = i;
}
}
stock GetRandomNumberFromArr(rand_arr[], size = sizeof(rand_arr))
{
if(rand_arr[--size] == 0)
{
return -1;
}
new num = random(rand_arr[size]);
new r_num = rand_arr[num];
rand_arr[num] = rand_arr[--rand_arr[size]];
return r_num;
}
stock SetRandomMaxNumberArr(number, rand_arr[], size = sizeof(rand_arr))
{
--size;
if(number > size) number = size;
if(number < 1) number = 1;
rand_arr[size] = number;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#define MAX_MAPS (49)
new MapPlayer[MAX_MAPS][2] =
{
// {?? ? ?? ???????.}
{1, 20},
{21, 31},
{21, 31},
{21, 31},
{1, 20},
{1, 20},
{21, 31},//6
{1, 20},
{1, 20},
{1, 20},
{1, 20},
{21, 31},
{1, 20},//12
{32, 42},//?????? ??? ?? 43 ?? 52
{21, 31},
{1, 20},
{1, 20},
{32, 42},//17
{21, 31},
{32, 42},//19
{21, 31},//20
{32, 42},//21
{32, 42},
{21, 31},
{1, 20},
{1, 20},
{21, 31},//26
{32, 42},//27
{21, 31},//28
{21, 31},//29
{32, 42},//30
{32, 42},//31
{21, 31},
{1, 20},
{1, 20},
{1, 20},
{21, 31},
{21, 31},//37
{32, 42},
{1, 20},
{21, 31},//20
{21, 31},//41
{21, 31},//42
{32, 42},//43
{32, 42},//44
{21, 31},
{1, 20},
{1, 20},
{1, 20}//48
};
public OnFilterScriptInit()
{
new random_Maps[6] = {-1, ...};
new tmp_MapPlayer[MAX_MAPS] = {-1, ...};
new tmp_MapCount = 0;
for(new m = 0; m < MAX_MAPS; m++)//Для начала найдём подxодящие арены
{
if(MapPlayer[m][0] <= 32 <= MapPlayer[m][1]) // проверка по онлайну, сейчас 32 игрока
{
tmp_MapPlayer[tmp_MapCount] = m;
tmp_MapCount++;
}
}
InitRandomNumberArr(MAX_MAPS, tmp_arr_rand_num);//Инициализируем массив под рандом (язык статичный, выделяем максимальный размер MAX_MAPS)
SetRandomMaxNumberArr(tmp_MapCount, tmp_arr_rand_num);//Установим максимальное рандомное число (tmp_MapCount), сколько у нас карт подошло под условие
for(new m = 0; m < 6; m++)//Получим рандомные 6 карт
{
new value = GetRandomNumberFromArr(tmp_arr_rand_num);
if(value > -1)
{
random_Maps[m] = tmp_MapPlayer[value];
}
}
for(new m = 0; m < 6; m++)//Приведём массив в порядок
{
if(random_Maps[m] == -1)
{
new bool:bOK = false;
for(new k = m; k < 6; k++)
{
if(random_Maps[k] > -1)
{
random_Maps[m] = random_Maps[k];
random_Maps[k] = -1;
bOK = true;
}
}
if(bOK == false)
{
break;
}
}
}
printf("tmp_MapCount = %d", tmp_MapCount);
for(new i = 0; i < sizeof(random_Maps); i++)
{
printf("random_Maps[%d] = %d", i, random_Maps[i]);
}
return 1;
}