Phone system help!
#3

If you want a minimum value, then you have to start at that value and generate only how much is missing from your max.
In your code it would be:
Код:
new rand = 10_000 + random(90_000);
I would suggest saving these values somewhere so that you could edit them in an easier manner.
E.g.
Код:
#define MAX_PHONE_NUMBER 100_000 //along with your other defines/globals/whatever
#define MIN_PHONE_NUMBER 10_000
new rand = MIN_PHONE_NUMBER + random(MAX_PHONE_NUMBER - MIN_PHONE_NUMBER);
That way if you want to change the phone number limit to something else, all you need to do is change the defines.

If you want to create unique phone number, you will have to use some place to store the current numbers, like a MySQL database. Store the phone numbers along with user data and after generating a new number, query to see if it already exists. I think you could do it directly in the database and then just fetch the number but I haven't had to do it and don't want mess up with it.
Reply


Messages In This Thread
Phone system help! - by bosmania - 24.02.2019, 12:40
Re: Phone system help! - by PepsiCola23 - 24.02.2019, 12:57
Re: Phone system help! - by AdamsLT - 24.02.2019, 13:05
Re: Phone system help! - by bosmania - 24.02.2019, 13:06
Re: Phone system help! - by bosmania - 24.02.2019, 13:14
Re: Phone system help! - by AdamsLT - 24.02.2019, 13:25

Forum Jump:


Users browsing this thread: 2 Guest(s)