08.02.2017, 19:36
The 2 functions i use:
FreeIndses() is called on starting of the command.
I cant use the normal for loop for the only reason that i want to access random elements within the array, not crescent or decreasing, thus i made the function getIndex which checks if the index hasnt been used already, if not return it & store it into the indexes array... until its full...
I couldnt think of another way... i know i am using alot of loops... but is there any other way?
Response is kinda 4-5 seconds.
PHP Code:
new Indexes[MAX_MESSAGES];
stock FreeIndexes()
{
for(new i =0; i< MAX_MESSAGES; i++)
{
Indexes[i] = 0;
}
}
stock getIndex()
{
new Index = random(MAX_MESSAGES-1), j;
for(new i =0; i< MAX_MESSAGES; i++)
{
if(Indexes[i] != Index)
{
if(Indexes[i] == 0)
{
Indexes[i] = Index;
break;
}
j = Index;
}
}
return j;
}
I cant use the normal for loop for the only reason that i want to access random elements within the array, not crescent or decreasing, thus i made the function getIndex which checks if the index hasnt been used already, if not return it & store it into the indexes array... until its full...
I couldnt think of another way... i know i am using alot of loops... but is there any other way?
Response is kinda 4-5 seconds.
