RP Test
#6

Someone had an inquery how to prevent the same question showing more than once:

Код:
#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.
I haven't tested this code, but it should work.
Reply


Messages In This Thread
RP Test - by JaKe Elite - 27.05.2015, 08:37
Re: RP Test - by Sledgehammer - 27.05.2015, 08:42
Re: RP Test - by JaKe Elite - 27.05.2015, 08:43
Re: RP Test - by Sledgehammer - 27.05.2015, 09:41
Re: RP Test - by JaKe Elite - 27.05.2015, 10:03
Re: RP Test - by Sledgehammer - 27.05.2015, 15:42

Forum Jump:


Users browsing this thread: 1 Guest(s)