Posts: 1,047
Threads: 23
Joined: Jun 2009
pawn Код:
stock Give5RandomNumbers(number,&A,&B,&C,&D,&E)
{
new rand[5];// Create the variables
rand[0] = random(number);// assign a random value to rand[0] with the max 'number'
XXXA://declare a position
rand[1] = random(number); // assign second number
if(
rand[0] == rand[1]// check if first value matches second value
)
goto XXXA;// if it matches it will go to our position back to pick a new random number
XXXB://and so on....
rand[2] = random(number);
if(
rand[0] == rand[2] ||
rand[1] == rand[2]
)
goto XXXB;
XXXC:
rand[3] = random(number);
if(
rand[0] == rand[3] ||
rand[1] == rand[3] ||
rand[2] == rand[3]
)
goto XXXC;
XXXD:
rand[4] = random(number);
if(
rand[0] == rand[4] ||
rand[1] == rand[4] ||
rand[2] == rand[4] ||
rand[3] == rand[4]
)
goto XXXD;
A = rand[0];
B = rand[1];
C = rand[2];
D = rand[3];
E = rand[4];
return 1;
}
I do not recommend to use this but this is an exmpale. I have written it now ;P But it should work.
if it stucks in a big loop it wil lag your server, if it stucks in a forever loop your server will need a restart.
Posts: 1,047
Threads: 23
Joined: Jun 2009
bigger doesn't mean always slower xD
And when I look at your code your chance tostuck in an infite loop is bigger and the code is much slower.
Posts: 135
Threads: 30
Joined: Mar 2008
Reputation:
0
Thanks Vince, and everyone else.