Random PIN
#3

Theres the random(max+1) function pawn. https://sampwiki.blast.hk/wiki/Random

To ensure it has 4 digits you could just do this:
pawn Код:
new pin = 1000 + random(9000);
Or if you want to store it as string (that would be better anyways considering that you probably want to check the pin in a cmd or something) you can also make it start with a 0:
pawn Код:
new pin[4];
format(pin, 4, "%04d", random(10000));
The %04d in the format means "print 4 digits of the integer and fill empty spaces with 0"
Reply


Messages In This Thread
Random PIN - by Fjclip99 - 28.07.2014, 22:13
Re: Random PIN - by DaniceMcHarley - 28.07.2014, 22:22
Re: Random PIN - by Mauzen - 28.07.2014, 22:25
Re: Random PIN - by ViniBorn - 29.07.2014, 01:09
Re: Random PIN - by DaniceMcHarley - 29.07.2014, 01:15
Re: Random PIN - by ViniBorn - 29.07.2014, 01:57
Re: Random PIN - by DaniceMcHarley - 29.07.2014, 02:07
Re: Random PIN - by Ihateyou - 29.07.2014, 05:54

Forum Jump:


Users browsing this thread: 1 Guest(s)