[HELP] Random - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] Random (
/showthread.php?tid=294456)
[HELP] Random -
Dirkon - 01.11.2011
Hey, I have problem with random();
my script:
pawn Код:
new RandomLetter[][] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "O", "P", "Q", "R", "S", "T", "U", "V", "X", "Y", "Z" };
new rand = random(sizeof(RandomLetter));
format(Numbers, sizeof(Numbers), "%s%s%s %d%d%d",RandomLetter[rand] ,RandomLetter[rand] ,RandomLetter[rand] ,random(9), random(9), random(9));
The problem is, that it formats it as: ZZZ 468 or BBB 865, etc. Always the same letter.
How to fix it?
Re: [HELP] Random -
IstuntmanI - 01.11.2011
Change
Код:
format(Numbers, sizeof(Numbers), "%s%s%s %d%d%d",RandomLetter[rand] ,RandomLetter[rand] ,RandomLetter[rand] ,random(9), random(9), random(9));
to
Код:
format(Numbers, sizeof(Numbers), "%s%s%s %d%d%d",RandomLetter[random(sizeof(RandomLetter))] ,RandomLetter[random(sizeof(RandomLetter))] ,RandomLetter[random(sizeof(RandomLetter))] ,random(9), random(9), random(9));
and remove
Код:
new rand = random(sizeof(RandomLetter));