4digit random numbers
#3

with your example the pin could be 3digit, 2digit and even 1digit number.
use
Код:
pin =  1000+random(8999);
with this the pin minimum can be 1000 and maximum of 9999 (1000+8999=9999)

My version of your code -
Код:
stock GenerateBankPin(playerid) 
{
  new pin =  1000+random(8999); //generates a number
  for ( new i = 0; i < GetMaxPlayers() ; i++ )  //loops through all the server player slots (defined in server.cfg)
  {
    if ( IsPlayerConnected ( i ) && pBankPin [ i ] ==  bpin && i!=playerid) pin =  1000+random(8999); //checks if player in that slot is connected and if its pin is the same as the playerid's then it generates a new pin.
  }
  return pin;
}
This isn't the best sollution offcourse and in some cases the number may be the same.
Reply


Messages In This Thread
4digit random numbers - by THE_KNOWN - 18.01.2011, 11:43
Re: 4digit random numbers - by Universal - 18.01.2011, 11:54
Re: 4digit random numbers - by Macluawn - 18.01.2011, 11:57
Re: 4digit random numbers - by THE_KNOWN - 18.01.2011, 11:58
Re: 4digit random numbers - by THE_KNOWN - 18.01.2011, 11:59
Re: 4digit random numbers - by Macluawn - 18.01.2011, 12:01
Re: 4digit random numbers - by THE_KNOWN - 18.01.2011, 12:13
Re: 4digit random numbers - by THE_KNOWN - 18.01.2011, 12:14

Forum Jump:


Users browsing this thread: 1 Guest(s)