27.05.2015, 15:42
(
Последний раз редактировалось Sledgehammer; 27.05.2015 в 16:28.
)
Someone had an inquery how to prevent the same question showing more than once:
I haven't tested this code, but it should work.
Код:
#define MAX_QUESTIONS 7
new PlayerTestQuestionsAns[MAX_PLAYERS]; // Checks how many questions have been answered already.
new PlayerTestQuestionsGot[MAX_PLAYERS][MAX_QUESTIONS]; // The reference of questions answered.
// Under on player connect
PlayerTestQuestion[playerid] = -1; // From the previous code as shown above.
PlayerTestQuestionsAns[playerid] = 0;
for(new i; i < MAX_QUESTIONS; i++)
PlayerTestQuestionsGot[playerid][i] = -1;
// Code shown above, The stuff you need to add is highlighted in bold.
PlayerTestQuestion[playerid] = random(sizeof(Test));
new
rand = random(2);
PlayerQuizCheck: while(PlayerTestQuestionsGot[playerid][x] == PlayerTestQuestion[playerid])
{
if(x > MAX_QUESTIONS)
break;
PlayerTestQuestions[playerid] = random(sizeof(Test));
goto PlayerQuizCheck;
break;
}
else
{
if(x > MAX_QUESTIONS || x > PlayerTestQuestionsAns[playerid])
break;
x++;
}
PlayerTestQuestionsAns[playerid]++;
PlayerTextQuestionsGot[playerid][PlayerTestQuestionsAns[playerid]] = PlayerTestQuestions[playerid];
//etc.

