Giving random questions.
#1

Hello there. I have a little problem out there... I have a script that asks ten questions to players in order to play on server. I want these messages to appear randomly but if a message has already been asked before by the system, it shouldn't ask it again.

It's like, I have numbers from 1 to 10 and I randomly pick one, but I don't want my next random selection to be previous random selection. If system selected 1, it shouldn't select 1 again on next question.

Waiting for the help, thanks.
Reply
#2

Bump.
Reply
#3

You'll have to create a saving variable which logs what player has answered the questions.
Reply
#4

Quote:
Originally Posted by Peach
Посмотреть сообщение
You'll have to create a saving variable which logs what player has answered the questions.
Only thing I need is giving out ten random numbers, from 0 to 9. But these numbers must not be equal to each other and must change for each player.
Reply
#5

I suggest you use this function with foreach.

PHP код:
stock randomEx(minnum cellminmaxnum cellmax)
{
    return 
random(maxnum minnum 1) + minnum;

Reply
#6

Quote:
Originally Posted by Peach
Посмотреть сообщение
I suggest you use this function with foreach.

PHP код:
stock randomEx(minnum cellminmaxnum cellmax)
{
    return 
random(maxnum minnum 1) + minnum;

I don't think that'll work because it will add or subtract the minnum and then will add it again with one point more, but I just want it to stay between 0-9.
Reply
#7

The +1 is used for 0.

If you do RandomEx(0,10); then it'll only go up to 0 and 9 because of it counting 0 as a number.
Reply
#8

Quote:
Originally Posted by Peach
Посмотреть сообщение
The +1 is used for 0.

If you do RandomEx(0,10); then it'll only go up to 0 and 9 because of it counting 0 as a number.
I'll try that and write again to here, thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)