18.01.2011, 11:57
with your example the pin could be 3digit, 2digit and even 1digit number.
use
with this the pin minimum can be 1000 and maximum of 9999 (1000+8999=9999)
My version of your code -
This isn't the best sollution offcourse and in some cases the number may be the same.
use
Код:
pin = 1000+random(8999);
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; }